diff --git a/CHANGELOG.md b/CHANGELOG.md index a60f6db..e227128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +- 0.4.3-1 (2025-01-30): + + Fixed zoom reset in charts. + - 0.4.2-1 (2025-01-28): + Fixed handling of gaps in metrics. + Moved the Go project to the GitHub namespace. diff --git a/Makefile b/Makefile index a29f674..6394be5 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SHELL := /bin/bash ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) UMASK := 022 -VERSION := 0.4.2 +VERSION := 0.4.3 ITERATION := 1 REVISION := $(shell cd '$(ROOT)' && git rev-parse --short HEAD) ENVIRONMENT ?= production diff --git a/README.md b/README.md index 67237a4..dfded2d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/allenta/varnishmon)](https://goreportcard.com/report/github.com/allenta/varnishmon) [![Go Reference](https://pkg.go.dev/badge/github.com/allenta/varnishmon.svg)](https://pkg.go.dev/github.com/allenta/varnishmon) -`varnishmon` is a utility inspired by the [classic `atop` tool](https://www.atoptool.nl). It periodically collects metrics from [Varnish Cache](https://varnish-cache.org) / [Varnish Enterprise](https://www.varnish-software.com/products/varnish-enterprise/) using the [`varnishstat` utility](https://varnish-cache.org/docs/trunk/reference/varnishstat.html), stores them in a [DuckDB](https://duckdb.org) database, and provides a simple built-in web interface for visualizing the timeseries data. **In summary, `varnishmon` is a tool designed to effortlessly record, visualize, and share `varnishstat` output with minimal setup.** +`varnishmon` is a utility inspired by the [classic `atop` tool](https://www.atoptool.nl). It periodically collects metrics from [Varnish Cache](https://varnish-cache.org) / [Varnish Enterprise](https://www.varnish-software.com/products/varnish-enterprise/) using the [`varnishstat` utility](https://varnish-cache.org/docs/trunk/reference/varnishstat.html), stores them in a [DuckDB](https://duckdb.org) database, and provides a simple built-in web interface for visualizing the timeseries data. **In summary, `varnishmon` is a tool designed to effortlessly record, visualize, and share historical `varnishstat` output with minimal setup.** ![varnishmon demo](extras/demo.png) diff --git a/assets/static/app.js b/assets/static/app.js index 8e3a66f..9b70a88 100644 --- a/assets/static/app.js +++ b/assets/static/app.js @@ -145,4 +145,4 @@ var n=r(45708),i=n.Buffer;function a(t,e){for(var r in t)e[r]=t[r]}function o(t, */ t.exports=function(){"use strict";var t={},e={};function r(r,n,i){if(e[r]=i,"index"===r){var a="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",o={};return e.shared(o),e.index(t,o),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))),t}}return r("shared",["exports"],(function(t){function e(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){t.done?r(t.value):i(t.value).then(o,s)}l((n=n.apply(t,e||[])).next())}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var n=i;function i(t,e){this.x=t,this.y=e}i.prototype={clone:function(){return new i(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[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,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=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},i.convert=function(t){return t instanceof i?t:Array.isArray(t)?new i(t[0],t[1]):t};var a=r(n),o=s;function s(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}s.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:s=r,r=.5*(s-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var l=r(o);let c,u;function h(){return null==c&&(c="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),c}function f(){if(null==u&&(u=!1,h())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function m(t,e,r,n){const i=new l(t,e,r,n);return t=>i.solve(t)}const g=m(.25,.1,.25,1);function y(t,e,r){return Math.min(r,Math.max(e,t))}function v(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function x(t,e){const r=[];for(const n in t)n in e||r.push(n);return r}function _(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}function b(t,e){const r={};for(let n=0;n=0)return!0;return!1}const I={};function P(t){I[t]||("undefined"!=typeof console&&console.warn(t),I[t]=!0)}function z(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function D(t,e,r,n){const i=e.y-t.y,o=e.x-t.x,s=n.y-r.y,l=n.x-r.x,c=s*o-l*i;if(0===c)return null;const u=(l*(t.y-r.y)-s*(t.x-r.x))/c;return new a(t.x+u*o,t.y+u*i)}function O([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}}function R(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}function F(t){const e=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,r={};if(t.replace(e,((t,e,n,i)=>{const a=n||i;return r[e]=!a||a.toLowerCase(),""})),r["max-age"]){const t=parseInt(r["max-age"],10);isNaN(t)?delete r["max-age"]:r["max-age"]=t}return r}let B=null;function N(t){if(null==B){const e=t.navigator?t.navigator.userAgent:null;B=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return B}function j(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const U=t=>e(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),V="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=",q=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=V}))},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):V}));function H(t,e,r,n,i){const a=4*Math.max(-e,0),o=(Math.max(0,r)-r)*n*4+a,s=4*n,l=Math.max(0,e),c=Math.max(0,r);return{rect:{x:l,y:c,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-c},layout:[{offset:o,stride:s}]}}function G(t,r,n,i,a){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const o=null==e?void 0:e.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw new Error(`Unrecognized format ${o}`);const s=o.startsWith("BGR"),l=new Uint8ClampedArray(i*a*4);if(yield e.copyTo(l,H(t,r,n,i,a)),s)for(let t=0;t{t.removeEventListener(e,r,n)}}}function J(t){return t*Math.PI/180}const K="AbortError";function Q(t){return t.message===K}function tt(){return new Error(K)}const et={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function rt(t){return et.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}function nt(t,e){et.REGISTERED_PROTOCOLS[t]=e}function it(t){delete et.REGISTERED_PROTOCOLS[t]}const at="global-dispatcher";class ot 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 st=()=>R(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,lt=t=>/^file:/.test(t)||/^file:/.test(st())&&!/^\w+:/.test(t);function ct(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:st(),signal:r.signal});"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");const n=yield fetch(e);if(!n.ok){const e=yield n.blob();throw new ot(n.status,n.statusText,t.url,e)}let i;i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const a=yield i;if(r.signal.aborted)throw tt();return{data:a,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}function ut(t,e){return new Promise(((r,n)=>{var i;const a=new XMLHttpRequest;a.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(a.responseType="arraybuffer");for(const e in t.headers)a.setRequestHeader(e,t.headers[e]);"json"===t.type&&(a.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===t.credentials,a.onerror=()=>{n(new Error(a.statusText))},a.onload=()=>{if(!e.signal.aborted)if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let e=a.response;if("json"===t.type)try{e=JSON.parse(a.response)}catch(t){return void n(t)}r({data:e,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires")})}else{const e=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});n(new ot(a.status,a.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{a.abort(),n(tt())})),a.send(t.body)}))}const ht=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const r=rt(t.url);if(r)return r(t,e);if(R(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:at},e)}if(!lt(t.url)){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return ct(t,e);if(R(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:at},e)}return ut(t,e)},ft=(t,e)=>ht(_(t,{type:"json"}),e),pt=(t,e)=>ht(_(t,{type:"arrayBuffer"}),e);function dt(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}const mt=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e)};for(const r of t){const t=window.document.createElement("source");dt(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t)}}))};function gt(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e))}function yt(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}class vt{constructor(t,e={}){_(this,e),this.type=t}}class xt extends vt{constructor(t,e={}){super("error",_({error:t},e))}}class _t{on(t,e){return this._listeners=this._listeners||{},gt(t,e,this._listeners),this}off(t,e){return yt(t,e,this._listeners),yt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},gt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new vt(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)yt(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(_(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t))}else t instanceof xt&&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}}var bt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},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 wt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Tt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return wt.forEach((t=>{t in e&&(r[t]=e[t])})),r}function kt(t){t=t.slice();const e=Object.create(null);for(let r=0;r{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):a.push(t)})),r=r.concat(i),Ot(a,e.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:"setStyle",args:[e]}]}return r}class Ft{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function Bt(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class Nt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class jt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new jt(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 Ut={kind:"null"},Vt={kind:"number"},qt={kind:"string"},Ht={kind:"boolean"},Gt={kind:"color"},Wt={kind:"object"},Zt={kind:"value"},Yt={kind:"error"},Xt={kind:"collator"},$t={kind:"formatted"},Jt={kind:"padding"},Kt={kind:"resolvedImage"},Qt={kind:"variableAnchorOffsetCollection"};function te(t,e){return{kind:"array",itemType:t,N:e}}function ee(t){if("array"===t.kind){const e=ee(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const re=[Ut,Vt,qt,Ht,Gt,$t,Wt,te(Zt),Jt,Kt,Qt];function ne(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!ne(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 re)if(!ne(t,e))return null}return`Expected ${ee(t)} but found ${ee(e)} instead.`}function ie(t,e){return e.some((e=>e.kind===t.kind))}function ae(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 oe(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const se=.96422,le=1,ce=.82521,ue=4/29,he=6/29,fe=3*he*he,pe=he*he*he,de=Math.PI/180,me=180/Math.PI;function ge(t){return(t%=360)<0&&(t+=360),t}function ye([t,e,r,n]){let i,a;const o=xe((.2225045*(t=ve(t))+.7168786*(e=ve(e))+.0606169*(r=ve(r)))/le);t===e&&e===r?i=a=o:(i=xe((.4360747*t+.3850649*e+.1430804*r)/se),a=xe((.0139322*t+.0971045*e+.7141733*r)/ce));const s=116*o-16;return[s<0?0:s,500*(i-o),200*(o-a),n]}function ve(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function xe(t){return t>pe?Math.pow(t,1/3):t/fe+ue}function _e([t,e,r,n]){let i=(t+16)/116,a=isNaN(e)?i:i+e/500,o=isNaN(r)?i:i-r/200;return i=le*we(i),a=se*we(a),o=ce*we(o),[be(3.1338561*a-1.6168667*i-.4906146*o),be(-.9787684*a+1.9161415*i+.033454*o),be(.0719453*a-.2289914*i+1.4052427*o),n]}function be(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function we(t){return t>he?t*t*t:fe*(t-ue)}function Te(t){const[e,r,n,i]=ye(t),a=Math.sqrt(r*r+n*n);return[Math.round(1e4*a)?ge(Math.atan2(n,r)*me):NaN,a,e,i]}function ke([t,e,r,n]){return t=isNaN(t)?0:t*de,_e([r,Math.cos(t)*e,Math.sin(t)*e,n])}function Ae([t,e,r,n]){function i(n){const i=(n+t/30)%12,a=e*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return t=ge(t),e/=100,r/=100,[i(0),i(8),i(4),n]}function Me(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=Ie[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[Se(t.slice(r,r+=e)),Se(t.slice(r,r+=e)),Se(t.slice(r,r+=e)),Se(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/,r=t.match(e);if(r){const[t,e,n,i,a,o,s,l,c,u,h,f]=r,p=[i||" ",s||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[n,o,c].join(""),r="%%%"===t?100:""===t?255:0;if(r){const t=[Ce(+e/r,0,1),Ce(+a/r,0,1),Ce(+l/r,0,1),h?Ee(+h,f):1];if(Le(t))return t}}return}}const r=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/,n=t.match(r);if(n){const[t,e,r,i,a,o,s,l,c]=n,u=[r||" ",a||" ",s].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const t=[+e,Ce(+i,0,100),Ce(+o,0,100),l?Ee(+l,c):1];if(Le(t))return Ae(t)}}}function Se(t){return parseInt(t.padEnd(2,t),16)/255}function Ee(t,e){return Ce(e?t/100:t,0,1)}function Ce(t,e,r){return Math.min(Math.max(e,t),r)}function Le(t){return!t.some(Number.isNaN)}const Ie={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 Pe{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 Pe)return t;if("string"!=typeof t)return;const e=Me(t);return e?new Pe(...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",Te(this.rgb))}get lab(){return this.overwriteGetter("lab",ye(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})`}}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1);class ze{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 De{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i}}class Oe{constructor(t){this.sections=t}static fromString(t){return new Oe([new De(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 Oe?t:Oe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Re{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Re)return t;if("number"==typeof t)return new Re([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 Re(t)}}toString(){return JSON.stringify(this.values)}}const Fe=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Be{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Be)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 Ue(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Pe||t instanceof ze||t instanceof Oe||t instanceof Re||t instanceof Be||t instanceof Ne)return!0;if(Array.isArray(t)){for(const e of t)if(!Ue(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ue(t[e]))return!1;return!0}return!1}function Ve(t){if(null===t)return Ut;if("string"==typeof t)return qt;if("boolean"==typeof t)return Ht;if("number"==typeof t)return Vt;if(t instanceof Pe)return Gt;if(t instanceof ze)return Xt;if(t instanceof Oe)return $t;if(t instanceof Re)return Jt;if(t instanceof Be)return Qt;if(t instanceof Ne)return Kt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Ve(e);if(r){if(r===t)continue;r=Zt;break}r=t}return te(r||Zt,e)}return Wt}function qe(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Pe||t instanceof Oe||t instanceof Re||t instanceof Be||t instanceof Ne?t.toString():JSON.stringify(t)}class He{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(!Ue(t[1]))return e.error("invalid value");const r=t[1];let n=Ve(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 He(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Ge{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const We={string:qt,number:Vt,boolean:Ht,object:Wt};class Ze{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,a;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in We)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=We[r],n++}else i=Zt;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);a=t[2],n++}r=te(i,a)}else{if(!We[i])throw new Error(`Types doesn't contain name = ${i}`);r=We[i]}const a=[];for(;nt.outputDefined()))}}const Ye={"to-boolean":Ht,"to-color":Gt,"to-number":Vt,"to-string":qt};class Xe{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(!Ye[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=Ye[r],i=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:je(e[0],e[1],e[2],e[3]),!r))return new Pe(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ge(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=Re.parse(e);if(n)return n}throw new Ge(`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=Be.parse(e);if(n)return n}throw new Ge(`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 Ge(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Oe.fromString(qe(this.args[0].evaluate(t)));case"resolvedImage":return Ne.fromString(qe(this.args[0].evaluate(t)));default:return qe(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const $e=["Unknown","Point","LineString","Polygon"];class Je{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?$e[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]=Pe.parse(t)),e}}class Ke{constructor(t,e,r=[],n,i=new jt,a=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=a,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 Ze(e,[t]):"coerce"===r?new Xe(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 He)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Je;try{n=new He(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 void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`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 Ke(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 Nt(r,t))}checkSubtype(t,e){const r=ne(t,e);return r&&this.error(r),r}}class Qe{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 Ge(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ge(`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 rr{constructor(t,e){this.type=Ht,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,Zt),n=e.parse(t[2],2,Zt);return r&&n?ie(r.type,[Ht,qt,Vt,Ut,Zt])?new rr(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ee(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!ae(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ee(Ve(e))} instead.`);if(!ae(r,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ee(Ve(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class nr{constructor(t,e,r){this.type=Vt,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,Zt),n=e.parse(t[2],2,Zt);if(!r||!n)return null;if(!ie(r.type,[Ht,qt,Vt,Ut,Zt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ee(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Vt);return i?new nr(r,n,i):null}return new nr(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!ae(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ee(Ve(e))} instead.`);if(!ae(r,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ee(Ve(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ir{constructor(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a}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={},a=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,Ve(t)))return null}else r=Ve(t);if(void 0!==i[String(t)])return c.error("Branch labels must be unique.");i[String(t)]=a.length}const u=e.parse(l,o,n);if(!u)return null;n=n||u.type,a.push(u)}const o=e.parse(t[1],1,Zt);if(!o)return null;const s=e.parse(t[t.length-1],t.length-1,n);return s?"value"!==o.type.kind&&e.concat(1).checkSubtype(r,o.type)?null:new ir(r,n,o,i,a,s):null}evaluate(t){const e=this.input.evaluate(t);return(Ve(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 ar{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 or{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,Zt),n=e.parse(t[2],2,Vt);if(!r||!n)return null;if(!ie(r.type,[te(Zt),qt,Zt]))return e.error(`Expected first argument to be of type array or string, but found ${ee(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Vt);return i?new or(r.type,r,n,i):null}return new or(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!ae(e,["string","array"]))throw new Ge(`Expected first argument to be of type array or string, but found ${ee(Ve(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function sr(t,e){const r=t.length-1;let n,i,a=0,o=r,s=0;for(;a<=o;)if(s=Math.floor((a+o)/2),n=t[s],i=t[s+1],n<=e){if(s===r||ee))throw new Ge("Input is not a number.");o=s-1}return 0}class lr{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,Vt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(o,l,i);if(!c)return null;i=i||c.type,n.push([a,c])}return new lr(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[sr(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 cr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ur=hr;function hr(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}hr.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:s=r,r=.5*(s-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var fr=cr(ur);function pr(t){return"rgb"===t||"hcl"===t||"lab"===t}function dr(t,e,r){return t+r*(e-t)}function mr(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,a,o]=gr(t.rgb,e.rgb,r);return new Pe(n,i,a,o,!1)}case"hcl":{const[n,i,a,o]=t.hcl,[s,l,c,u]=e.hcl;let h,f;if(isNaN(n)||isNaN(s))isNaN(n)?isNaN(s)?h=NaN:(h=s,1!==a&&0!==a||(f=l)):(h=n,1!==c&&0!==c||(f=i));else{let t=s-n;s>n&&t>180?t-=360:s180&&(t+=360),h=n+r*t}const[p,d,m,g]=ke([h,null!=f?f:dr(i,l,r),dr(a,c,r),dr(o,u,r)]);return new Pe(p,d,m,g,!1)}case"lab":{const[n,i,a,o]=_e(gr(t.lab,e.lab,r));return new Pe(n,i,a,o,!1)}}}function gr(t,e,r){return t.map(((t,n)=>dr(t,e[n],r)))}function yr(t,e,r){return new Re(gr(t.values,e.values,r))}function vr(t,e,r){const n=t.values,i=e.values;if(n.length!==i.length)throw new Ge(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const a=[];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,Vt),!i)return null;const o=[];let s=null;"interpolate-hcl"===r||"interpolate-lab"===r?s=Gt:e.expectedType&&"value"!==e.expectedType.kind&&(s=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 c=e.parse(n,l,s);if(!c)return null;s=s||c.type,o.push([r,c])}return oe(s,Vt)||oe(s,Gt)||oe(s,Jt)||oe(s,Qt)||oe(s,te(Vt))?new _r(s,r,n,i,o):e.error(`Type ${ee(s)} 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 a=sr(e,n),o=e[a],s=e[a+1],l=_r.interpolationFactor(this.interpolation,n,o,s),c=r[a].evaluate(t),u=r[a+1].evaluate(t);switch(this.operator){case"interpolate":return xr[this.type.kind](c,u,l);case"interpolate-hcl":return xr.color(c,u,l,"hcl");case"interpolate-lab":return xr.color(c,u,l,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function br(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}class wr{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 a=n&&i.some((t=>ne(n,t.type)));return new wr(a?Zt: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 Ne&&!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 Tr(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 kr(t,e,r){return e===r}function Ar(t,e,r){return e!==r}function Mr(t,e,r){return er}function Er(t,e,r){return e<=r}function Cr(t,e,r){return e>=r}function Lr(t,e,r,n){return 0===n.compare(e,r)}function Ir(t,e,r,n){return!Lr(t,e,r,n)}function Pr(t,e,r,n){return n.compare(e,r)<0}function zr(t,e,r,n){return n.compare(e,r)>0}function Dr(t,e,r,n){return n.compare(e,r)<=0}function Or(t,e,r,n){return n.compare(e,r)>=0}function Rr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Ht,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 a=e.parse(t[1],1,Zt);if(!a)return null;if(!Tr(r,a.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${ee(a.type)}'.`);let o=e.parse(t[2],2,Zt);if(!o)return null;if(!Tr(r,o.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${ee(o.type)}'.`);if(a.type.kind!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${ee(a.type)}' and '${ee(o.type)}'.`);n&&("value"===a.type.kind&&"value"!==o.type.kind?a=new Ze(o.type,[a]):"value"!==a.type.kind&&"value"===o.type.kind&&(o=new Ze(a.type,[o])));let s=null;if(4===t.length){if("string"!==a.type.kind&&"string"!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(s=e.parse(t[3],3,Xt),!s)return null}return new i(a,o,s)}evaluate(i){const a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Ve(a),r=Ve(o);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ge(`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=Ve(a),r=Ve(o);if("string"!==t.kind||"string"!==r.kind)return e(i,a,o)}return this.collator?r(i,a,o,this.collator.evaluate(i)):e(i,a,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Fr=Rr("==",kr,Lr),Br=Rr("!=",Ar,Ir),Nr=Rr("<",Mr,Pr),jr=Rr(">",Sr,zr),Ur=Rr("<=",Er,Dr),Vr=Rr(">=",Cr,Or);class qr{constructor(t,e,r){this.type=Xt,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,Ht);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Ht);if(!i)return null;let a=null;return r.locale&&(a=e.parse(r.locale,1,qt),!a)?null:new qr(n,i,a)}evaluate(t){return new ze(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 Hr{constructor(t,e,r,n,i){this.type=qt,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,Vt);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,qt),!i))return null;let a=null;if(n.currency&&(a=e.parse(n.currency,1,qt),!a))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parse(n["min-fraction-digits"],1,Vt),!o))return null;let s=null;return n["max-fraction-digits"]&&(s=e.parse(n["max-fraction-digits"],1,Vt),!s)?null:new Hr(r,i,a,o,s)}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 Gr{constructor(t){this.type=$t,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 a=t[r];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;let t=null;if(a["font-scale"]&&(t=e.parse(a["font-scale"],1,Vt),!t))return null;let r=null;if(a["text-font"]&&(r=e.parse(a["text-font"],1,te(qt)),!r))return null;let o=null;if(a["text-color"]&&(o=e.parse(a["text-color"],1,Gt),!o))return null;const s=n[n.length-1];s.scale=t,s.font=r,s.textColor=o}else{const a=e.parse(t[r],1,Zt);if(!a)return null;const o=a.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:a,scale:null,font:null,textColor:null})}}return new Gr(n)}evaluate(t){const e=e=>{const r=e.content.evaluate(t);return Ve(r)===Kt?new De("",r,null,null,null):new De(qe(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)};return new Oe(this.sections.map(e))}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 Wr{constructor(t){this.type=Kt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,qt);return r?new Wr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=Ne.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}}class Zr{constructor(t){this.type=Vt,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 ${ee(r.type)} instead.`):new Zr(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 Ge(`Expected value to be of type string or array, but found ${ee(Ve(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Yr=8192;function Xr(t,e){const r=Jr(t[0]),n=Qr(t[1]),i=Math.pow(2,e.z);return[Math.round(r*i*Yr),Math.round(n*i*Yr)]}function $r(t,e){const r=Math.pow(2,e.z),n=(t[0]/Yr+e.x)/r,i=(t[1]/Yr+e.y)/r;return[Kr(n),tn(i)]}function Jr(t){return(180+t)/360}function Kr(t){return 360*t-180}function Qr(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function tn(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function en(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 rn(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function nn(t,e,r){return e[1]>t[1]!=r[1]>t[1]&&t[0]<(r[0]-e[0])*(t[1]-e[1])/(r[1]-e[1])+e[0]}function an(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],a=t[0]-r[0],o=t[1]-r[1];return n*o-a*i==0&&n*a<=0&&i*o<=0}function on(t,e,r,n){const i=[e[0]-t[0],e[1]-t[1]];return 0!==fn([n[0]-r[0],n[1]-r[1]],i)&&!(!pn(t,e,r,n)||!pn(r,n,t,e))}function sn(t,e,r){for(const n of r)for(let r=0;r0&&h<0||u<0&&h>0}function dn(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}en(e,t)}function yn(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}function vn(t,e,r,n){const i=Math.pow(2,n.z)*Yr,a=[n.x*Yr,n.y*Yr],o=[];for(const n of t)for(const t of n){const n=[t.x+a[0],t.y+a[1]];gn(n,e,r,i),o.push(n)}return o}function xn(t,e,r,n){const i=Math.pow(2,n.z)*Yr,a=[n.x*Yr,n.y*Yr],o=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+a[0],n.y+a[1]];en(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=i/2){yn(e);for(const t of o)for(const n of t)gn(n,e,r,i)}return o}function _n(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 a=dn(e.coordinates,n,i),o=vn(t.geometry(),r,n,i);if(!rn(r,n))return!1;for(const t of o)if(!ln(t,a))return!1}if("MultiPolygon"===e.type){const a=mn(e.coordinates,n,i),o=vn(t.geometry(),r,n,i);if(!rn(r,n))return!1;for(const t of o)if(!cn(t,a))return!1}return!0}function bn(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 a=dn(e.coordinates,n,i),o=xn(t.geometry(),r,n,i);if(!rn(r,n))return!1;for(const t of o)if(!un(t,a))return!1}if("MultiPolygon"===e.type){const a=mn(e.coordinates,n,i),o=xn(t.geometry(),r,n,i);if(!rn(r,n))return!1;for(const t of o)if(!hn(t,a))return!1}return!0}class wn{constructor(t,e){this.type=Ht,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(Ue(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 wn(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new wn(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new wn(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 _n(t,this.geometries);if("LineString"===t.geometryType())return bn(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Tn=class{constructor(t=[],e=kn){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.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,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,a=e[i];if(r(n,a)>=0)break;e[t]=a,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]=a,t=n}e[t]=i}};function kn(t,e){return te?1:0}function An(t,e,r,n,i){Mn(t,e,r,n||t.length-1,i||En)}function Mn(t,e,r,n,i){for(;n>r;){if(n-r>600){var a=n-r+1,o=e-r+1,s=Math.log(a),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);Mn(t,e,Math.max(r,Math.floor(e-o*l/a+c)),Math.min(n,Math.floor(e+(a-o)*l/a+c)),i)}var u=t[e],h=r,f=n;for(Sn(t,r,e),i(t[n],u)>0&&Sn(t,r,n);h0;)f--}0===i(t[r],u)?Sn(t,r,f):Sn(t,++f,n),f<=e&&(r=f+1),e<=f&&(n=f-1)}}function Sn(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function En(t,e){return te?1:0}function Cn(t,e){if(t.length<=1)return[t];const r=[];let n,i;for(const e of t){const t=In(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[s+1][0],c=t[s+1][1]):f>0&&(l+=u/this.kx*f,c+=h/this.ky*f)),u=this.wrap(e[0]-l)*this.kx,h=(e[1]-c)*this.ky;const p=u*u+h*h;p180;)t-=360;return t}}const Fn=100,Bn=50;function Nn(t,e){return e[0]-t[0]}function jn(t){return t[1]-t[0]+1}function Un(t,e){return t[1]>=t[0]&&t[1]t[1])return[null,null];const r=jn(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 qn(t,e){if(!Un(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)en(r,t[n]);return r}function Hn(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)en(e,t);return e}function Gn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Wn(t,e,r){if(!Gn(t)||!Gn(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(rn(i,a)){if(Qn(t,e))return 0}else if(Qn(e,t))return 0;let o=1/0;for(const n of t)for(let t=0,i=n.length,a=i-1;t0;){const i=o.pop();if(i[0]>=a)continue;const l=i[1],c=e?Bn:Fn;if(jn(l)<=c){if(!Un(l,t.length))return NaN;if(e){const e=Kn(t,l,r,n);if(isNaN(e)||0===e)return e;a=Math.min(a,e)}else for(let e=l[0];e<=l[1];++e){const i=Jn(t[e],r,n);if(a=Math.min(a,i),0===a)return 0}}else{const r=Vn(l,e);ei(o,a,n,t,s,r[0]),ei(o,a,n,t,s,r[1])}}return a}function ii(t,e,r,n,i,a=1/0){let o=Math.min(a,i.distance(t[0],r[0]));if(0===o)return o;const s=new Tn([[0,[0,t.length-1],[0,r.length-1]]],Nn);for(;s.length>0;){const a=s.pop();if(a[0]>=o)continue;const l=a[1],c=a[2],u=e?Bn:Fn,h=n?Bn:Fn;if(jn(l)<=u&&jn(c)<=h){if(!Un(l,t.length)&&Un(c,r.length))return NaN;let a;if(e&&n)a=Xn(t,l,r,c,i),o=Math.min(o,a);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(a=Zn(r[t],e,i),o=Math.min(o,a),0===o)return o}else if(!e&&n){const e=r.slice(c[0],c[1]+1);for(let r=l[0];r<=l[1];++r)if(a=Zn(t[r],e,i),o=Math.min(o,a),0===o)return o}else a=$n(t,l,r,c,i),o=Math.min(o,a)}else{const a=Vn(l,e),u=Vn(c,n);ri(s,o,i,t,r,a[0],u[0]),ri(s,o,i,t,r,a[0],u[1]),ri(s,o,i,t,r,a[1],u[0]),ri(s,o,i,t,r,a[1],u[1])}}return o}function ai(t,e){const r=t.geometry(),n=r.flat().map((e=>$r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Rn(n[0][1]);let a=1/0;for(const t of e){switch(t.type){case"Point":a=Math.min(a,ii(n,!1,[t.coordinates],!1,i,a));break;case"LineString":a=Math.min(a,ii(n,!1,t.coordinates,!0,i,a));break;case"Polygon":a=Math.min(a,ni(n,!1,t.coordinates,i,a))}if(0===a)return a}return a}function oi(t,e){const r=t.geometry(),n=r.flat().map((e=>$r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Rn(n[0][1]);let a=1/0;for(const t of e){switch(t.type){case"Point":a=Math.min(a,ii(n,!0,[t.coordinates],!1,i,a));break;case"LineString":a=Math.min(a,ii(n,!0,t.coordinates,!0,i,a));break;case"Polygon":a=Math.min(a,ni(n,!0,t.coordinates,i,a))}if(0===a)return a}return a}function si(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Cn(r,0).map((e=>e.map((e=>e.map((e=>$r([e.x,e.y],t.canonical))))))),i=new Rn(n[0][0][0][1]);let a=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":a=Math.min(a,ni([t.coordinates],!1,e,i,a));break;case"LineString":a=Math.min(a,ni(t.coordinates,!0,e,i,a));break;case"Polygon":a=Math.min(a,ti(e,t.coordinates,i,a))}if(0===a)return a}return a}function li(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 ci{constructor(t,e){this.type=Vt,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(Ue(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new ci(e,e.features.map((t=>li(t.geometry))).flat());if("Feature"===e.type)return new ci(e,li(e.geometry));if("type"in e&&"coordinates"in e)return new ci(e,li(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 ai(t,this.geometries);if("LineString"===t.geometryType())return oi(t,this.geometries);if("Polygon"===t.geometryType())return si(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const ui={"==":Fr,"!=":Br,">":jr,"<":Nr,">=":Vr,"<=":Ur,array:Ze,at:er,boolean:Ze,case:ar,coalesce:wr,collator:qr,format:Gr,image:Wr,in:rr,"index-of":nr,interpolate:_r,"interpolate-hcl":_r,"interpolate-lab":_r,length:Zr,let:Qe,literal:He,match:ir,number:Ze,"number-format":Hr,object:Ze,slice:or,step:lr,string:Ze,"to-boolean":Xe,"to-color":Xe,"to-number":Xe,"to-string":Xe,var:tr,within:wn,distance:ci};class hi{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=hi.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,a=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=a.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let s=null;for(const[n,a]of o){s=new Ke(e.registry,vi,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;eyi(t))).join(" | "),n=[];for(let r=1;r>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}function gi(t){return{type:t}}function yi(t){return Array.isArray(t)?`(${t.map(ee).join(", ")})`:`(${ee(t.type)}...)`}function vi(t){if(t instanceof tr)return vi(t.boundExpression);if(t instanceof hi&&"error"===t.name)return!1;if(t instanceof qr)return!1;if(t instanceof wn)return!1;if(t instanceof ci)return!1;const e=t instanceof Xe||t instanceof Ze;let r=!0;return t.eachChild((t=>{r=e?r&&vi(t):r&&t instanceof He})),!!r&&xi(t)&&bi(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function xi(t){if(t instanceof hi){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 wn)return!1;if(t instanceof ci)return!1;let e=!0;return t.eachChild((t=>{e&&!xi(t)&&(e=!1)})),e}function _i(t){if(t instanceof hi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!_i(t)&&(e=!1)})),e}function bi(t,e){if(t instanceof hi&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!bi(t,e)&&(r=!1)})),r}function wi(t){return{result:"success",value:t}}function Ti(t){return{result:"error",value:t}}function ki(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Ai(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Mi(t){return!!t.expression&&t.expression.interpolated}function Si(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Ei(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ci(t){return t}function Li(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||void 0!==t.property,a=n||!i,o=t.type||(Mi(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?Pe.parse:Re.parse;(t=Bt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default?t.default=n(t.default):t.default=n(e.default)}if(t.colorSpace&&!pr(t.colorSpace))throw new Error(`Unknown color space: "${t.colorSpace}"`);let s,l,c;if("exponential"===o)s=Di;else if("interval"===o)s=zi;else if("categorical"===o){s=Pi,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Oi}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Di({stops:i,base:t.base},e,r).evaluate(r,n)}}if(a){const r="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:_r.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>s(t,e,r,l,c)}}return{kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Ii(t.default,e.default):s(t,e,i,l,c)}}}function Ii(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Pi(t,e,r,n,i){return Ii(typeof r===i?n[r]:void 0,t.default,e.default)}function zi(t,e,r){if("number"!==Si(r))return Ii(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=sr(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Di(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Si(r))return Ii(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 a=sr(t.stops.map((t=>t[0])),r),o=Ri(r,n,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],c=xr[e.type]||Ci;return"function"==typeof s.evaluate?{evaluate(...e){const r=s.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return c(r,n,o,t.colorSpace)}}:c(s,l,o,t.colorSpace)}function Oi(t,e,r){switch(e.type){case"color":r=Pe.parse(r);break;case"formatted":r=Oe.fromString(r.toString());break;case"resolvedImage":r=Ne.fromString(r.toString());break;case"padding":r=Re.parse(r);break;default:Si(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0)}return Ii(r,t.default,e.default)}function Ri(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}hi.register(ui,{error:[Yt,[qt],(t,[e])=>{throw new Ge(e.evaluate(t))}],typeof:[qt,[Zt],(t,[e])=>ee(Ve(e.evaluate(t)))],"to-rgba":[te(Vt,4),[Gt],(t,[e])=>{const[r,n,i,a]=e.evaluate(t).rgb;return[255*r,255*n,255*i,a]}],rgb:[Gt,[Vt,Vt,Vt],fi],rgba:[Gt,[Vt,Vt,Vt,Vt],fi],has:{type:Ht,overloads:[[[qt],(t,[e])=>pi(e.evaluate(t),t.properties())],[[qt,Wt],(t,[e,r])=>pi(e.evaluate(t),r.evaluate(t))]]},get:{type:Zt,overloads:[[[qt],(t,[e])=>di(e.evaluate(t),t.properties())],[[qt,Wt],(t,[e,r])=>di(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Zt,[qt],(t,[e])=>di(e.evaluate(t),t.featureState||{})],properties:[Wt,[],t=>t.properties()],"geometry-type":[qt,[],t=>t.geometryType()],id:[Zt,[],t=>t.id()],zoom:[Vt,[],t=>t.globals.zoom],"heatmap-density":[Vt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Vt,[],t=>t.globals.lineProgress||0],accumulated:[Zt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Vt,gi(Vt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Vt,gi(Vt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Vt,overloads:[[[Vt,Vt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Vt],(t,[e])=>-e.evaluate(t)]]},"/":[Vt,[Vt,Vt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Vt,[Vt,Vt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Vt,[],()=>Math.LN2],pi:[Vt,[],()=>Math.PI],e:[Vt,[],()=>Math.E],"^":[Vt,[Vt,Vt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Vt,[Vt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Vt,[Vt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Vt,[Vt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Vt,[Vt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Vt,[Vt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Vt,[Vt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Vt,[Vt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Vt,[Vt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Vt,[Vt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Vt,[Vt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Vt,gi(Vt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Vt,gi(Vt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Vt,[Vt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Vt,[Vt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Vt,[Vt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Vt,[Vt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ht,[qt,Zt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Ht,[Zt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ht,[qt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Ht,[qt,Zt],(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":[Ht,[qt,Zt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Ht,[Zt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Ht,[qt,Zt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Ht,[Zt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Ht,[qt,Zt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Ht,[Zt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Ht,[Zt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ht,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ht,[te(qt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Ht,[te(Zt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ht,[qt,te(Zt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ht,[qt,te(Zt)],(t,[e,r])=>mi(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ht,overloads:[[[Ht,Ht],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[gi(Ht),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:Ht,overloads:[[[Ht,Ht],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[gi(Ht),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[Ht,[Ht],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ht,[qt],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[qt,[qt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[qt,[qt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[qt,gi(Zt),(t,e)=>e.map((e=>qe(e.evaluate(t)))).join("")],"resolved-locale":[qt,[Xt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Fi{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Je,this._defaultValue=e?Yi(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,r,n,i,a){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=a,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,a){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=a||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 Ge(`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 Bi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in ui}function Ni(t,e){const r=new Ke(ui,vi,[],e?Zi(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?wi(new Fi(n,e)):Ti(r.errors)}class ji{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!_i(e.expression)}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}}class Ui{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!_i(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}interpolationFactor(t,e,r){return this.interpolationType?_r.interpolationFactor(this.interpolationType,t,e,r):0}}function Vi(t){return void 0!==t._styleExpression}function qi(t,e){const r=Ni(t,e);if("error"===r.result)return r;const n=r.value.expression,i=xi(n);if(!i&&!ki(e))return Ti([new Nt("","data expressions not supported")]);const a=bi(n,["zoom"]);if(!a&&!Ai(e))return Ti([new Nt("","zoom expressions not supported")]);const o=Wi(n);if(!o&&!a)return Ti([new Nt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(o instanceof Nt)return Ti([o]);if(o instanceof _r&&!Mi(e))return Ti([new Nt("",'"interpolate" expressions cannot be used with this property')]);if(!o)return wi(new ji(i?"constant":"source",r.value));const s=o instanceof _r?o.interpolation:void 0;return wi(new Ui(i?"camera":"composite",r.value,o.labels,s))}class Hi{constructor(t,e){this._parameters=t,this._specification=e,Bt(this,Li(this._parameters,this._specification))}static deserialize(t){return new Hi(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Gi(t,e){if(Ei(t))return new Hi(t,e);if(Bi(t)){const r=qi(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=Pe.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(r=Be.parse(t)):r=Re.parse(t),{kind:"constant",evaluate:()=>r}}}function Wi(t){let e=null;if(t instanceof Qe)e=Wi(t.result);else if(t instanceof wr){for(const r of t.args)if(e=Wi(r),e)break}else(t instanceof lr||t instanceof _r)&&t.input instanceof hi&&"zoom"===t.input.name&&(e=t);return e instanceof Nt||t.eachChild((t=>{const r=Wi(t);r instanceof Nt?e=r:!e&&r?e=new Nt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new Nt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Zi(t){const e={color:Gt,string:qt,number:Vt,enum:qt,boolean:Ht,formatted:$t,padding:Jt,resolvedImage:Kt,variableAnchorOffsetCollection:Qt};return"array"===t.type?te(e[t.value]||Zt,t.length):e[t.type]}function Yi(t){return"color"===t.type&&Ei(t.default)?new Pe(0,0,0,0):"color"===t.type?Pe.parse(t.default)||null:"padding"===t.type?Re.parse(t.default)||null:"variableAnchorOffsetCollection"===t.type?Be.parse(t.default)||null:void 0===t.default?null:t.default}function Xi(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(!Xi(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const $i={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ji(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Xi(t)||(t=ta(t));const e=Ni(t,$i);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:Qi(t)}}function Ki(t,e){return te?1:0}function Qi(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?ea(t[1],t[2],e):"any"===e?ra(t.slice(1)):"all"===e?["all"].concat(t.slice(1).map(ta)):"none"===e?["all"].concat(t.slice(1).map(ta).map(aa)):"in"===e?na(t[1],t.slice(2)):"!in"===e?aa(na(t[1],t.slice(2))):"has"===e?ia(t[1]):"!has"!==e||aa(ia(t[1]))}function ea(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 ra(t){return["any"].concat(t.map(ta))}function na(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(Ki)]]:["filter-in-small",t,["literal",e]]}}function ia(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function aa(t){return["!",t]}function oa(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+=`${oa(r)},`;return`${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Ft(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function ga(t){const e=t.valueSpec,r=ha(t.value.type);let n,i,a,o={};const s="categorical"!==r&&void 0===t.value.property,l=!s,c="array"===Si(t.value.stops)&&"array"===Si(t.value.stops[0])&&"object"===Si(t.value.stops[0][0]),u=pa({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:h,default:d}});return"identity"===r&&s&&u.push(new Ft(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||u.push(new Ft(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Mi(t.valueSpec)&&u.push(new Ft(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!ki(t.valueSpec)?u.push(new Ft(t.key,t.value,"property functions not supported")):s&&!Ai(t.valueSpec)&&u.push(new Ft(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!c||void 0!==t.value.property||u.push(new Ft(t.key,t.value,'"property" property is required')),u;function h(t){if("identity"===r)return[new Ft(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(da({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===Si(n)&&0===n.length&&e.push(new Ft(t.key,n,"array must have at least one stop")),e}function f(t){let r=[];const n=t.value,s=t.key;if("array"!==Si(n))return[new Ft(s,n,`array expected, ${Si(n)} found`)];if(2!==n.length)return[new Ft(s,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Si(n[0]))return[new Ft(s,n,`object expected, ${Si(n[0])} found`)];if(void 0===n[0].zoom)return[new Ft(s,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Ft(s,n,"object stop key must have value")];if(a&&a>ha(n[0].zoom))return[new Ft(s,n[0].zoom,"stop zoom values must appear in ascending order")];ha(n[0].zoom)!==a&&(a=ha(n[0].zoom),i=void 0,o={}),r=r.concat(pa({key:`${s}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:ma,value:p}}))}else r=r.concat(p({key:`${s}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return Bi(fa(n[1]))?r.concat([new Ft(`${s}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${s}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,a){const s=Si(t.value),l=ha(t.value),c=null!==t.value?t.value:a;if(n){if(s!==n)return[new Ft(t.key,c,`${s} stop domain type must match previous stop domain type ${n}`)]}else n=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new Ft(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==r){let n=`number expected, ${s} found`;return ki(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ft(t.key,c,n)]}return"categorical"!==r||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===s&&void 0!==i&&lnew Ft(`${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 Ft(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&&!_i(r))return[new Ft(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!_i(r))return[new Ft(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!bi(r,["zoom","feature-state"]))return[new Ft(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!xi(r))return[new Ft(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function va(t){const e=t.value,r=t.key,n=Si(e);return"boolean"!==n?[new Ft(r,e,`boolean expected, ${n} found`)]:[]}function xa(t){const e=t.key,r=t.value,n=Si(r);return"string"!==n?[new Ft(e,r,`color expected, ${n} found`)]:Pe.parse(String(r))?[]:[new Ft(e,r,`color expected, "${r}" found`)]}function _a(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(ha(r))&&i.push(new Ft(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(ha(r))&&i.push(new Ft(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function ba(t){return Xi(fa(t.value))?ya(Bt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):wa(t)}function wa(t){const e=t.value,r=t.key;if("array"!==Si(e))return[new Ft(r,e,`array expected, ${Si(e)} found`)];const n=t.styleSpec;let i,a=[];if(e.length<1)return[new Ft(r,e,"filter array must have at least 1 element")];switch(a=a.concat(_a({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),ha(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===ha(e[1])&&a.push(new Ft(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&a.push(new Ft(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Si(e[1]),"string"!==i&&a.push(new Ft(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let o=2;o{t in r&&e.push(new Ft(n,r[t],`"${t}" is prohibited for ref layers`))})),i.layers.forEach((e=>{ha(e.id)===s&&(t=e)})),t?t.ref?e.push(new Ft(n,r.ref,"ref cannot reference another ref layer")):o=ha(t.type):e.push(new Ft(n,r.ref,`ref layer "${s}" not found`))}else if("background"!==o)if(r.source){const t=i.sources&&i.sources[r.source],a=t&&ha(t.type);t?"vector"===a&&"raster"===o?e.push(new Ft(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==a&&"hillshade"===o?e.push(new Ft(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===a&&"raster"!==o?e.push(new Ft(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==a||r["source-layer"]?"raster-dem"===a&&"hillshade"!==o?e.push(new Ft(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==o||!r.paint||!r.paint["line-gradient"]||"geojson"===a&&t.lineMetrics||e.push(new Ft(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ft(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ft(n,r.source,`source "${r.source}" not found`))}else e.push(new Ft(n,r,'missing required property "source"'));return e=e.concat(pa({key:n,value:r,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:ba,layout:t=>pa({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Aa(Bt({layerType:o},t))}}),paint:t=>pa({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>ka(Bt({layerType:o},t))}})}})),e}function Sa(t){const e=t.value,r=t.key,n=Si(e);return"string"!==n?[new Ft(r,e,`string expected, ${n} found`)]:[]}function Ea(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,a=i.source_raster_dem,o=t.style;let s=[];const l=Si(n);if(void 0===n)return s;if("object"!==l)return s.push(new Ft("source_raster_dem",n,`object expected, ${l} found`)),s;const c="custom"===ha(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!c&&u.includes(e)?s.push(new Ft(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[e]?s=s.concat(t.validateSpec({key:e,value:n[e],valueSpec:a[e],validateSpec:t.validateSpec,style:o,styleSpec:i})):s.push(new Ft(e,n[e],`unknown property "${e}"`));return s}const Ca={promoteId:Ia};function La(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,a=t.validateSpec;if(!e.type)return[new Ft(r,e,'"type" is required')];const o=ha(e.type);let s;switch(o){case"vector":case"raster":return s=pa({key:r,value:e,valueSpec:n[`source_${o.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Ca,validateSpec:a}),s;case"raster-dem":return s=Ea({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:a}),s;case"geojson":if(s=pa({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:a,objectElementValidators:Ca}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],o="string"==typeof n?[n,["accumulated"],["get",t]]:n;s.push(...ya({key:`${r}.${t}.map`,value:i,validateSpec:a,expressionContext:"cluster-map"})),s.push(...ya({key:`${r}.${t}.reduce`,value:o,validateSpec:a,expressionContext:"cluster-reduce"}))}return s;case"video":return pa({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:a,styleSpec:n});case"image":return pa({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:a,styleSpec:n});case"canvas":return[new Ft(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return _a({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:a,styleSpec:n})}}function Ia({key:t,value:e}){if("string"===Si(e))return Sa({key:t,value:e});{const r=[];for(const n in e)r.push(...Sa({key:`${t}.${n}`,value:e[n]}));return r}}function Pa(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let a=[];const o=Si(e);if(void 0===e)return a;if("object"!==o)return a=a.concat([new Ft("light",e,`object expected, ${o} found`)]),a;for(const o in e){const s=o.match(/^(.*)-transition$/);a=s&&n[s[1]]&&n[s[1]].transition?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r})):n[o]?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:i,styleSpec:r})):a.concat([new Ft(o,e[o],`unknown property "${o}"`)])}return a}function za(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,a=Si(e);if(void 0===e)return[];if("object"!==a)return[new Ft("sky",e,`object expected, ${a} found`)];let o=[];for(const a in e)o=n[a]?o.concat(t.validateSpec({key:a,value:e[a],valueSpec:n[a],style:i,styleSpec:r})):o.concat([new Ft(a,e[a],`unknown property "${a}"`)]);return o}function Da(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let a=[];const o=Si(e);if(void 0===e)return a;if("object"!==o)return a=a.concat([new Ft("terrain",e,`object expected, ${o} found`)]),a;for(const o in e)a=n[o]?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:i,styleSpec:r})):a.concat([new Ft(o,e[o],`unknown property "${o}"`)]);return a}function Oa(t){return 0===Sa(t).length?[]:ya(t)}function Ra(t){return 0===Sa(t).length?[]:ya(t)}function Fa(t){const e=t.key,r=t.value;if("array"===Si(r)){if(r.length<1||r.length>4)return[new Ft(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let a=0;a[],array:da,boolean:va,number:ma,color:xa,constants:ua,enum:_a,filter:ba,function:ga,layer:Ma,object:pa,source:La,light:Pa,sky:za,terrain:Da,projection:ja,string:Sa,formatted:Oa,resolvedImage:Ra,padding:Fa,variableAnchorOffsetCollection:Ba,sprite:Na};function Va(t){const e=t.value,r=t.valueSpec,n=t.styleSpec;return t.validateSpec=Va,r.expression&&Ei(ha(e))?ga(t):r.expression&&Bi(fa(e))?ya(t):r.type&&Ua[r.type]?Ua[r.type](t):pa(Bt({},t,{valueSpec:r.type?n[r.type]:r}))}function qa(t){const e=t.value,r=t.key,n=Sa(t);return n.length||(-1===e.indexOf("{fontstack}")&&n.push(new Ft(r,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&n.push(new Ft(r,e,'"glyphs" url must include a "{range}" token'))),n}function Ha(t,e=bt){let r=[];return r=r.concat(Va({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Va,objectElementValidators:{glyphs:qa,"*":()=>[]}})),t.constants&&(r=r.concat(ua({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Va}))),Wa(r)}function Ga(t){return function(e){return t({...e,validateSpec:Va})}}function Wa(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Za(t){return function(...e){return Wa(t.apply(this,e))}}Ha.source=Za(Ga(La)),Ha.sprite=Za(Ga(Na)),Ha.glyphs=Za(Ga(qa)),Ha.light=Za(Ga(Pa)),Ha.sky=Za(Ga(za)),Ha.terrain=Za(Ga(Da)),Ha.layer=Za(Ga(Ma)),Ha.filter=Za(Ga(ba)),Ha.paintProperty=Za(Ga(ka)),Ha.layoutProperty=Za(Ga(Aa));const Ya=Ha;Ya.source;const Xa=Ya.light,$a=Ya.sky;Ya.terrain,Ya.filter;const Ja=Ya.paintProperty,Ka=Ya.layoutProperty;function Qa(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new xt(new Error(n.message))),r=!0;return r}const to=3;class eo{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],e=i[1],r=i[2],this.d=e+2*r;for(let t=0;t=c[l+0]&&n>=c[l+1])?(o[h]=!0,a.push(i[h])):o[h]=!1}}}}_forEachCell(t,e,r,n,i,a,o,s){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let f=l;f<=u;f++)for(let l=c;l<=h;l++){const c=this.d*l+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(l),this._convertFromCellCoord(f+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,c,a,o,s))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=to+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const a=t[n];i[n]=ro[r].shallow.indexOf(n)>=0?a:lo(a,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 co(t){if(so(t))return t;if(Array.isArray(t))return t.map(co);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=ao(t)||"Object";if(!ro[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=ro[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]=ro[e].shallow.indexOf(r)>=0?i:co(i)}return n}class uo{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,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"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,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function fo(t){for(const e of t)if(yo(e.charCodeAt(0)))return!0;return!1}function po(t){for(const e of t)if(!mo(e.charCodeAt(0)))return!1;return!0}function mo(t){return!(ho.Arabic(t)||ho["Arabic Supplement"](t)||ho["Arabic Extended-A"](t)||ho["Arabic Presentation Forms-A"](t)||ho["Arabic Presentation Forms-B"](t))}function go(t){return!(t<11904||!(ho["Bopomofo Extended"](t)||ho.Bopomofo(t)||ho["CJK Compatibility Forms"](t)||ho["CJK Compatibility Ideographs"](t)||ho["CJK Compatibility"](t)||ho["CJK Radicals Supplement"](t)||ho["CJK Strokes"](t)||ho["CJK Symbols and Punctuation"](t)||ho["CJK Unified Ideographs Extension A"](t)||ho["CJK Unified Ideographs"](t)||ho["Enclosed CJK Letters and Months"](t)||ho["Halfwidth and Fullwidth Forms"](t)||ho.Hiragana(t)||ho["Ideographic Description Characters"](t)||ho["Kangxi Radicals"](t)||ho["Katakana Phonetic Extensions"](t)||ho.Katakana(t)||ho["Vertical Forms"](t)||ho["Yi Radicals"](t)||ho["Yi Syllables"](t)))}function yo(t){return!(746!==t&&747!==t&&(t<4352||!(ho["Bopomofo Extended"](t)||ho.Bopomofo(t)||ho["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||ho["CJK Compatibility Ideographs"](t)||ho["CJK Compatibility"](t)||ho["CJK Radicals Supplement"](t)||ho["CJK Strokes"](t)||!(!ho["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||ho["CJK Unified Ideographs Extension A"](t)||ho["CJK Unified Ideographs"](t)||ho["Enclosed CJK Letters and Months"](t)||ho["Hangul Compatibility Jamo"](t)||ho["Hangul Jamo Extended-A"](t)||ho["Hangul Jamo Extended-B"](t)||ho["Hangul Jamo"](t)||ho["Hangul Syllables"](t)||ho.Hiragana(t)||ho["Ideographic Description Characters"](t)||ho.Kanbun(t)||ho["Kangxi Radicals"](t)||ho["Katakana Phonetic Extensions"](t)||ho.Katakana(t)&&12540!==t||!(!ho["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)||!(!ho["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||ho["Unified Canadian Aboriginal Syllabics"](t)||ho["Unified Canadian Aboriginal Syllabics Extended"](t)||ho["Vertical Forms"](t)||ho["Yijing Hexagram Symbols"](t)||ho["Yi Syllables"](t)||ho["Yi Radicals"](t))))}function vo(t){return!!(ho["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||ho["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)||ho["Letterlike Symbols"](t)||ho["Number Forms"](t)||ho["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)||ho["Control Pictures"](t)&&9251!==t||ho["Optical Character Recognition"](t)||ho["Enclosed Alphanumerics"](t)||ho["Geometric Shapes"](t)||ho["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||ho["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ho["CJK Symbols and Punctuation"](t)||ho.Katakana(t)||ho["Private Use Area"](t)||ho["CJK Compatibility Forms"](t)||ho["Small Form Variants"](t)||ho["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}function xo(t){return!(yo(t)||vo(t))}function _o(t){return ho.Arabic(t)||ho["Arabic Supplement"](t)||ho["Arabic Extended-A"](t)||ho["Arabic Presentation Forms-A"](t)||ho["Arabic Presentation Forms-B"](t)}function bo(t){return t>=1424&&t<=2303||ho["Arabic Presentation Forms-A"](t)||ho["Arabic Presentation Forms-B"](t)}function wo(t,e){return!(!e&&bo(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||ho.Khmer(t))}function To(t){for(const e of t)if(bo(e.charCodeAt(0)))return!0;return!1}function ko(t,e){for(const r of t)if(!wo(r.charCodeAt(0),e))return!1;return!0}class Ao{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}}const Mo=new Ao;class So{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 uo,this.transition={})}isSupportedScript(t){return ko(t,"loaded"===Mo.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 Eo{constructor(t,e){this.property=t,this.value=e,this.expression=Gi(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 Co{constructor(t){this.property=t,this.value=new Eo(t,void 0)}transitioned(t,e){return new Io(this.property,this.value,e,_({},t.transition,this.transition),t.now)}untransitioned(){return new Io(this.property,this.value,null,{},0)}}class Lo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return C(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Co(this._values[t].property)),this._values[t].value=new Eo(this._values[t].property,null===e?void 0:C(e))}getTransition(t){return C(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Co(this._values[t].property)),this._values[t].transition=C(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 Po(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 Po(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Io{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),a=this.prior;if(a){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class No{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 So(Math.floor(e.zoom-1),e)),t.expression.evaluate(new So(Math.floor(e.zoom),e)),t.expression.evaluate(new So(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 jo{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){return!!t.expression.evaluate(e,null,{},r,n)}interpolate(){return!1}}class Uo{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 Eo(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Co(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}}}no("DataDrivenProperty",Fo),no("DataConstantProperty",Ro),no("CrossFadedDataDrivenProperty",Bo),no("CrossFadedProperty",No),no("ColorRampProperty",jo);const Vo="-transition";class qo extends _t{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 zo(e.layout)),e.paint)){this._transitionablePaint=new Lo(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 Oo(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){if(null!=e){const n=`layers.${this.id}.layout.${t}`;if(this._validate(Ka,n,t,e,r))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e}getPaintProperty(t){return t.endsWith(Vo)?this._transitionablePaint.getTransition(t.slice(0,-Vo.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e){const n=`layers.${this.id}.paint.${t}`;if(this._validate(Ja,n,t,e,r))return!1}if(t.endsWith(Vo))return this._transitionablePaint.setTransition(t.slice(0,-Vo.length),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),a=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,a,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),S(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)&&Qa(this,t.call(Ya,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:bt,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 Do&&ki(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Ho={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Go{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}}const Wo=128,Zo=5;class Yo{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(this.capacity*Zo),Wo),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 Xo(t,e=1){let r=0,n=0;return{members:t.map((t=>{const i=$o(t.type),a=r=Jo(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:a}})),size:Jo(r,Math.max(n,e)),alignment:e}}function $o(t){return Ho[t].BYTES_PER_ELEMENT}function Jo(t,e){return Math.ceil(t/e)*e}class Ko extends Yo{_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}}Ko.prototype.bytesPerElement=4,no("StructArrayLayout2i4",Ko);class Qo extends Yo{_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}}Qo.prototype.bytesPerElement=6,no("StructArrayLayout3i6",Qo);class ts extends Yo{_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 a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,t}}ts.prototype.bytesPerElement=8,no("StructArrayLayout4i8",ts);class es extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,o){const s=6*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,t}}es.prototype.bytesPerElement=12,no("StructArrayLayout2i4i12",es);class rs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,o){const s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=a,this.uint8[l+7]=o,t}}rs.prototype.bytesPerElement=8,no("StructArrayLayout2i4ub8",rs);class ns extends Yo{_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}}ns.prototype.bytesPerElement=8,no("StructArrayLayout2f8",ns);class is extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,a,o,s,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,a,o,s,l,c)}emplace(t,e,r,n,i,a,o,s,l,c,u){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]=a,this.uint16[h+5]=o,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,t}}is.prototype.bytesPerElement=20,no("StructArrayLayout10ui20",is);class as extends Yo{_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,a,o,s,l,c,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,n,i,a,o,s,l,c,u,h)}emplace(t,e,r,n,i,a,o,s,l,c,u,h,f){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=r,this.int16[p+2]=n,this.int16[p+3]=i,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=s,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=f,t}}as.prototype.bytesPerElement=24,no("StructArrayLayout4i4ui4i24",as);class os extends Yo{_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}}os.prototype.bytesPerElement=12,no("StructArrayLayout3f12",os);class ss extends Yo{_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){const r=1*t;return this.uint32[r+0]=e,t}}ss.prototype.bytesPerElement=4,no("StructArrayLayout1ul4",ss);class ls extends Yo{_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,a,o,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,a,o,s,l)}emplace(t,e,r,n,i,a,o,s,l,c){const u=10*t,h=5*t;return this.int16[u+0]=e,this.int16[u+1]=r,this.int16[u+2]=n,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[h+3]=s,this.uint16[u+8]=l,this.uint16[u+9]=c,t}}ls.prototype.bytesPerElement=20,no("StructArrayLayout6i1ul2ui20",ls);class cs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,o){const s=6*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,t}}cs.prototype.bytesPerElement=12,no("StructArrayLayout2i2i2i12",cs);class us extends Yo{_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 a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const o=4*t,s=8*t;return this.float32[o+0]=e,this.float32[o+1]=r,this.float32[o+2]=n,this.int16[s+6]=i,this.int16[s+7]=a,t}}us.prototype.bytesPerElement=16,no("StructArrayLayout2f1f2i16",us);class hs extends Yo{_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,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,o){const s=16*t,l=4*t,c=8*t;return this.uint8[s+0]=e,this.uint8[s+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[c+6]=a,this.int16[c+7]=o,t}}hs.prototype.bytesPerElement=16,no("StructArrayLayout2ub2f2i16",hs);class fs extends Yo{_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}}fs.prototype.bytesPerElement=6,no("StructArrayLayout3ui6",fs);class ps extends Yo{_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,a,o,s,l,c,u,h,f,p,d,m,g){const y=this.length;return this.resize(y+1),this.emplace(y,t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g)}emplace(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y){const v=24*t,x=12*t,_=48*t;return this.int16[v+0]=e,this.int16[v+1]=r,this.uint16[v+2]=n,this.uint16[v+3]=i,this.uint32[x+2]=a,this.uint32[x+3]=o,this.uint32[x+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=c,this.uint16[v+12]=u,this.float32[x+7]=h,this.float32[x+8]=f,this.uint8[_+36]=p,this.uint8[_+37]=d,this.uint8[_+38]=m,this.uint32[x+10]=g,this.int16[v+22]=y,t}}ps.prototype.bytesPerElement=48,no("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ps);class ds extends Yo{_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,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x,_,b,w,T,k,A,M,S){const E=this.length;return this.resize(E+1),this.emplace(E,t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x,_,b,w,T,k,A,M,S)}emplace(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x,_,b,w,T,k,A,M,S,E){const C=32*t,L=16*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]=a,this.int16[C+5]=o,this.int16[C+6]=s,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=u,this.uint16[C+10]=h,this.uint16[C+11]=f,this.uint16[C+12]=p,this.uint16[C+13]=d,this.uint16[C+14]=m,this.uint16[C+15]=g,this.uint16[C+16]=y,this.uint16[C+17]=v,this.uint16[C+18]=x,this.uint16[C+19]=_,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[L+12]=k,this.float32[L+13]=A,this.float32[L+14]=M,this.uint16[C+30]=S,this.uint16[C+31]=E,t}}ds.prototype.bytesPerElement=64,no("StructArrayLayout8i15ui1ul2f2ui64",ds);class ms extends Yo{_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){const r=1*t;return this.float32[r+0]=e,t}}ms.prototype.bytesPerElement=4,no("StructArrayLayout1f4",ms);class gs extends Yo{_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=6*t,a=3*t;return this.uint16[i+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,t}}gs.prototype.bytesPerElement=12,no("StructArrayLayout1ui2f12",gs);class ys extends Yo{_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=2*t,a=4*t;return this.uint32[i+0]=e,this.uint16[a+2]=r,this.uint16[a+3]=n,t}}ys.prototype.bytesPerElement=8,no("StructArrayLayout1ul2ui8",ys);class vs extends Yo{_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}}vs.prototype.bytesPerElement=4,no("StructArrayLayout2ui4",vs);class xs extends Yo{_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){const r=1*t;return this.uint16[r+0]=e,t}}xs.prototype.bytesPerElement=2,no("StructArrayLayout1ui2",xs);class _s extends Yo{_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 a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,t}}_s.prototype.bytesPerElement=16,no("StructArrayLayout4f16",_s);class bs extends Go{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 a(this.anchorPointX,this.anchorPointY)}}bs.prototype.size=20;class ws extends ls{get(t){return new bs(this,t)}}no("CollisionBoxArray",ws);class Ts extends Go{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]}}Ts.prototype.size=48;class ks extends ps{get(t){return new Ts(this,t)}}no("PlacedSymbolArray",ks);class As extends Go{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]}}As.prototype.size=64;class Ms extends ds{get(t){return new As(this,t)}}no("SymbolInstanceArray",Ms);class Ss extends ms{getoffsetX(t){return this.float32[1*t+0]}}no("GlyphOffsetArray",Ss);class Es extends Qo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}no("SymbolLineVertexArray",Es);class Cs extends Go{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]}}Cs.prototype.size=12;class Ls extends gs{get(t){return new Cs(this,t)}}no("TextAnchorOffsetArray",Ls);class Is extends Go{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]}}Is.prototype.size=8;class Ps extends ys{get(t){return new Is(this,t)}}no("FeatureIndexArray",Ps);class zs extends Ko{}class Ds extends Qo{}class Os extends ts{}class Rs extends Ko{}class Fs extends Ko{}class Bs extends es{}class Ns extends rs{}class js extends ns{}class Us extends is{}class Vs extends as{}class qs extends os{}class Hs extends ss{}class Gs extends cs{}class Ws extends us{}class Zs extends hs{}class Ys extends fs{}class Xs extends fs{}class $s extends vs{}class Js extends xs{}const Ks=Xo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Qs,size:tl,alignment:el}=Ks;class rl{constructor(t=[]){this.segments=t}prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>rl.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${rl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>rl.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 rl([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function nl(t,e){return 256*(t=y(Math.floor(t),0,255))+(e=y(Math.floor(e),0,255))}rl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,no("SegmentVector",rl);const il=Xo([{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 al={exports:{}},ol={exports:{}};!function(t){function e(t,e){var r,n,i,a,o,s,l,c;for(r=3&t.length,n=t.length-r,i=e,o=3432918353,s=461845907,c=0;c>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&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}t.exports=e}(ol);var sl=ol.exports,ll={exports:{}};!function(t){function e(t,e){for(var r,n=t.length,i=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<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,++a;switch(n){case 3:i^=(255&t.charCodeAt(a+2))<<16;case 2:i^=(255&t.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}t.exports=e}(ll);var cl=sl,ul=ll.exports;al.exports=cl,al.exports.murmur3=cl,al.exports.murmur2=ul;var hl=r(al.exports);class fl{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,r,n){this.ids.push(pl(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=pl(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;){const t=this.positions[3*r],e=this.positions[3*r+1],n=this.positions[3*r+2];i.push({index:t,start:e,end:n}),r++}return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return dl(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new fl;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function pl(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:hl(String(t))}function dl(t,e,r,n){for(;r>1];let a=r-1,o=n+1;for(;;){do{a++}while(t[a]i);if(a>=o)break;ml(t,a,o),ml(e,3*a,3*o),ml(e,3*a+1,3*o+1),ml(e,3*a+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 wl(t,e):new vl(t,e)}}class Sl{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 bl(t,e):new vl(t,e)}}class El{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 a=this.paintVertexArray.length,o=this.expression.evaluate(new So(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(a,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=Al(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 a}populatePaintArray(t,e,r,n,i){const a=this.expression.evaluate(new So(this.zoom),e,{},n,[],i),o=this.expression.evaluate(new So(this.zoom+1),e,{},n,[],i),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,a,o)}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),a=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,a)}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Al(r),a=Al(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 El||r instanceof Cl)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Il(n,e,r);this.needsUpload=!1,this._featureMap=new fl,this._bufferOffset=0}populatePaintArrays(t,e,r,n,i,a){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,a);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 zl(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 Dl(t){return{"line-pattern":{source:Us,composite:Us},"fill-pattern":{source:Us,composite:Us},"fill-extrusion-pattern":{source:Us,composite:Us}}[t]}function Ol(t,e,r){const n={color:{source:ns,composite:_s},number:{source:ms,composite:ns}},i=Dl(t);return i&&i[r]||n[e][r]}no("ConstantBinder",Ml),no("CrossFadedConstantBinder",Sl),no("SourceExpressionBinder",El),no("CrossFadedCompositeBinder",Ll),no("CompositeExpressionBinder",Cl),no("ProgramConfiguration",Il,{omit:["_buffers"]}),no("ProgramConfigurationSet",Pl);const Rl=8192,Fl=15,Bl=Math.pow(2,Fl-1)-1,Nl=-Bl-1;function jl(t){const e=Rl/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||ar.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Ul(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?jl(t):[]}}function Vl(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}class ql{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 Rs,this.indexArray=new Xs,this.segments=new rl,this.programConfigurations=new Pl(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 a=null,o=!1;"circle"===n.type&&(a=n.layout.get("circle-sort-key"),o=!a.isConstant());for(const{feature:e,id:n,index:s,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ul(e,t);if(!this.layers[0]._featureFilter.filter(new So(this.zoom),c,r))continue;const u=o?a.evaluate(c,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:s,geometry:t?c.geometry:jl(e),patterns:{},sortKey:u};i.push(h)}o&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:a,sourceLayerIndex:o}=n,s=t[a].feature;this.addFeature(n,i,a,r),e.featureIndex.insert(s,i,a,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,Qs),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>=Rl||n<0||n>=Rl)continue;const i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=i.vertexLength;Vl(this.layoutVertexArray,r,n,-1,-1),Vl(this.layoutVertexArray,r,n,1,-1),Vl(this.layoutVertexArray,r,n,1,1),Vl(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+3,a+2),i.vertexLength+=4,i.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n)}}function Hl(t,e){for(let r=0;r=3)for(let e=0;e1){if(Xl(t,e))return!0;for(let n=0;n1?t.distSqr(r):t.distSqr(r.sub(e)._mult(i)._add(e))}function Ql(t,e){let r,n,i,a=!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&&(a=!a)}return a}function tc(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function ec(t,e,r,n,i){for(const a of t)if(e<=a.x&&r<=a.y&&n>=a.x&&i>=a.y)return!0;const o=[new a(e,r),new a(e,i),new a(n,i),new a(n,r)];if(t.length>2)for(const e of o)if(tc(t,e))return!0;for(let e=0;ei.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;const a=z(t,e,r[0]);return a!==z(t,e,r[1])||a!==z(t,e,r[2])||a!==z(t,e,r[3])}function nc(t,e,r){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ic(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ac(t,e,r,n,i){if(!e[0]&&!e[1])return t;const o=a.convert(e)._mult(i);"viewport"===r&&o._rotate(-n);const s=[];for(let e=0;esc=sc||new Uo({"circle-sort-key":new Fo(bt.layout_circle["circle-sort-key"])});let cc;const uc=()=>cc=cc||new Uo({"circle-radius":new Fo(bt.paint_circle["circle-radius"]),"circle-color":new Fo(bt.paint_circle["circle-color"]),"circle-blur":new Fo(bt.paint_circle["circle-blur"]),"circle-opacity":new Fo(bt.paint_circle["circle-opacity"]),"circle-translate":new Ro(bt.paint_circle["circle-translate"]),"circle-translate-anchor":new Ro(bt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Ro(bt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Ro(bt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Fo(bt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Fo(bt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Fo(bt.paint_circle["circle-stroke-opacity"])});var hc={get paint(){return uc()},get layout(){return lc()}},fc=1e-6,pc="undefined"!=typeof Float32Array?Float32Array:Array;function dc(){var t=new pc(16);return pc!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function mc(t){var e=new pc(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function gc(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function yc(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function vc(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=e[9],f=e[10],p=e[11],d=e[12],m=e[13],g=e[14],y=e[15],v=r*s-n*o,x=r*l-i*o,_=r*c-a*o,b=n*l-i*s,w=n*c-a*s,T=i*c-a*l,k=u*m-h*d,A=u*g-f*d,M=u*y-p*d,S=h*g-f*m,E=h*y-p*m,C=f*y-p*g,L=v*C-x*E+_*S+b*M-w*A+T*k;return L?(L=1/L,t[0]=(s*C-l*E+c*S)*L,t[1]=(i*E-n*C-a*S)*L,t[2]=(m*T-g*w+y*b)*L,t[3]=(f*w-h*T-p*b)*L,t[4]=(l*M-o*C-c*A)*L,t[5]=(r*C-i*M+a*A)*L,t[6]=(g*_-d*T-y*x)*L,t[7]=(u*T-f*_+p*x)*L,t[8]=(o*E-s*M+c*k)*L,t[9]=(n*M-r*E-a*k)*L,t[10]=(d*w-m*_+y*v)*L,t[11]=(h*_-u*w-p*v)*L,t[12]=(s*A-o*S-l*k)*L,t[13]=(r*S-n*A+i*k)*L,t[14]=(m*x-d*b-g*v)*L,t[15]=(u*b-h*x+f*v)*L,t):null}function xc(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],h=e[8],f=e[9],p=e[10],d=e[11],m=e[12],g=e[13],y=e[14],v=e[15],x=r[0],_=r[1],b=r[2],w=r[3];return t[0]=x*n+_*s+b*h+w*m,t[1]=x*i+_*l+b*f+w*g,t[2]=x*a+_*c+b*p+w*y,t[3]=x*o+_*u+b*d+w*v,x=r[4],_=r[5],b=r[6],w=r[7],t[4]=x*n+_*s+b*h+w*m,t[5]=x*i+_*l+b*f+w*g,t[6]=x*a+_*c+b*p+w*y,t[7]=x*o+_*u+b*d+w*v,x=r[8],_=r[9],b=r[10],w=r[11],t[8]=x*n+_*s+b*h+w*m,t[9]=x*i+_*l+b*f+w*g,t[10]=x*a+_*c+b*p+w*y,t[11]=x*o+_*u+b*d+w*v,x=r[12],_=r[13],b=r[14],w=r[15],t[12]=x*n+_*s+b*h+w*m,t[13]=x*i+_*l+b*f+w*g,t[14]=x*a+_*c+b*p+w*y,t[15]=x*o+_*u+b*d+w*v,t}function _c(t,e,r){var n,i,a,o,s,l,c,u,h,f,p,d,m=r[0],g=r[1],y=r[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],h=e[8],f=e[9],p=e[10],d=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=f,t[10]=p,t[11]=d,t[12]=n*m+s*g+h*y+e[12],t[13]=i*m+l*g+f*y+e[13],t[14]=a*m+c*g+p*y+e[14],t[15]=o*m+u*g+d*y+e[15]),t}function bc(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function wc(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+h*n,t[7]=l*i+f*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=h*i-s*n,t[11]=f*i-l*n,t}function Tc(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],h=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+h*n,t[3]=l*i+f*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=h*i-s*n,t[7]=f*i-l*n,t}function kc(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ac(t,e,r,n,i){var a,o=1/Math.tan(e/2);return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(a=1/(n-i),t[10]=(i+n)*a,t[14]=2*i*n*a):(t[10]=-1,t[14]=-2*n),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Mc=Ac;function Sc(t,e,r,n,i,a,o){var s=1/(e-r),l=1/(n-i),c=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*l,t[14]=(o+a)*c,t[15]=1,t}var Ec=Sc;function Cc(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function Lc(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],f=t[10],p=t[11],d=t[12],m=t[13],g=t[14],y=t[15],v=e[0],x=e[1],_=e[2],b=e[3],w=e[4],T=e[5],k=e[6],A=e[7],M=e[8],S=e[9],E=e[10],C=e[11],L=e[12],I=e[13],P=e[14],z=e[15];return Math.abs(r-v)<=fc*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-x)<=fc*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(i-_)<=fc*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-b)<=fc*Math.max(1,Math.abs(a),Math.abs(b))&&Math.abs(o-w)<=fc*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=fc*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-k)<=fc*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(c-A)<=fc*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(u-M)<=fc*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(h-S)<=fc*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(f-E)<=fc*Math.max(1,Math.abs(f),Math.abs(E))&&Math.abs(p-C)<=fc*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(d-L)<=fc*Math.max(1,Math.abs(d),Math.abs(L))&&Math.abs(m-I)<=fc*Math.max(1,Math.abs(m),Math.abs(I))&&Math.abs(g-P)<=fc*Math.max(1,Math.abs(g),Math.abs(P))&&Math.abs(y-z)<=fc*Math.max(1,Math.abs(y),Math.abs(z))}var Ic=xc;function Pc(){var t=new pc(4);return pc!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zc(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function Dc(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Oc(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}var Rc=zc;Pc();class Fc extends qo{constructor(t){super(t,hc)}createBucket(t){return new ql(t)}queryRadius(t){const e=t;return nc("circle-radius",this,e)+nc("circle-stroke-width",this,e)+ic(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,n,i,a,o,s){const l=ac(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,o),c=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),u="map"===this.paint.get("circle-pitch-alignment"),h=u?l:Nc(l,s),f=u?c*o:c;for(const t of n)for(const e of t){const t=u?e:Bc(e,s);let r=f;const n=Oc([],[e.x,e.y,0,1],s);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/a.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=a.cameraToCenterDistance/n[3]),Gl(h,t,r))return!0}return!1}}function Bc(t,e){const r=Oc([],[t.x,t.y,0,1],e);return new a(r[0]/r[3],r[1]/r[3])}function Nc(t,e){return t.map((t=>Bc(t,e)))}class jc extends ql{}let Uc;no("HeatmapBucket",jc,{omit:["layers"]});const Vc=()=>Uc=Uc||new Uo({"heatmap-radius":new Fo(bt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Fo(bt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ro(bt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new jo(bt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ro(bt.paint_heatmap["heatmap-opacity"])});var qc={get paint(){return Vc()}};function Hc(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 Gc(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Hc({},{width:e,height:r},n);Wc(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 Wc(t,e,r,n,i,a){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,s=e.data;if(o===s)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=a;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;eJc=Jc||new Uo({"hillshade-illumination-direction":new Ro(bt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Ro(bt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Ro(bt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Ro(bt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Ro(bt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Ro(bt.paint_hillshade["hillshade-accent-color"])});var Qc={get paint(){return Kc()}};class tu extends qo{constructor(t){super(t,Qc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}}const eu=Xo([{name:"a_pos",components:2,type:"Int16"}],4),{members:ru,size:nu,alignment:iu}=eu;function au(t,e,r=2){const n=e&&e.length,i=n?e[0]*r:t.length;let a=ou(t,0,i,r,!0);const o=[];if(!a||a.next===a.prev)return o;let s,l,c;if(n&&(a=pu(t,e,a,r)),t.length>80*r){s=1/0,l=1/0;let e=-1/0,n=-1/0;for(let a=r;ae&&(e=r),i>n&&(n=i)}c=Math.max(e-s,n-l),c=0!==c?32767/c:0}return lu(a,o,r,s,l,c,0),o}function ou(t,e,r,n,i){let a;if(i===Ru(t,e,r,n)>0)for(let i=e;i=e;i-=n)a=zu(i/n|0,t[i],t[i+1],a);return a&&Au(a,a.next)&&(Du(a),a=a.next),a}function su(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Au(n,n.next)&&0!==ku(n.prev,n,n.next))n=n.next;else{if(Du(n),n=e=n.prev,n===n.next)break;r=!0}}while(r||n!==e);return e}function lu(t,e,r,n,i,a,o){if(!t)return;!o&&a&&vu(t,n,i,a);let s=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(a?uu(t,n,i,a):cu(t))e.push(l.i,t.i,c.i),Du(t),t=c.next,s=c.next;else if((t=c)===s){o?1===o?lu(t=hu(su(t),e),e,r,n,i,a,2):2===o&&fu(t,e,r,n,i,a):lu(su(t),e,r,n,i,a,1);break}}}function cu(t){const e=t.prev,r=t,n=t.next;if(ku(e,r,n)>=0)return!1;const i=e.x,a=r.x,o=n.x,s=e.y,l=r.y,c=n.y,u=ia?i>o?i:o:a>o?a:o,p=s>l?s>c?s:c:l>c?l:c;let d=n.next;for(;d!==e;){if(d.x>=u&&d.x<=f&&d.y>=h&&d.y<=p&&wu(i,s,a,l,o,c,d.x,d.y)&&ku(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function uu(t,e,r,n){const i=t.prev,a=t,o=t.next;if(ku(i,a,o)>=0)return!1;const s=i.x,l=a.x,c=o.x,u=i.y,h=a.y,f=o.y,p=sl?s>c?s:c:l>c?l:c,g=u>h?u>f?u:f:h>f?h:f,y=_u(p,d,e,r,n),v=_u(m,g,e,r,n);let x=t.prevZ,_=t.nextZ;for(;x&&x.z>=y&&_&&_.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=g&&x!==i&&x!==o&&wu(s,u,l,h,c,f,x.x,x.y)&&ku(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,_.x>=p&&_.x<=m&&_.y>=d&&_.y<=g&&_!==i&&_!==o&&wu(s,u,l,h,c,f,_.x,_.y)&&ku(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=g&&x!==i&&x!==o&&wu(s,u,l,h,c,f,x.x,x.y)&&ku(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=m&&_.y>=d&&_.y<=g&&_!==i&&_!==o&&wu(s,u,l,h,c,f,_.x,_.y)&&ku(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function hu(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Au(n,i)&&Mu(n,r,r.next,i)&&Lu(n,i)&&Lu(i,n)&&(e.push(n.i,r.i,i.i),Du(r),Du(r.next),r=t=i),r=r.next}while(r!==t);return su(r)}function fu(t,e,r,n,i,a){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Tu(o,t)){let s=Pu(o,t);return o=su(o,o.next),s=su(s,s.next),lu(o,e,r,n,i,a,0),void lu(s,e,r,n,i,a,0)}t=t.next}o=o.next}while(o!==t)}function pu(t,e,r,n){const i=[];for(let r=0,a=e.length;r=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,a=r.x=r.x&&r.x>=l&&n!==r.x&&wu(ia.x||r.x===a.x&&yu(a,r)))&&(a=r,u=e)}r=r.next}while(r!==s);return a}function yu(t,e){return ku(t.prev,t,e.prev)<0&&ku(e.next,t,t.next)<0}function vu(t,e,r,n){let i=t;do{0===i.z&&(i.z=_u(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,xu(i)}function xu(t){let e,r=1;do{let n,i=t;t=null;let a=null;for(e=0;i;){e++;let o=i,s=0;for(let t=0;t0||l>0&&o;)0!==s&&(0===l||!o||i.z<=o.z)?(n=i,i=i.nextZ,s--):(n=o,o=o.nextZ,l--),a?a.nextZ=n:t=n,n.prevZ=a,a=n;i=o}a.nextZ=null,r*=2}while(e>1);return t}function _u(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 bu(t){let e=t,r=t;do{(e.x=(t-o)*(a-s)&&(t-o)*(n-s)>=(r-o)*(e-s)&&(r-o)*(a-s)>=(i-o)*(n-s)}function Tu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Cu(t,e)&&(Lu(t,e)&&Lu(e,t)&&Iu(t,e)&&(ku(t.prev,t,e.prev)||ku(t,e.prev,e))||Au(t,e)&&ku(t.prev,t,t.next)>0&&ku(e.prev,e,e.next)>0)}function ku(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Au(t,e){return t.x===e.x&&t.y===e.y}function Mu(t,e,r,n){const i=Eu(ku(t,e,r)),a=Eu(ku(t,e,n)),o=Eu(ku(r,n,t)),s=Eu(ku(r,n,e));return i!==a&&o!==s||!(0!==i||!Su(t,r,e))||!(0!==a||!Su(t,n,e))||!(0!==o||!Su(r,t,n))||!(0!==s||!Su(r,e,n))}function Su(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 Eu(t){return t>0?1:t<0?-1:0}function Cu(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&&Mu(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Lu(t,e){return ku(t.prev,t,t.next)<0?ku(t,e,t.next)>=0&&ku(t,t.prev,e)>=0:ku(t,e,t.prev)<0||ku(t,t.next,e)<0}function Iu(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}function Pu(t,e){const r=Ou(t.i,t.x,t.y),n=Ou(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function zu(t,e,r,n){const i=Ou(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 Du(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 Ou(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ru(t,e,r,n){let i=0;for(let a=e,o=r-n;at.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Fs,this.indexArray=new Xs,this.indexArray2=new $s,this.programConfigurations=new Pl(t.layers,t.zoom),this.segments=new rl,this.segments2=new rl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Fu("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ul(o,t);if(!this.layers[0]._featureFilter.filter(new So(this.zoom),u,r))continue;const h=i?n.evaluate(u,{},r,e.availableImages):void 0,f={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:jl(o),patterns:{},sortKey:h};a.push(f)}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Bu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,a,r,{});const s=t[a].feature;e.featureIndex.insert(s,i,a,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,ru),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 Cn(e,Nu)){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=[],a=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&a.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;tUu=Uu||new Uo({"fill-sort-key":new Fo(bt.layout_fill["fill-sort-key"])});let qu;const Hu=()=>qu=qu||new Uo({"fill-antialias":new Ro(bt.paint_fill["fill-antialias"]),"fill-opacity":new Fo(bt.paint_fill["fill-opacity"]),"fill-color":new Fo(bt.paint_fill["fill-color"]),"fill-outline-color":new Fo(bt.paint_fill["fill-outline-color"]),"fill-translate":new Ro(bt.paint_fill["fill-translate"]),"fill-translate-anchor":new Ro(bt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Bo(bt.paint_fill["fill-pattern"])});var Gu={get paint(){return Hu()},get layout(){return Vu()}};class Wu extends qo{constructor(t){super(t,Gu)}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new ju(t)}queryRadius(){return ic(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,n,i,a,o){return Wl(ac(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,o),n)}isTileClipped(){return!0}}const Zu=Xo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Yu=Xo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Xu,size:$u,alignment:Ju}=Zu;var Ku={},Qu=n,th=eh;function eh(t,e,r,n,i){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=i,t.readFields(rh,this,e)}function rh(t,e,r){1==t?e.id=r.readVarint():2==t?nh(r,e):3==t?e.type=r.readVarint():4==t&&(e._geometry=r.pos)}function nh(t,e){for(var r=t.readVarint()+t.pos;t.pos>3}if(i--,1===n||2===n)a+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&s.push(e),e=[]),e.push(new Qu(a,o));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&s.push(e),s},eh.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())c&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,c]},eh.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=eh.types[this.type];function u(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}lh.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 oh(this._pbf,e,this.extent,this._keys,this._values)};var hh=sh,fh=ph;function ph(t,e){this.layers=t.readFields(dh,{},e)}function dh(t,e,r){if(3===t){var n=new hh(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}Ku.VectorTile=fh,Ku.VectorTileFeature=th,Ku.VectorTileLayer=sh;const mh=Ku.VectorTileFeature.types,gh=500,yh=Math.pow(2,13);function vh(t,e,r,n,i,a,o,s){t.emplaceBack(e,r,2*Math.floor(n*yh)+o,i*yh*2,a*yh*2,Math.round(s))}class xh{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 Bs,this.centroidVertexArray=new zs,this.indexArray=new Xs,this.programConfigurations=new Pl(t.layers,t.zoom),this.segments=new rl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.features=[],this.hasPattern=Fu("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,s=Ul(n,t);if(!this.layers[0]._featureFilter.filter(new So(this.zoom),s,r))continue;const l={id:i,sourceLayerIndex:o,index:a,geometry:t?s.geometry:jl(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Bu("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,a,r,{}),e.featureIndex.insert(n,l.geometry,a,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,Xu),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Yu.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 Cn(e,gh)){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(bh(t))continue;let r=0;for(let n=0;n=1){const o=t[n-1];if(!_h(a,o)){i.vertexLength+4>rl.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=a.sub(o)._perp()._unit(),n=o.dist(a);r+n>32768&&(r=0),vh(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,r),vh(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,r),e.x+=2*a.x,e.y+=2*a.y,e.vertexCount+=2,r+=n,vh(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,0,r),vh(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 s=i.vertexLength;this.indexArray.emplaceBack(s,s+2,s+1),this.indexArray.emplaceBack(s+1,s+2,s+3),i.vertexLength+=4,i.primitiveLength+=2}}}}if(i.vertexLength+n>rl.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==mh[t.type])continue;const a=[],o=[],s=i.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&o.push(a.length/2);for(let r=0;rRl)||t.y===e.y&&(t.y<0||t.y>Rl)}function bh(t){return t.every((t=>t.x<0))||t.every((t=>t.x>Rl))||t.every((t=>t.y<0))||t.every((t=>t.y>Rl))}let wh;no("FillExtrusionBucket",xh,{omit:["layers","features"]});const Th=()=>wh=wh||new Uo({"fill-extrusion-opacity":new Ro(bt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Fo(bt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ro(bt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ro(bt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Bo(bt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Fo(bt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Fo(bt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ro(bt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])});var kh={get paint(){return Th()}};class Ah extends qo{constructor(t){super(t,kh)}createBucket(t){return new xh(t)}queryRadius(){return ic(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,r,n,i,a,o,s){const l=ac(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),c=this.paint.get("fill-extrusion-height").evaluate(e,r),u=this.paint.get("fill-extrusion-base").evaluate(e,r),h=Lh(l,s,a,0),f=Ch(n,u,c,s);return Eh(f[0],f[1],h)}}function Mh(t,e){return t.x*e.x+t.y*e.y}function Sh(t,e){if(1===t.length){let r=0;const n=e[r++];let i;for(;!i||n.equals(i);)if(i=e[r++],!i)return 1/0;for(;rt.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 Ns,this.layoutVertexArray2=new js,this.indexArray=new Xs,this.programConfigurations=new Pl(t.layers,t.zoom),this.segments=new rl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Fu("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),a=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ul(e,t);if(!this.layers[0]._featureFilter.filter(new So(this.zoom),c,r))continue;const u=i?n.evaluate(c,{},r):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:s,geometry:t?c.geometry:jl(e),patterns:{},sortKey:u};a.push(h)}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Bu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,a,r,{});const s=t[a].feature;e.featureIndex.insert(s,i,a,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,Rh)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ph),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 a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),s=a.get("line-cap"),l=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,s,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n)}addLine(t,e,r,n,i,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[s-1].equals(t[s-2]);)s--;let l=0;for(;l0;if(b&&e>l){const t=h.dist(f);if(t>2*c){const e=h.sub(h.sub(f)._mult(c/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,d,0,0,u),f=e}}const T=f&&p;let k=T?r:o?"butt":n;if(T&&"round"===k&&(xi&&(k="bevel"),"bevel"===k&&(x>2&&(k="flipbevel"),x100)g=m.mult(-1);else{const t=x*d.add(m).mag()/d.sub(m).mag();g._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(h,g,0,0,u),this.addCurrentVertex(h,g.mult(-1),0,0,u)}else if("bevel"===k||"fakeround"===k){const t=-Math.sqrt(x*x-1),e=w?t:0,r=w?0:t;if(f&&this.addCurrentVertex(h,d,e,r,u),"fakeround"===k){const t=Math.round(180*_/Math.PI/qh);for(let e=1;e2*c){const e=h.add(p.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,r,n,i,a=!1){const o=e.x+e.y*r,s=e.y-e.x*r,l=-e.x+e.y*n,c=-e.y-e.x*n;this.addHalfVertex(t,o,s,a,!1,r,i),this.addHalfVertex(t,l,c,a,!0,-n,i),this.distance>Wh/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,a))}addHalfVertex({x:t,y:e},r,n,i,a,o,s){const l=(this.lineClips?this.scaledDistance*(Wh-1):this.scaledDistance)*Gh;if(this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(a?1:0),Math.round(jh*r)+128,Math.round(jh*n)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips){const t=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(t,this.lineClipsArray.length)}const c=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),s.primitiveLength++),a?this.e2=c:this.e1=c}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 Yh;no("LineBucket",Zh,{omit:["layers","patternFeatures"]});const Xh=()=>Yh=Yh||new Uo({"line-cap":new Ro(bt.layout_line["line-cap"]),"line-join":new Fo(bt.layout_line["line-join"]),"line-miter-limit":new Ro(bt.layout_line["line-miter-limit"]),"line-round-limit":new Ro(bt.layout_line["line-round-limit"]),"line-sort-key":new Fo(bt.layout_line["line-sort-key"])});let $h;const Jh=()=>$h=$h||new Uo({"line-opacity":new Fo(bt.paint_line["line-opacity"]),"line-color":new Fo(bt.paint_line["line-color"]),"line-translate":new Ro(bt.paint_line["line-translate"]),"line-translate-anchor":new Ro(bt.paint_line["line-translate-anchor"]),"line-width":new Fo(bt.paint_line["line-width"]),"line-gap-width":new Fo(bt.paint_line["line-gap-width"]),"line-offset":new Fo(bt.paint_line["line-offset"]),"line-blur":new Fo(bt.paint_line["line-blur"]),"line-dasharray":new No(bt.paint_line["line-dasharray"]),"line-pattern":new Bo(bt.paint_line["line-pattern"]),"line-gradient":new jo(bt.paint_line["line-gradient"])});var Kh={get paint(){return Jh()},get layout(){return Xh()}};class Qh extends Fo{possiblyEvaluate(t,e){return e=new So(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=_({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let tf;class ef extends qo{constructor(t){super(t,Kh),this.gradientVersion=0,tf||(tf=new Qh(Kh.paint.properties["line-width"].specification),tf.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();Vi(t)?this.stepInterpolant=t._styleExpression.expression instanceof lr:this.stepInterpolant=!1,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"]=tf.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Zh(t)}queryRadius(t){const e=t,r=rf(nc("line-width",this,e),nc("line-gap-width",this,e)),n=nc("line-offset",this,e);return r/2+Math.abs(n)+ic(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,a,o){const s=ac(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,o),l=o/2*rf(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=oc(n,c*o)),Zl(s,n,l)}isTileClipped(){return!0}}function rf(t,e){return e>0?e+2*t:t}const nf=Xo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),af=Xo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Xo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const of=Xo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Xo([{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 sf=Xo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),lf=Xo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function cf(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Mo.applyArabicShaping&&(t=Mo.applyArabicShaping(t)),t}function uf(t,e,r){return t.sections.forEach((t=>{t.text=cf(t.text,e,r)})),t}function hf(t){const e={},r={},n=[];let i=0;function a(e){n.push(t[e]),i++}function o(t,e,i){const a=r[t];return delete r[t],r[e]=a,n[a].geometry[0].pop(),n[a].geometry[0]=n[a].geometry[0].concat(i[0]),a}function s(t,r,i){const a=e[r];return delete e[r],e[t]=a,n[a].geometry[0].shift(),n[a].geometry[0]=i[0].concat(n[a].geometry[0]),a}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 c=0;ct.geometry))}Xo([{name:"triangle",components:3,type:"Uint16"}]),Xo([{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"}]),Xo([{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"}]),Xo([{type:"Float32",name:"offsetX"}]),Xo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Xo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const ff={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function pf(t){let e="";for(let r=0;r */ -read:function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,h=r?i-1:0,f=r?-1:1,p=t[e+h];for(h+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+h],h+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+h],h+=f,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},write:function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*m}},gf=vf,yf=mf;function vf(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}vf.Varint=0,vf.Fixed64=1,vf.Bytes=2,vf.Fixed32=5;var xf=4294967296,_f=1/xf,bf=12,wf="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function Tf(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return Af(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return Af(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function kf(t){return t.type===vf.Bytes?t.readVarint()+t.pos:t.pos+1}function Af(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Mf(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),Sf(r,n,e),Ef(n,e)}function Sf(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,t>>>=7,r.buf[r.pos]=127&t}function Ef(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)))))}function Cf(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 Lf(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Uf(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Vf(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(a=t[i+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===u?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),i+=u}return n}function qf(t,e,r){return wf.decode(t.subarray(e,r))}function Hf(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+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}vf.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Nf(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Uf(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Nf(this.buf,this.pos)+Nf(this.buf,this.pos+4)*xf;return this.pos+=8,t},readSFixed64:function(){var t=Nf(this.buf,this.pos)+Uf(this.buf,this.pos+4)*xf;return this.pos+=8,t},readFloat:function(){var t=yf.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=yf.read(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:Tf(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>=bf&&wf?qf(this.buf,e,t):Vf(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!==vf.Bytes)return t.push(this.readVarint(e));var r=kf(this);for(t=t||[];this.pos127;);else if(e===vf.Bytes)this.pos=this.readVarint()+this.pos;else if(e===vf.Fixed32)this.pos+=4;else{if(e!==vf.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?Mf(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=Hf(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Cf(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),yf.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),yf.write(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&&Cf(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,vf.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Lf,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,If,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Df,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Pf,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,zf,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Of,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Rf,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Ff,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Bf,e)},writeBytesField:function(t,e){this.writeTag(t,vf.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,vf.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,vf.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,vf.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,vf.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,vf.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,vf.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,vf.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,vf.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,vf.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Gf=r(gf);const Wf=3;function Zf(t,e,r){1===t&&r.readMessage(Yf,e)}function Yf(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:a,left:o,top:s,advance:l}=r.readMessage(Xf,{});e.push({id:t,bitmap:new Zc({width:i+2*Wf,height:a+2*Wf},n),metrics:{width:i,height:a,left:o,top:s,advance:l}})}}function Xf(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint())}function $f(t){return new Gf(t).readFields(Zf,[])}const Jf=Wf;function Kf(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,a=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,a=Math.max(a,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&&hp[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 lp;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(sp.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=op?null:++this.imageSectionID:(this.imageSectionID=ap,this.imageSectionID)}}function cp(t,e){const r=[],n=t.text;let i=0;for(const n of e)r.push(t.substring(i,n)),i=n;return i=0;let c=0;for(let r=0;r0&&n>b&&(b=n)}else{const t=n[m.fontStack],e=t&&t[y];if(e&&e.rect)w=e.rect,x=e.metrics;else{const t=r[m.fontStack],e=t&&t[y];if(!e)continue;x=e.metrics}v=(a-m.scale)*df}A?(e.verticalizable=!0,_.push({glyph:y,imageName:T,x:p,y:d+v,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:x,rect:w}),p+=k*m.scale+u):(_.push({glyph:y,imageName:T,x:p,y:d+v,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:x,rect:w}),p+=x.advance*m.scale+u)}if(0!==_.length){const t=p-u;m=Math.max(t,m),Tp(_,0,_.length-1,y,b)}p=0;const w=o*a+b;x.lineOffset=Math.max(b,l),d+=w,g=Math.max(w,g),++v}const x=d-np,{horizontalAlign:_,verticalAlign:b}=bp(s);kp(e.positionedLines,y,_,b,m,g,o,x,a.length),e.top+=-b*x,e.bottom=e.top+x,e.left+=-_*m,e.right=e.left+m}function Tp(t,e,r,n,i){if(!n&&!i)return;const a=t[r],o=a.metrics.advance*a.scale,s=(t[r].x+o)*n;for(let n=e;n<=r;n++)t[n].x-=s,t[n].y+=i}function kp(t,e,r,n,i,a,o,s,l){const c=(e-r)*i;let u=0;u=a!==o?-s*n-np:(-n*l+.5)*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=u}function Ap(t,e,r){const{horizontalAlign:n,verticalAlign:i}=bp(r),a=e[0],o=e[1],s=a-t.displaySize[0]*n,l=s+t.displaySize[0],c=o-t.displaySize[1]*i;return{image:t,top:c,bottom:c+t.displaySize[1],left:s,right:l}}function Mp(t){var e,r;let n=t.left,i=t.top,a=t.right-n,o=t.bottom-i;const s=t.image.content[2]-t.image.content[0],l=t.image.content[3]-t.image.content[1],c=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",u=null!==(r=t.image.textFitHeight)&&void 0!==r?r:"stretchOrShrink",h=s/l;if("proportional"===u){if("stretchOnly"===c&&a/oh){const t=Math.ceil(a/h);i*=t/o,o=t}return{x1:n,y1:i,x2:n+a,y2:i+o}}function Sp(t,e,r,n,i,a){const o=t.image;let s;if(o.content){const t=o.content,e=o.pixelRatio||1;s=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e]}const l=e.left*a,c=e.right*a;let u,h,f,p;"width"===r||"both"===r?(p=i[0]+l-n[3],h=i[0]+c+n[1]):(p=i[0]+(l+c-o.displaySize[0])/2,h=p+o.displaySize[0]);const d=e.top*a,m=e.bottom*a;return"height"===r||"both"===r?(u=i[1]+d-n[0],f=i[1]+m+n[2]):(u=i[1]+(d+m-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:h,bottom:f,left:p,collisionPadding:s}}const Ep=255,Cp=128,Lp=Ep*Cp;function Ip(t,e){const{expression:r}=e;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new So(t+1))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=yc([]),this.placementViewportMatrix=yc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ip(this.zoom,r["text-size"]),this.iconSizeData=Ip(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),a=n.get("symbol-z-order");this.canOverlap="never"!==Dp(n,"text-overlap","text-allow-overlap")||"never"!==Dp(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!i.isConstant();const o="viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey;this.sortFeaturesByY=o&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ai[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new jp(new Pl(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new jp(new Pl(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ss,this.lineVertexArray=new Es,this.symbolInstances=new Ms,this.textAnchorOffsets=new Ls}calculateGlyphDependencies(t,e,r,n,i){for(let a=0;a0)&&("constant"!==o.value.kind||o.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const f=r.iconDependencies,p=r.glyphDependencies,d=r.availableImages,m=new So(this.zoom);for(const{feature:r,id:s,index:l,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Ul(r,e);if(!i._featureFilter.filter(m,y,n))continue;let v,x;if(e||(y.geometry=jl(r)),c){const t=i.getValueAndResolveTokens("text-field",y,n,d),e=Oe.factory(t),r=this.hasRTLText=this.hasRTLText||Np(e);(!r||"unavailable"===Mo.getRTLTextPluginStatus()||r&&Mo.isParsed())&&(v=uf(e,i,y))}if(u){const t=i.getValueAndResolveTokens("icon-image",y,n,d);x=t instanceof Ne?t:Ne.fromString(t)}if(!v&&!x)continue;const _=this.sortFeaturesByKey?h.evaluate(y,{},n):void 0,b={id:s,text:v,icon:x,index:l,sourceLayerIndex:g,geometry:y.geometry,properties:r.properties,type:Op[r.type],sortKey:_};if(this.features.push(b),x&&(f[x.name]=!0),v){const e=o.evaluate(y,{},n).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ai.vertical)>=0;for(const t of v.sections)if(t.image)f[t.image.name]=!0;else{const n=fo(v.toString()),i=t.fontStack||e,a=p[i]=p[i]||{};this.calculateGlyphDependencies(t.text,a,r,this.allowVerticalPlacement,n)}}}"line"===a.get("symbol-placement")&&(this.features=hf(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])),a}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)}}}function qp(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}let Hp;no("SymbolBucket",Vp,{omit:["layers","collisionBoxArray","features","compareText"]}),Vp.MAX_GLYPHS=65535,Vp.addDynamicAttributes=Bp;const Gp=()=>Hp=Hp||new Uo({"symbol-placement":new Ro(bt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ro(bt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ro(bt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fo(bt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ro(bt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ro(bt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ro(bt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ro(bt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ro(bt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ro(bt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fo(bt.layout_symbol["icon-size"]),"icon-text-fit":new Ro(bt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ro(bt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fo(bt.layout_symbol["icon-image"]),"icon-rotate":new Fo(bt.layout_symbol["icon-rotate"]),"icon-padding":new Fo(bt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ro(bt.layout_symbol["icon-keep-upright"]),"icon-offset":new Fo(bt.layout_symbol["icon-offset"]),"icon-anchor":new Fo(bt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ro(bt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ro(bt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ro(bt.layout_symbol["text-rotation-alignment"]),"text-field":new Fo(bt.layout_symbol["text-field"]),"text-font":new Fo(bt.layout_symbol["text-font"]),"text-size":new Fo(bt.layout_symbol["text-size"]),"text-max-width":new Fo(bt.layout_symbol["text-max-width"]),"text-line-height":new Ro(bt.layout_symbol["text-line-height"]),"text-letter-spacing":new Fo(bt.layout_symbol["text-letter-spacing"]),"text-justify":new Fo(bt.layout_symbol["text-justify"]),"text-radial-offset":new Fo(bt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ro(bt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Fo(bt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Fo(bt.layout_symbol["text-anchor"]),"text-max-angle":new Ro(bt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ro(bt.layout_symbol["text-writing-mode"]),"text-rotate":new Fo(bt.layout_symbol["text-rotate"]),"text-padding":new Ro(bt.layout_symbol["text-padding"]),"text-keep-upright":new Ro(bt.layout_symbol["text-keep-upright"]),"text-transform":new Fo(bt.layout_symbol["text-transform"]),"text-offset":new Fo(bt.layout_symbol["text-offset"]),"text-allow-overlap":new Ro(bt.layout_symbol["text-allow-overlap"]),"text-overlap":new Ro(bt.layout_symbol["text-overlap"]),"text-ignore-placement":new Ro(bt.layout_symbol["text-ignore-placement"]),"text-optional":new Ro(bt.layout_symbol["text-optional"])});let Wp;const Zp=()=>Wp=Wp||new Uo({"icon-opacity":new Fo(bt.paint_symbol["icon-opacity"]),"icon-color":new Fo(bt.paint_symbol["icon-color"]),"icon-halo-color":new Fo(bt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fo(bt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fo(bt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ro(bt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ro(bt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fo(bt.paint_symbol["text-opacity"]),"text-color":new Fo(bt.paint_symbol["text-color"],{runtimeType:Gt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fo(bt.paint_symbol["text-halo-color"]),"text-halo-width":new Fo(bt.paint_symbol["text-halo-width"]),"text-halo-blur":new Fo(bt.paint_symbol["text-halo-blur"]),"text-translate":new Ro(bt.paint_symbol["text-translate"]),"text-translate-anchor":new Ro(bt.paint_symbol["text-translate-anchor"])});var Yp={get paint(){return Zp()},get layout(){return Gp()}};class Xp{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:Ut,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}no("FormatSectionOverride",Xp,{omit:["defaultValue"]});class $p extends qo{constructor(t){super(t,Yp)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["icon-rotation-alignment"]="map":this.layout._values["icon-rotation-alignment"]="viewport"),"auto"===this.layout.get("text-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="map":this.layout._values["text-rotation-alignment"]="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),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Bi(a.value)||!i?i:qp(e.properties,i)}createBucket(t){return new Vp(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Yp.paint.overridableProperties){if(!$p.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Xp(e),n=new Fi(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ji("source",n):new Ui("composite",n,e.value.zoomStops),this.paint._values[t]=new Do(e.property,i,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&$p.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Yp.paint.properties[e];let i=!1;const a=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 Oe)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{if(!i)if(e instanceof He&&Ve(e.value)===$t){const t=e.value;a(t.sections)}else e instanceof Gr?a(e.sections):e.eachChild(t)},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return i}}function Jp(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),a=i&&i.values;return[a[0]*n,a[1]*n,a[2]*n,a[3]*n]}let Kp;const Qp=()=>Kp=Kp||new Uo({"background-color":new Ro(bt.paint_background["background-color"]),"background-pattern":new No(bt.paint_background["background-pattern"]),"background-opacity":new Ro(bt.paint_background["background-opacity"])});var td={get paint(){return Qp()}};class ed extends qo{constructor(t){super(t,td)}}let rd;const nd=()=>rd=rd||new Uo({"raster-opacity":new Ro(bt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ro(bt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ro(bt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ro(bt.paint_raster["raster-brightness-max"]),"raster-saturation":new Ro(bt.paint_raster["raster-saturation"]),"raster-contrast":new Ro(bt.paint_raster["raster-contrast"]),"raster-resampling":new Ro(bt.paint_raster["raster-resampling"]),"raster-fade-duration":new Ro(bt.paint_raster["raster-fade-duration"])});var id={get paint(){return nd()}};class ad extends qo{constructor(t){super(t,id)}}function od(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e}class sd extends qo{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 ld(t){if("custom"===t.type)return new sd(t);switch(t.type){case"background":return new ed(t);case"circle":return new Fc(t);case"fill":return new Wu(t);case"fill-extrusion":return new Ah(t);case"heatmap":return new $c(t);case"hillshade":return new tu(t);case"line":return new ef(t);case"raster":return new ad(t);case"symbol":return new $p(t)}}class cd{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 ud{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new cd((()=>this.process())),this.subscription=$(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=R(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 a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:lo(t.data,a)});this.target.postMessage(o,{transfer:a})}))}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(R(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(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(co(r.error)):e.resolve(co(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=co(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i)}catch(e){this.completeTask(t,e)}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?lo(e):null,data:lo(r,n)};this.target.postMessage(i,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}}const hd=6371008.8;class fd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new fd(v(this.lng,-180,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 hd*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof fd)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new fd(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new fd(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 pd=2*Math.PI*hd;function dd(t){return pd*Math.cos(t*Math.PI/180)}function md(t){return(180+t)/360}function gd(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function yd(t,e){return t/dd(e)}function vd(t){return 360*t-180}function xd(t){const e=180-360*t;return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function _d(t,e){return t*dd(xd(e))}function bd(t){return 1/Math.cos(t*Math.PI/180)}class wd{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=fd.convert(t);return new wd(md(r.lng),gd(r.lat),yd(e,r.lat))}toLngLat(){return new fd(vd(this.x),xd(this.y))}toAltitude(){return _d(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/pd*bd(xd(this.y))}}function Td(t,e,r){var n=kd(256*t,256*(e=Math.pow(2,r)-e-1),r),i=kd(256*(t+1),256*(e+1),r);return n[0]+","+n[1]+","+i[0]+","+i[1]}function kd(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Ad{constructor(t,e,r){if(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))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=Ed(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=Td(this.x,this.y,this.z),i=Cd(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===r?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,i).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 a((t.x*e-this.x)*Rl,(t.y*e-this.y)*Rl)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Md{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Ed(t,e.z,e.z,e.x,e.y)}}class Sd{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Ad(r,+n,+i),this.key=Ed(e,t,r,n,i)}clone(){return new Sd(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 Sd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Sd(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?Ed(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ed(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 Sd(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 Sd(e,this.wrap,e,r,n),new Sd(e,this.wrap,e,r+1,n),new Sd(e,this.wrap,e,r,n+1),new Sd(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y0;a--)n=1<this.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 Yc({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,a=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:a=o-1;break;case 1:o=a+1}const s=-e*this.dim,l=-r*this.dim;for(let e=a;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 Pd{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 zd{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new eo(Rl,16,0),this.grid3D=new eo(Rl,16,0),this.featureIndexArray=new Ps,this.promoteId=e}insert(t,e,r,n,i,a){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const s=a?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&s.insert(o,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ku.VectorTile(new Gf(this.rawTileData)).layers,this.sourceLayerCoder=new Id(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},a=Rl/t.tileSize/t.scale,o=Ji(i.filter),s=t.queryGeometry,l=t.queryPadding*a,c=Od(s),u=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),h=Od(t.cameraQueryGeometry),f=this.grid3D.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l,((e,r,n,i)=>ec(t.cameraQueryGeometry,e-l,r-l,n+l,i+l)));for(const t of f)u.push(t);u.sort(Rd);const p={};let d;for(let l=0;l(f||(f=jl(e)),r.queryIntersectsFeature(s,e,n,f,this.z,t.transform,a,t.pixelPosMatrix))))}return p}loadMatchingFeature(t,e,r,n,i,a,o,s,l,c,u){const h=this.bucketLayerIDs[e];if(a&&!L(a,h))return;const f=this.sourceLayerCoder.decode(r),p=this.vtLayers[f].feature(n);if(i.needGeometry){const t=Ul(p,!0);if(!i.filter(new So(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new So(this.tileID.overscaledZ),p))return;const d=this.getId(p,f);for(let e=0;e{const o=e instanceof Oo?e.get(a):null;return o&&o.evaluate?o.evaluate(r,n,i):o}))}function Od(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);return{minX:e,minY:r,maxX:n,maxY:i}}function Rd(t,e){return e-t}function Fd(t,e,r,n,i){const o=[];for(let s=0;s=n&&u.x>=n||(s.x>=n?s=new a(n,s.y+(u.y-s.y)*((n-s.x)/(u.x-s.x)))._round():u.x>=n&&(u=new a(n,s.y+(u.y-s.y)*((n-s.x)/(u.x-s.x)))._round()),s.y>=i&&u.y>=i||(s.y>=i?s=new a(s.x+(u.x-s.x)*((i-s.y)/(u.y-s.y)),i)._round():u.y>=i&&(u=new a(s.x+(u.x-s.x)*((i-s.y)/(u.y-s.y)),i)._round()),c&&s.equals(c[c.length-1])||(c=[s],o.push(c)),c.push(u)))))}}return o}no("FeatureIndex",zd,{omit:["rawTileData","sourceLayerCoder"]});class Bd extends a{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new Bd(this.x,this.y,this.angle,this.segment)}}function Nd(t,e,r,n,i){if(void 0===e.segment||0===r)return!0;let a=e,o=e.segment+1,s=0;for(;s>-r/2;){if(o--,o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;const l=[];let c=0;for(;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=r.dist(a)}return!0}function jd(t){let e=0;for(let r=0;rc){const u=(c-l)/a,h=xr.number(n.x,i.x,u),f=xr.number(n.y,i.y,u),p=new Bd(h,f,i.angleTo(n),r);return p._round(),!o||Nd(t,p,s,o,e)?p:void 0}l+=a}}function Hd(t,e,r,n,i,a,o,s,l){const c=Ud(n,a,o),u=Vd(n,i),h=u*o,f=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&y=0&&v=0&&f+c<=u){const r=new Bd(y,v,m,e);r._round(),n&&!Nd(t,r,a,n,i)||p.push(r)}}h+=d}return s||p.length||o||(p=Gd(t,h/2,r,n,i,a,o,!0,l)),p}no("Anchor",Bd);const Wd=Qf;function Zd(t,e,r,n){const i=[],o=t.image,s=o.pixelRatio,l=o.paddedRect.w-2*Wd,c=o.paddedRect.h-2*Wd;let u={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=o.stretchX||[[0,l]],f=o.stretchY||[[0,c]],p=(t,e)=>t+e[1]-e[0],d=h.reduce(p,0),m=f.reduce(p,0),g=l-d,y=c-m;let v=0,x=d,_=0,b=m,w=0,T=g,k=0,A=y;if(o.content&&n){const e=o.content,r=e[2]-e[0],n=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(u=Mp(t)),v=Yd(h,0,e[0]),_=Yd(f,0,e[1]),x=Yd(h,e[0],e[2]),b=Yd(f,e[1],e[3]),w=e[0]-v,k=e[1]-_,T=r-x,A=n-b}const M=u.x1,S=u.y1,E=u.x2-M,C=u.y2-S,L=(t,n,i,l)=>{const c=$d(t.stretch-v,x,E,M),u=Jd(t.fixed-w,T,t.stretch,d),h=$d(n.stretch-_,b,C,S),f=Jd(n.fixed-k,A,n.stretch,m),p=$d(i.stretch-v,x,E,M),g=Jd(i.fixed-w,T,i.stretch,d),y=$d(l.stretch-_,b,C,S),L=Jd(l.fixed-k,A,l.stretch,m),I=new a(c,h),P=new a(p,h),z=new a(p,y),D=new a(c,y),O=new a(u/s,f/s),R=new a(g/s,L/s),F=e*Math.PI/180;if(F){const t=Math.sin(F),e=Math.cos(F),r=[e,-t,t,e];I._matMult(r),P._matMult(r),D._matMult(r),z._matMult(r)}const B=t.stretch+t.fixed,N=i.stretch+i.fixed,j=n.stretch+n.fixed,U=l.stretch+l.fixed;return{tl:I,tr:P,bl:D,br:z,tex:{x:o.paddedRect.x+Wd+B,y:o.paddedRect.y+Wd+j,w:N-B,h:U-j},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:O,pixelOffsetBR:R,minFontScaleX:T/s/E,minFontScaleY:A/s/C,isSDF:r}};if(n&&(o.stretchX||o.stretchY)){const t=Xd(h,g,d),e=Xd(f,y,m);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=o.image)||void 0===h?void 0:h.content)&&(o.image.textFitWidth||o.image.textFitHeight)?Mp(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};c.y1=c.y1*s-l[0],c.y2=c.y2*s+l[2],c.x1=c.x1*s-l[3],c.x2=c.x2*s+l[1];const f=o.collisionPadding;if(f&&(c.x1-=f[0]*s,c.y1-=f[1]*s,c.x2+=f[2]*s,c.y2+=f[3]*s),u){const t=new a(c.x1,c.y1),e=new a(c.x2,c.y1),r=new a(c.x1,c.y2),n=new a(c.x2,c.y2),i=u*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),c.x1=Math.min(t.x,e.x,r.x,n.x),c.x2=Math.max(t.x,e.x,r.x,n.x),c.y1=Math.min(t.y,e.y,r.y,n.y),c.y2=Math.max(t.y,e.y,r.y,n.y)}t.emplaceBack(e.x,e.y,c.x1,c.y1,c.x2,c.y2,r,n,i)}this.boxEndIndex=t.length}}class tm{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,a=e[i];if(r(n,a)>=0)break;e[t]=a,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 em(t,e=1,r=!1){let n=1/0,i=1/0,o=-1/0,s=-1/0;const l=t[0];for(let t=0;to)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const c=o-n,u=s-i,h=Math.min(c,u);let f=h/2;const p=new tm([],rm);if(0===h)return new a(n,i);for(let e=n;ed.d||!d.d)&&(d=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,m)),n.max-d.d<=e||(f=n.h/2,p.push(new nm(n.p.x-f,n.p.y-f,f,t)),p.push(new nm(n.p.x+f,n.p.y-f,f,t)),p.push(new nm(n.p.x-f,n.p.y+f,f,t)),p.push(new nm(n.p.x+f,n.p.y+f,f,t)),m+=4)}return r&&(console.log(`num probes: ${m}`),console.log(`best distance: ${d.d}`)),d.p}function rm(t,e){return e.max-t.max}function nm(t,e,r,n){this.p=new a(t,e),this.h=r,this.d=im(this.p,n),this.max=this.d+this.h*Math.SQRT2}function im(t,e){let r=!1,n=1/0;for(let i=0;it.y!=s.y>t.y&&t.x<(s.x-i.x)*(t.y-i.y)/(s.y-i.y)+i.x&&(r=!r),n=Math.min(n,Kl(t,i,s))}}return(r?1:-1)*Math.sqrt(n)}function am(t){let e=0,r=0,n=0;const i=t[0];for(let t=0,a=i.length,o=a-1;tt*df));n.startsWith("top")?i[1]-=sm:n.startsWith("bottom")&&(i[1]+=sm),e[r+1]=i}return new Be(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)*df,lm]:i.get("text-offset").evaluate(e,{},r).map((t=>t*df));const a=[];for(const t of o)a.push(t,cm(t,n));return new Be(a)}return null}function hm(e){e.bucket.createArrays();const r=512*e.bucket.overscaling;e.bucket.tilePixelRatio=Rl/r,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const n=e.bucket.layers[0],i=n.layout,a=n._unevaluatedLayout._values,o={layoutIconSize:a["icon-size"].possiblyEvaluate(new So(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new So(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new So(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.textSizeData;o.compositeTextSizes=[a["text-size"].possiblyEvaluate(new So(t),e.canonical),a["text-size"].possiblyEvaluate(new So(r),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.iconSizeData;o.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new So(t),e.canonical),a["icon-size"].possiblyEvaluate(new So(r),e.canonical)]}const s=i.get("text-line-height")*df,l="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement"),c=i.get("text-keep-upright"),u=i.get("text-size");for(const r of e.bucket.features){const a=i.get("text-font").evaluate(r,{},e.canonical).join(","),h=u.evaluate(r,{},e.canonical),f=o.layoutTextSize.evaluate(r,{},e.canonical),p=o.layoutIconSize.evaluate(r,{},e.canonical),d={horizontal:{},vertical:void 0},m=r.text;let g,y=[0,0];if(m){const o=m.toString(),u=i.get("text-letter-spacing").evaluate(r,{},e.canonical)*df,p=po(o)?u:0,g=i.get("text-anchor").evaluate(r,{},e.canonical),v=um(n,r,e.canonical);if(!v){const t=i.get("text-radial-offset").evaluate(r,{},e.canonical);y=t?cm(g,[t*df,lm]):i.get("text-offset").evaluate(r,{},e.canonical).map((t=>t*df))}let x=l?"center":i.get("text-justify").evaluate(r,{},e.canonical);const _="point"===i.get("symbol-placement")?i.get("text-max-width").evaluate(r,{},e.canonical)*df:1/0,b=()=>{e.bucket.allowVerticalPlacement&&fo(o)&&(d.vertical=up(m,e.glyphMap,e.glyphPositions,e.imagePositions,a,_,s,g,"left",p,y,t.ai.vertical,!0,f,h))};if(!l&&v){const r=new Set;if("auto"===x)for(let t=0;t{h.x<0||h.x>=Rl||h.y<0||h.y>=Rl||ym(t,h,s,r,n,i,C,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,[b,b,b,b],k,l,x,w,A,p,e,a,c,u,o)};if("line"===M)for(const i of Fd(e.geometry,0,0,Rl,Rl)){const e=Hd(i,_,T,r.vertical||d,n,m,v,t.overscaling,Rl);for(const r of e)d&&vm(t,d.text,S,r)||L(i,r)}else if("line-center"===M){for(const t of e.geometry)if(t.length>1){const e=qd(t,T,r.vertical||d,n,m,v);e&&L(t,e)}}else if("Polygon"===e.type)for(const t of Cn(e.geometry,0)){const e=em(t,16);L(t[0],new Bd(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)L(t,new Bd(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)L([e],new Bd(e.x,e.y,0))}function dm(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;rLp&&P(`${t.layerIds[0]}: Value for "text-size" is >= ${Ep}. Reduce your "text-size".`)):"composite"===g.kind&&(y=[Cp*p.compositeTextSizes[0].evaluate(o,{},d),Cp*p.compositeTextSizes[1].evaluate(o,{},d)],(y[0]>Lp||y[1]>Lp)&&P(`${t.layerIds[0]}: Value for "text-size" is >= ${Ep}. Reduce your "text-size".`)),t.addSymbols(t.text,m,y,s,a,o,c,e,l.lineStartIndex,l.lineLength,f,d);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function gm(t){for(const e in t)return t[e];return null}function ym(e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x,_,b,w,T,k,A){const M=e.addToLineVertexArray(r,n);let S,E,C,L,I=0,z=0,D=0,O=0,R=-1,F=-1;const B={};let N=hl("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},k)+90,e=i.vertical;C=new Qd(c,r,u,h,f,e,p,d,m,t),s&&(L=new Qd(c,r,u,h,f,s,y,v,m,t))}if(a){const n=l.layout.get("icon-rotate").evaluate(b,{}),i="none"!==l.layout.get("icon-text-fit"),o=Zd(a,n,T,i),p=s?Zd(s,n,T,i):void 0;E=new Qd(c,r,u,h,f,a,y,v,!1,n),I=4*o.length;const d=e.iconSizeData;let m=null;"source"===d.kind?(m=[Cp*l.layout.get("icon-size").evaluate(b,{})],m[0]>Lp&&P(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ep}. Reduce your "icon-size".`)):"composite"===d.kind&&(m=[Cp*w.compositeIconSizes[0].evaluate(b,{},k),Cp*w.compositeIconSizes[1].evaluate(b,{},k)],(m[0]>Lp||m[1]>Lp)&&P(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ep}. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,m,_,x,b,t.ai.none,r,M.lineStartIndex,M.lineLength,-1,k),R=e.icon.placedSymbolArray.length-1,p&&(z=4*p.length,e.addSymbols(e.icon,p,m,_,x,b,t.ai.vertical,r,M.lineStartIndex,M.lineLength,-1,k),F=e.icon.placedSymbolArray.length-1)}const j=Object.keys(i.horizontal);for(const n of j){const a=i.horizontal[n];if(!S){N=hl(a.text);const t=l.layout.get("text-rotate").evaluate(b,{},k);S=new Qd(c,r,u,h,f,a,p,d,m,t)}const s=1===a.positionedLines.length;if(D+=mm(e,r,a,o,l,m,b,g,M,i.vertical?t.ai.horizontal:t.ai.horizontalOnly,s?j:[n],B,R,w,k),s)break}i.vertical&&(O+=mm(e,r,i.vertical,o,l,m,b,g,M,t.ai.vertical,["vertical"],B,F,w,k));const U=S?S.boxStartIndex:e.collisionBoxArray.length,V=S?S.boxEndIndex:e.collisionBoxArray.length,q=C?C.boxStartIndex:e.collisionBoxArray.length,H=C?C.boxEndIndex:e.collisionBoxArray.length,G=E?E.boxStartIndex:e.collisionBoxArray.length,W=E?E.boxEndIndex:e.collisionBoxArray.length,Z=L?L.boxStartIndex:e.collisionBoxArray.length,Y=L?L.boxEndIndex:e.collisionBoxArray.length;let X=-1;const $=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=$(S,X),X=$(C,X),X=$(E,X),X=$(L,X);const J=X>-1?1:0;J&&(X*=A/df),e.glyphOffsetArray.length>=Vp.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const K=um(l,b,k),[Q,tt]=dm(e.textAnchorOffsets,K);e.symbolInstances.emplaceBack(r.x,r.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,R,F,N,U,V,q,H,G,W,Z,Y,u,D,O,I,z,J,0,p,X,Q,tt)}function vm(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])>4;if(n!==_m)throw new Error(`Got v${n} data when expected v${_m}.`);const i=xm[15&r];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new wm(o,a,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=xm.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,s=(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,bm,t),this.coords=new this.ArrayType(this.data,bm+o+s,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(bm+a+o+s),this.ids=new this.IndexArrayType(this.data,bm,t),this.coords=new this.ArrayType(this.data,bm+o+s,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(_m<<4)+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 Tm(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:a,nodeSize:o}=this,s=[0,i.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let o=h;o<=u;o++){const s=a[2*o],c=a[2*o+1];s>=t&&s<=r&&c>=e&&c<=n&&l.push(i[o])}continue}const f=h+u>>1,p=a[2*f],d=a[2*f+1];p>=t&&p<=r&&d>=e&&d<=n&&l.push(i[f]),(0===c?t<=p:e<=d)&&(s.push(h),s.push(f-1),s.push(1-c)),(0===c?r>=p:n>=d)&&(s.push(f+1),s.push(u),s.push(1-c))}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:a}=this,o=[0,n.length-1,0],s=[],l=r*r;for(;o.length;){const c=o.pop()||0,u=o.pop()||0,h=o.pop()||0;if(u-h<=a){for(let r=h;r<=u;r++)Sm(i[2*r],i[2*r+1],t,e)<=l&&s.push(n[r]);continue}const f=h+u>>1,p=i[2*f],d=i[2*f+1];Sm(p,d,t,e)<=l&&s.push(n[f]),(0===c?t-r<=p:e-r<=d)&&(o.push(h),o.push(f-1),o.push(1-c)),(0===c?t+r>=p:e+r>=d)&&(o.push(f+1),o.push(u),o.push(1-c))}return s}}function Tm(t,e,r,n,i,a){if(i-n<=r)return;const o=n+i>>1;km(t,e,o,n,i,a),Tm(t,e,r,n,o-1,1-a),Tm(t,e,r,o+1,i,1-a)}function km(t,e,r,n,i,a){for(;i>n;){if(i-n>600){const o=i-n+1,s=r-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);km(t,e,r,Math.max(n,Math.floor(r-s*c/o+u)),Math.min(i,Math.floor(r+(o-s)*c/o+u)),a)}const o=e[2*r+a];let s=n,l=i;for(Am(t,e,n,r),e[2*i+a]>o&&Am(t,e,n,i);so;)l--}e[2*n+a]===o?Am(t,e,n,l):(l++,Am(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function Am(t,e,r,n){Mm(t,r,n),Mm(e,2*r,2*n),Mm(e,2*r+1,2*n+1)}function Mm(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function Sm(t,e,r,n){const i=t-r,a=e-n;return i*i+a*a}var Em;t.bf=void 0,(Em=t.bf||(t.bf={})).create="create",Em.load="load",Em.fullLoad="fullLoad";let Cm=null,Lm=[];const Im=1e3/60,Pm="loadTime",zm="fullLoadTime",Dm={mark(t){performance.mark(t)},frame(t){const e=t;if(null!=Cm){const t=e-Cm;Lm.push(t)}Cm=e},clearMetrics(){Cm=null,Lm=[],performance.clearMeasures(Pm),performance.clearMeasures(zm);for(const e in t.bf)performance.clearMarks(t.bf[e])},getPerformanceMetrics(){performance.measure(Pm,t.bf.create,t.bf.load),performance.measure(zm,t.bf.create,t.bf.fullLoad);const e=performance.getEntriesByName(Pm)[0].duration,r=performance.getEntriesByName(zm)[0].duration,n=Lm.length,i=1/(Lm.reduce(((t,e)=>t+e),0)/n/1e3),a=Lm.filter((t=>t>Im)).reduce(((t,e)=>t+(e-Im)/Im),0);return{loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:a/(n+a)*100,totalFrames:n}}};class Om{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}}t.$=Os,t.A=pc,t.B=$a,t.C=N,t.D=Ro,t.E=_t,t.F=ud,t.G=at,t.H=dc,t.I=tp,t.J=_c,t.K=bc,t.L=xc,t.M=b,t.N=fd,t.O=md,t.P=a,t.Q=gd,t.R=Yc,t.S=Sd,t.T=Lo,t.U=h,t.V=f,t.W=G,t.X=Rl,t.Y=Xo,t.Z=wd,t._=e,t.a=et,t.a$=Lc,t.a0=rl,t.a1=Ad,t.a2=Ft,t.a3=mt,t.a4=T,t.a5=ws,t.a6=Vp,t.a7=Ji,t.a8=Ul,t.a9=So,t.aA=kt,t.aB=ld,t.aC=C,t.aD=Rt,t.aE=od,t.aF=E,t.aG=M,t.aH=S,t.aI=yl,t.aJ=vl,t.aK=kl,t.aL=bl,t.aM=wl,t.aN=Pe,t.aO=_l,t.aP=xl,t.aQ=Ec,t.aR=Ic,t.aS=Ws,t.aT=lf,t.aU=Ys,t.aV=A,t.aW=Xc,t.aX=zs,t.aY=Xs,t.aZ=Js,t.a_=Cc,t.aa=Pd,t.ab=F,t.ac=x,t.ad=y,t.ae=Tc,t.af=mc,t.ag=Oc,t.ah=zp,t.aj=Pp,t.ak=Bp,t.al=D,t.am=Fd,t.an=Hl,t.ao=yc,t.ap=p,t.aq=df,t.as=Dp,t.at=vc,t.au=fm,t.av=bp,t.aw=wm,t.ax=ca,t.ay=uo,t.az=st,t.b=j,t.b0=gc,t.b1=Rc,t.b2=Dc,t.b3=v,t.b4=Md,t.b5=yd,t.b6=Mc,t.b7=wc,t.b8=m,t.b9=g,t.bA=Q,t.bB=Ni,t.bC=Mo,t.ba=J,t.bb=kc,t.bc=Ds,t.bd=hd,t.be=Dm,t.bg=ot,t.bh=nt,t.bi=it,t.bj=la,t.bk=no,t.bl=Id,t.bm=zd,t.bn=ep,t.bo=hm,t.bp=Zh,t.bq=ju,t.br=xh,t.bs=Ku,t.bt=Gf,t.bu=Om,t.bv=X,t.bw=Ld,t.bx=r,t.by=n,t.bz=gf,t.c=tt,t.d=U,t.e=_,t.f=q,t.g=rt,t.h=ft,t.i=R,t.j=xt,t.k=vt,t.l=pt,t.m=ht,t.n=$f,t.o=Zc,t.p=Kf,t.q=Uo,t.r=Xa,t.s=dt,t.t=Qa,t.u=ho,t.v=bt,t.w=P,t.x=Ya,t.y=O,t.z=xr})),r("worker",["./shared"],(function(t){class e{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const r of e){this._layerConfigs[r.id]=r;const e=this._layers[r.id]=t.aB(r);e._featureFilter=t.a7(e.filter),this.keyCache[r.id]&&delete this.keyCache[r.id]}for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=t.bj(Object.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._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 a=r.sourceLayer||"_geojsonTileLayer";let o=i[a];o||(o=i[a]=[]),o.push(e)}}}const r=1;class n{constructor(e){const n={},i=[];for(const t in e){const a=e[t],o=n[t]={};for(const t in a){const e=a[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(n),o[t]={rect:n,metrics:e.metrics}}}const{w:a,h:o}=t.p(i),s=new t.o({width:a||1,height:o||1});for(const i in e){const a=e[i];for(const e in a){const o=a[+e];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const l=n[i][e].rect;t.o.copy(o.bitmap,s,{x:0,y:0},{x:l.x+r,y:l.y+r},o.bitmap)}}this.image=s,this.positions=n}}t.bk("GlyphAtlas",n);class i{constructor(e){this.tileID=new t.S(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,r,i,o){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.a5;const s=new t.bl(Object.keys(e.layers).sort()),l=new t.bm(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:i},h=r.familiesBySource[this.source];for(const r in h){const n=e.layers[r];if(!n)continue;1===n.version&&t.w(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=s.encode(r),f=[];for(let t=0;t=r.maxzoom||"none"!==r.visibility&&(a(e,this.zoom,i),(c[r.id]=r.createBucket({index:l.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(f,u,this.tileID.canonical),l.bucketLayerIDs.push(e.map((t=>t.id))))}}const f=t.aG(u.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(f).length){const t=new AbortController;this.inFlightDependencies.push(t),p=o.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const d=Object.keys(u.iconDependencies);let m=Promise.resolve({});if(d.length){const t=new AbortController;this.inFlightDependencies.push(t),m=o.sendAsync({type:"GI",data:{icons:d,source:this.source,tileID:this.tileID,type:"icons"}},t)}const g=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(g.length){const t=new AbortController;this.inFlightDependencies.push(t),y=o.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[v,x,_]=yield Promise.all([p,m,y]),b=new n(v),w=new t.bn(x,_);for(const e in c){const r=c[e];r instanceof t.a6?(a(r.layers,this.zoom,i),t.bo({bucket:r,glyphMap:v,glyphPositions:b.positions,imageMap:x,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):r.hasPattern&&(r instanceof t.bp||r instanceof t.bq||r instanceof t.br)&&(a(r.layers,this.zoom,i),r.addFeatures(u,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(c).filter((t=>!t.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?v:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function a(e,r,n){const i=new t.a9(r);for(const t of e)t.recalculate(i,n)}class o{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 n=yield t.l(e.request,r);try{return{vectorTile:new t.bs.VectorTile(new t.bt(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires}}catch(t){const r=new Uint8Array(n.data),i=31===r[0]&&139===r[1];let a=`Unable to parse the tile at ${e.request.url}, `;throw a+=i?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.message}`,new Error(a)}}))}loadTile(e){return t._(this,void 0,void 0,(function*(){const r=e.uid,n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bu(e.request),a=new i(e);this.loading[r]=a;const o=new AbortController;a.abort=o;try{const i=yield this.loadVectorTile(e,o);if(delete this.loading[r],!i)return null;const s=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}a.vectorTile=i.vectorTile;const u=a.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[r]=a,this.fetching[r]={rawTileData:s,cacheControl:l,resourceTiming:c};try{const e=yield u;return t.e({rawTileData:s.slice(0)},e,l,c)}finally{delete this.fetching[r]}}catch(t){throw delete this.loading[r],a.status="done",this.loaded[r]=a,t}}))}reloadTile(e){return t._(this,void 0,void 0,(function*(){const r=e.uid;if(!this.loaded||!this.loaded[r])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[r];if(n.showCollisionBoxes=e.showCollisionBoxes,"parsing"===n.status){const e=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor);let i;if(this.fetching[r]){const{rawTileData:n,cacheControl:a,resourceTiming:o}=this.fetching[r];delete this.fetching[r],i=t.e({rawTileData:n.slice(0)},e,a,o)}else i=e;return i}if("done"===n.status&&n.vectorTile)return n.parse(n.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 s{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:r,encoding:n,rawImageData:i,redFactor:a,greenFactor:o,blueFactor:s,baseShift:l}=e,c=i.width+2,u=i.height+2,h=t.b(i)?new t.R({width:c,height:u},yield t.bv(i,-1,-1,c,u)):i,f=new t.bw(r,h,n,a,o,s,l);return this.loaded=this.loaded||{},this.loaded[r]=f,f}))}removeTile(t){const e=this.loaded,r=t.uid;e&&e[r]&&delete e[r]}}var l=c;function c(t,e){var r,n=t&&t.type;if("FeatureCollection"===n)for(r=0;r=Math.abs(s)?r-l+s:s-l+r,r=l}r+n>=0!=!!e&&t.reverse()}var f=t.bx(l);const p=t.bs.VectorTileFeature.prototype.toGeoJSON;let d=class{constructor(e){this._feature=e,this.extent=t.X,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const r of this._feature.geometry)e.push([new t.P(r[0],r[1])]);return e}{const e=[];for(const r of this._feature.geometry){const n=[];for(const e of r)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,r){return p.call(this,t,e,r)}},m=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.X,this.length=e.length,this._features=e}feature(t){return new d(this._features[t])}};var g={exports:{}},y=t.by,v=t.bs.VectorTileFeature,x=_;function _(t,e){this.options=e||{},this.features=t,this.length=t.length}function b(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}_.prototype.feature=function(t){return new b(this.features[t],this.options.extent)},b.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e>31}function P(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,a=0,o=r.length,s=0;st},F=Math.fround||(B=new Float32Array(1),t=>(B[0]=+t,B[0]));var B;const N=2,j=3,U=4,V=5,q=6;class H{constructor(t){this.options=Object.assign(Object.create(R),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 a=[];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 a=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,a],e),o=this.getClusters([-180,n,i,a],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],s=o.range(Z(r),Y(a),Z(i),Y(n)),l=o.data,c=[];for(const t of s){const e=this.stride*t;c.push(l[e+V]>1?G(l,e,this.clusterProps):this.points[l[e+j]])}return c}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 a=i.data;if(e*this.stride>=a.length)throw new Error(n);const o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),s=a[e*this.stride],l=a[e*this.stride+1],c=i.within(s,l,o),u=[];for(const e of c){const r=e*this.stride;a[r+U]===t&&u.push(a[r+V]>1?G(a,r,this.clusterProps):this.points[a[r+j]])}if(0===u.length)throw new Error(n);return u}getLeaves(t,e,r){e=e||10,r=r||0;const n=[];return this._appendLeaves(n,t,e,r,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],i=Math.pow(2,t),{extent:a,radius:o}=this.options,s=o/a,l=(r-s)/i,c=(r+1+s)/i,u={features:[]};return this._addTileFeatures(n.range((e-s)/i,l,(e+1+s)/i,c),n.data,e,r,i,u),0===e&&this._addTileFeatures(n.range(1-s/i,l,1,c),n.data,i,r,i,u),e===i-1&&this._addTileFeatures(n.range(0,l,s/i,c),n.data,-1,r,i,u),u.features.length?u: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 a=this.getChildren(e);for(const e of a){const a=e.properties;if(a&&a.cluster?i+a.point_count<=n?i+=a.point_count:i=this._appendLeaves(t,a.cluster_id,r,n,i):i1;let l,c,u;if(s)l=W(e,t,this.clusterProps),c=e[t],u=e[t+1];else{const r=this.points[e[t+j]];l=r.properties;const[n,i]=r.geometry.coordinates;c=Z(n),u=Y(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*i-r)),Math.round(this.options.extent*(u*i-n))]],tags:l};let f;f=s||this.options.generateId?e[t+j]:this.points[e[t+j]].id,void 0!==f&&(h.id=f),a.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:a}=this.options,o=r/(n*Math.pow(2,e)),s=t.data,l=[],c=this.stride;for(let r=0;re&&(p+=s[r+V])}if(p>f&&p>=a){let t,a=n*f,o=u*f,d=-1;const m=(r/c<<5)+(e+1)+this.points.length;for(const n of h){const l=n*c;if(s[l+N]<=e)continue;s[l+N]=e;const u=s[l+V];a+=s[l]*u,o+=s[l+1]*u,s[l+U]=m,i&&(t||(t=this._map(s,r,!0),d=this.clusterProps.length,this.clusterProps.push(t)),i(t,this._map(s,l)))}s[r+U]=m,l.push(a/p,o/p,1/0,m,-1,p),i&&l.push(d)}else{for(let t=0;t1)for(const t of h){const r=t*c;if(!(s[r+N]<=e)){s[r+N]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+V]>1){const n=this.clusterProps[t[e+q]];return r?Object.assign({},n):n}const n=this.points[t[e+j]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function G(t,e,r){return{type:"Feature",id:t[e+j],properties:W(t,e,r),geometry:{type:"Point",coordinates:[X(t[e]),$(t[e+1])]}}}function W(t,e,r){const n=t[e+V],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,a=t[e+q],o=-1===a?{}:Object.assign({},r[a]);return Object.assign(o,{cluster:!0,cluster_id:t[e+j],point_count:n,point_count_abbreviated:i})}function Z(t){return t/360+.5}function Y(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 X(t){return 360*(t-.5)}function $(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function J(t,e,r,n){let i=n;const a=e+(r-e>>1);let o,s=r-e;const l=t[e],c=t[e+1],u=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-a);tn&&(o-e>3&&J(t,e,o,n),t[o+2]=i,r-o>3&&J(t,o,r,n))}function K(t,e,r,n,i,a){let o=i-r,s=a-n;if(0!==o||0!==s){const l=((t-r)*o+(e-n)*s)/(o*o+s*s);l>1?(r=i,n=a):l>0&&(r+=o*l,n+=s*l)}return o=t-r,s=e-n,o*o+s*s}function Q(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)tt(i,r);else if("Polygon"===e)tt(i,r[0]);else if("MultiLineString"===e)for(const t of r)tt(i,t);else if("MultiPolygon"===e)for(const t of r)tt(i,t[0]);return i}function tt(t,e){for(let r=0;r0&&(o+=n?(i*l-s*a)/2:Math.sqrt(Math.pow(s-i,2)+Math.pow(l-a,2))),i=s,a=l}const s=e.length-3;e[2]=1,J(e,0,s,r),e[s+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function at(t,e,r,n){for(let i=0;i1?1:r}function lt(t,e,r,n,i,a,o,s){if(n/=e,a>=(r/=e)&&o=n)return null;const l=[];for(const e of t){const t=e.geometry;let a=e.type;const o=0===i?e.minX:e.minY,c=0===i?e.maxX:e.maxY;if(o>=r&&c=n)continue;let u=[];if("Point"===a||"MultiPoint"===a)ct(t,u,r,n,i);else if("LineString"===a)ut(t,u,r,n,i,!1,s.lineMetrics);else if("MultiLineString"===a)ft(t,u,r,n,i,!1);else if("Polygon"===a)ft(t,u,r,n,i,!0);else if("MultiPolygon"===a)for(const e of t){const t=[];ft(e,t,r,n,i,!0),t.length&&u.push(t)}if(u.length){if(s.lineMetrics&&"LineString"===a){for(const t of u)l.push(Q(e.id,a,t,e.tags));continue}"LineString"!==a&&"MultiLineString"!==a||(1===u.length?(a="LineString",u=u[0]):a="MultiLineString"),"Point"!==a&&"MultiPoint"!==a||(a=3===u.length?"Point":"MultiPoint"),l.push(Q(e.id,a,u,e.tags))}}return l.length?l:null}function ct(t,e,r,n,i){for(let a=0;a=r&&o<=n&&pt(e,t[a],t[a+1],t[a+2])}}function ut(t,e,r,n,i,a,o){let s=ht(t);const l=0===i?dt:mt;let c,u,h=t.start;for(let f=0;fr&&(u=l(s,p,d,g,y,r),o&&(s.start=h+c*u)):v>n?x=r&&(u=l(s,p,d,g,y,r),_=!0),x>n&&v<=n&&(u=l(s,p,d,g,y,n),_=!0),!a&&_&&(o&&(s.end=h+c*u),e.push(s),s=ht(t)),o&&(h+=c)}let f=t.length-3;const p=t[f],d=t[f+1],m=t[f+2],g=0===i?p:d;g>=r&&g<=n&&pt(s,p,d,m),f=s.length-3,a&&f>=3&&(s[f]!==s[0]||s[f+1]!==s[1])&&pt(s,s[0],s[1],s[2]),s.length&&e.push(s)}function ht(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function ft(t,e,r,n,i,a){for(const o of t)ut(o,e,r,n,i,a,!1)}function pt(t,e,r,n){t.push(e,r,n)}function dt(t,e,r,n,i,a){const o=(a-e)/(n-e);return pt(t,a,r+(i-r)*o,1),o}function mt(t,e,r,n,i,a){const o=(a-r)/(i-r);return pt(t,e+(n-e)*o,a,1),o}function gt(t,e){const r=e.buffer/e.extent;let n=t;const i=lt(t,1,-1-r,r,0,-1,2,e),a=lt(t,1,1-r,2+r,0,-1,2,e);return(i||a)&&(n=lt(t,1,-r,1+r,0,-1,2,e)||[],i&&(n=yt(i,1).concat(n)),a&&(n=n.concat(yt(a,-1)))),n}function yt(t,e){const r=[];for(let n=0;n0&&e.size<(i?o:n))return void(r.numPoints+=e.length/3);const s=[];for(let t=0;to)&&(r.numSimplified++,s.push(e[t],e[t+1])),r.numPoints++;i&&kt(s,a),t.push(s)}function kt(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=et(t,e);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),n=gt(n,e),n.length&&this.splitTile(n,0,0,0),r&&(n.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,r,n,i,a,o){const s=[t,e,r,n],l=this.options,c=l.debug;for(;s.length;){n=s.pop(),r=s.pop(),e=s.pop(),t=s.pop();const u=1<1&&console.time("creation"),f=this.tiles[h]=bt(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==i){if(e===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(r!==a>>t||n!==o>>t)continue}}if(f.source=null,0===t.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,d=.5-p,m=.5+p,g=1+p;let y=null,v=null,x=null,_=null,b=lt(t,u,r-p,r+m,0,f.minX,f.maxX,l),w=lt(t,u,r+d,r+g,0,f.minX,f.maxX,l);t=null,b&&(y=lt(b,u,n-p,n+m,1,f.minY,f.maxY,l),v=lt(b,u,n+d,n+g,1,f.minY,f.maxY,l),b=null),w&&(x=lt(w,u,n-p,n+m,1,f.minY,f.maxY,l),_=lt(w,u,n+d,n+g,1,f.minY,f.maxY,l),w=null),c>1&&console.timeEnd("clipping"),s.push(y||[],e+1,2*r,2*n),s.push(v||[],e+1,2*r,2*n+1),s.push(x||[],e+1,2*r+1,2*n),s.push(_||[],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:a}=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,c=t,u=e,h=r;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[St(c,u,h)];return l&&l.source?(a>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?xt(this.tiles[s],i):null):null}}function St(t,e,r){return 32*((1<0||(null===(i=r.addOrUpdateProperties)||void 0===i?void 0:i.length)>0);if((s||l)&&(e=Object.assign({},e),t.set(r.id,e),l&&(e.properties=Object.assign({},e.properties))),r.newGeometry&&(e.geometry=r.newGeometry),r.removeAllProperties)e.properties={};else if((null===(a=r.removeProperties)||void 0===a?void 0:a.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}}class Dt extends o{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(e,r){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const r=this._geoJSONIndex.getTile(t.z,t.x,t.y);if(!r)return null;const n=new m(r.features);let i=O(n);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:n,rawData:i.buffer}}))}loadData(e){return t._(this,void 0,void 0,(function*(){var r;null===(r=this._pendingRequest)||void 0===r||r.abort();const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bu(e.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest),this._geoJSONIndex=e.cluster?new H(Ot(e)).load((yield this._pendingData).features):Ct(yield this._pendingData,e.geojsonVtOptions),this.loaded={};const t={};if(n){const r=n.finish();r&&(t.resourceTiming={},t.resourceTiming[e.source]=JSON.parse(JSON.stringify(r)))}return t}catch(e){if(delete this._pendingRequest,t.bA(e))return{abandoned:!0};throw e}}))}getData(){return t._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded,r=t.uid;return e&&e[r]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,r){return t._(this,void 0,void 0,(function*(){let n=yield this.loadGeoJSON(e,r);if(delete this._pendingRequest,"object"!=typeof n)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(f(n,!0),e.filter){const r=t.bB(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 i=n.features.filter((t=>r.value.evaluate({zoom:0},t)));n={type:"FeatureCollection",features:i}}return n}))}loadGeoJSON(e,r){return t._(this,void 0,void 0,(function*(){const{promoteId:n}=e;if(e.request){const i=yield t.h(e.request,r);return this._dataUpdateable=It(i.data,n)?Pt(i.data,n):void 0,i.data}if("string"==typeof e.data)try{const t=JSON.parse(e.data);return this._dataUpdateable=It(t,n)?Pt(t,n):void 0,t}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 zt(this._dataUpdateable,e.dataDiff,n),{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)}}function Ot({superclusterOptions:e,clusterProperties:r}){if(!r||!e)return e;const n={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(r);for(const e of s){const[a,o]=r[e],s=t.bB(o),l=t.bB("string"==typeof a?[a,["accumulated"],["get",e]]:a);n[e]=s.value,i[e]=l.value}return e.map=t=>{o.properties=t;const e={};for(const t of s)e[t]=n[t].evaluate(a,o);return e},e.reduce=(t,e)=>{o.properties=e;for(const e of s)a.accumulated=t[e],t[e]=i[e].evaluate(a,o)},e}class Rt{constructor(e){this.self=e,this.actor=new t.F(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=t.bh,this.self.removeProtocol=t.bi,this.self.registerRTLTextPlugin=e=>{if(t.bC.isParsed())throw new Error("RTL text plugin already registered.");t.bC.setMethods(e)},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(t.bC.isParsed())return t.bC.getState();if("loading"!==r.pluginStatus)return t.bC.setState(r),r;const e=r.pluginURL;if(this.self.importScripts(e),t.bC.isParsed()){const r={pluginStatus:"loaded",pluginURL:e};return t.bC.setState(r),r}throw t.bC.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let r=this.layerIndexes[t];return r||(r=this.layerIndexes[t]=new e),r}_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 o(n,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][r]=new Dt(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 s),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new Rt(self)),Rt})),r("index",["exports","./shared"],(function(t,e){var r={name:"maplibre-gl",description:"BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",version:"4.5.2",main:"dist/maplibre-gl.js",style:"dist/maplibre-gl.css",license:"BSD-3-Clause",homepage:"https://maplibre.org/",funding:"https://github.com/maplibre/maplibre-gl-js?sponsor=1",bugs:{url:"https://github.com/maplibre/maplibre-gl-js/issues/"},repository:{type:"git",url:"git://github.com/maplibre/maplibre-gl-js.git"},types:"dist/maplibre-gl.d.ts",type:"module",dependencies:{"@mapbox/geojson-rewind":"^0.5.2","@mapbox/jsonlint-lines-primitives":"^2.0.2","@mapbox/point-geometry":"^0.1.0","@mapbox/tiny-sdf":"^2.0.6","@mapbox/unitbezier":"^0.0.1","@mapbox/vector-tile":"^1.3.1","@mapbox/whoots-js":"^3.1.0","@maplibre/maplibre-gl-style-spec":"^20.3.0","@types/geojson":"^7946.0.14","@types/geojson-vt":"3.2.5","@types/mapbox__point-geometry":"^0.1.4","@types/mapbox__vector-tile":"^1.3.4","@types/pbf":"^3.0.5","@types/supercluster":"^7.1.3",earcut:"^3.0.0","geojson-vt":"^4.0.2","gl-matrix":"^3.4.3","global-prefix":"^3.0.0",kdbush:"^4.0.2","murmurhash-js":"^1.0.0",pbf:"^3.3.0",potpack:"^2.0.0",quickselect:"^3.0.0",supercluster:"^8.0.1",tinyqueue:"^3.0.0","vt-pbf":"^3.1.3"},devDependencies:{autoprefixer:"^10.4.20","@mapbox/mapbox-gl-rtl-text":"^0.3.0","@mapbox/mvt-fixtures":"^3.10.0","@rollup/plugin-commonjs":"^26.0.1","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.7","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","@types/benchmark":"^2.1.5","@types/cssnano":"^5.0.0","@types/d3":"^7.4.3","@types/diff":"^5.2.1","@types/earcut":"^2.1.4","@types/eslint":"^8.56.7","@types/gl":"^6.0.5","@types/glob":"^8.1.0","@types/jest":"^29.5.12","@types/jsdom":"^21.1.7","@types/minimist":"^1.2.5","@types/murmurhash-js":"^1.0.6","@types/nise":"^1.4.5","@types/node":"^22.1.0","@types/offscreencanvas":"^2019.7.3","@types/pixelmatch":"^5.2.6","@types/pngjs":"^6.0.5","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/request":"^2.48.12","@types/shuffle-seed":"^1.1.3","@types/window-or-global":"^1.0.6","@typescript-eslint/eslint-plugin":"^7.18.0","@typescript-eslint/parser":"^7.18.0",address:"^2.0.3",benchmark:"^2.1.4",canvas:"^2.11.2",cssnano:"^7.0.4",d3:"^7.9.0","d3-queue":"^3.0.7","devtools-protocol":"^0.0.1339468",diff:"^5.2.0","dts-bundle-generator":"^9.5.1",eslint:"^8.57.0","eslint-config-mourner":"^3.0.0","eslint-plugin-html":"^8.1.1","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^28.8.0","eslint-plugin-react":"^7.35.0","eslint-plugin-tsdoc":"0.3.0",expect:"^29.7.0",glob:"^11.0.0","is-builtin-module":"^4.0.0",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0","jest-junit":"^16.0.0","jest-monocart-coverage":"^1.1.1","jest-webgl-canvas-mock":"^2.5.3",jsdom:"^24.1.1","junit-report-builder":"^5.0.0",minimist:"^1.2.8","mock-geolocation":"^1.0.11","monocart-coverage-reports":"^2.10.2",nise:"^6.0.0","npm-font-open-sans":"^1.1.0","npm-run-all":"^4.1.5","pdf-merger-js":"^5.1.2",pixelmatch:"^6.0.0",pngjs:"^7.0.0",postcss:"^8.4.41","postcss-cli":"^11.0.0","postcss-inline-svg":"^6.0.0","pretty-bytes":"^6.1.1",puppeteer:"^23.0.2",react:"^18.3.1","react-dom":"^18.3.1",rollup:"^4.20.0","rollup-plugin-sourcemaps":"^0.6.3",rw:"^1.3.3",semver:"^7.6.3","shuffle-seed":"^1.1.6","source-map-explorer":"^2.5.3",st:"^3.0.0",stylelint:"^16.8.1","stylelint-config-standard":"^36.0.1","ts-jest":"^29.2.4","ts-node":"^10.9.2",tslib:"^2.6.3",typedoc:"^0.26.5","typedoc-plugin-markdown":"^4.2.3","typedoc-plugin-missing-exports":"^3.0.0",typescript:"^5.5.4"},overrides:{"postcss-inline-svg":{"css-select":"^5.1.0","dom-serializer":"^2.0.0",htmlparser2:"^8.0.1","postcss-value-parser":"^4.2.0"}},scripts:{"generate-dist-package":"node --no-warnings --loader ts-node/esm build/generate-dist-package.js","generate-shaders":"node --no-warnings --loader ts-node/esm build/generate-shaders.ts","generate-struct-arrays":"node --no-warnings --loader ts-node/esm build/generate-struct-arrays.ts","generate-style-code":"node --no-warnings --loader ts-node/esm build/generate-style-code.ts","generate-typings":"dts-bundle-generator --export-referenced-types --umd-module-name=maplibregl -o ./dist/maplibre-gl.d.ts ./src/index.ts","generate-docs":"typedoc && node --no-warnings --loader ts-node/esm build/generate-docs.ts","generate-images":"node --no-warnings --loader ts-node/esm build/generate-doc-images.ts","build-dist":"npm run build-css && npm run generate-typings && npm run build-dev && npm run build-csp-dev && npm run build-prod && npm run build-prod-unminified && npm run build-csp","build-dev":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev","watch-dev":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch","build-prod":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production,MINIFY:true","build-prod-unminified":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production","build-csp":"rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:production,MINIFY:true","build-csp-dev":"rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev","build-css":"postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css","watch-css":"postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css","build-benchmarks":"npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts","watch-benchmarks":"rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch","start-server":"st --no-cache -H 0.0.0.0 --port 9966 .","start-docs":"docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",start:"run-p watch-css watch-dev start-server","start-bench":"run-p watch-css watch-benchmarks start-server",lint:"eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .","lint-css":"stylelint **/*.css --fix -f verbose",test:"run-p lint lint-css test-render jest",jest:"jest","test-build":"jest --selectProjects=build --reporters=default","test-build-ci":"jest --selectProjects=build","test-integration":"jest --selectProjects=integration --reporters=default","test-integration-ci":"jest --coverage --selectProjects=integration","test-render":"node --no-warnings --loader ts-node/esm test/integration/render/run_render_tests.ts","test-unit":"jest --selectProjects=unit --reporters=default","test-unit-ci":"jest --coverage --selectProjects unit","test-watch-roots":"jest --watch",codegen:"run-p --print-label generate-dist-package generate-style-code generate-struct-arrays generate-shaders && npm run generate-typings",benchmark:"node --no-warnings --loader ts-node/esm test/bench/run-benchmarks.ts","gl-stats":"node --no-warnings --loader ts-node/esm test/bench/gl-stats.ts",prepare:"npm run codegen",typecheck:"tsc --noEmit && tsc --project tsconfig.dist.json",tsnode:"node --experimental-loader=ts-node/esm --no-warnings"},files:["build/","dist/*","src/"],engines:{npm:">=8.1.0",node:">=16.14.0"}};let n,i;const a={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:t=>new Promise(((r,n)=>{const i=requestAnimationFrame(r);t.signal.addEventListener("abort",(()=>{cancelAnimationFrame(i),n(e.c())}))})),getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0,t.width,t.height),r},resolveURL:t=>(n||(n=document.createElement("a")),n.href=t,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==i&&(i=matchMedia("(prefers-reduced-motion: reduce)")),i.matches)}};class o{static testProp(t){if(!o.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",o.suppressClickInternal,!0)}),0)}static getScale(t){const e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,r,n){const i=r.boundingClientRect;return new e.P((n.clientX-i.left)/r.x-t.clientLeft,(n.clientY-i.top)/r.y-t.clientTop)}static mousePos(t,e){const r=o.getScale(t);return o.getPoint(t,r,e)}static touchPos(t,e){const r=[],n=o.getScale(t);for(let i=0;i{l&&p(l),l=null,h=!0},c.onerror=()=>{u=!0,l=null},c.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let r,n,i,a;t.resetRequestQueue=()=>{r=[],n=0,i=0,a={}},t.addThrottleControl=t=>{const e=i++;return a[e]=t,e},t.removeThrottleControl=t=>{delete a[t],u()};const o=()=>{for(const t of Object.keys(a))if(a[t]())return!0;return!1};t.getImage=(t,n,i=!0)=>new Promise(((a,o)=>{s.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"});const l={abortController:n,requestParameters:t,supportImageRefresh:i,state:"queued",onError:t=>{o(t)},onSuccess:t=>{a(t)}};r.push(l),u()}));const l=t=>"function"==typeof createImageBitmap?e.d(t):e.f(t),c=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:r,supportImageRefresh:i,onError:a,onSuccess:o,abortController:s}=t,c=!1===i&&!e.i(self)&&!e.g(r.url)&&(!r.headers||Object.keys(r.headers).reduce(((t,e)=>t&&"accept"===e),!0));n++;const f=c?h(r,s):e.m(r,s);try{const r=yield f;delete t.abortController,t.state="completed",r.data instanceof HTMLImageElement||e.b(r.data)?o(r):r.data&&o({data:yield l(r.data),cacheControl:r.cacheControl,expires:r.expires})}catch(e){delete t.abortController,a(e)}finally{n--,u()}})),u=()=>{const t=o()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=n;e0;e++){const t=r.shift();t.abortController.signal.aborted?e--:c(t)}},h=(t,r)=>new Promise(((n,i)=>{const a=new Image,o=t.url,s=t.credentials;s&&"include"===s?a.crossOrigin="use-credentials":(s&&"same-origin"===s||!e.s(o))&&(a.crossOrigin="anonymous"),r.signal.addEventListener("abort",(()=>{a.src="",i(e.c())})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,n({data:a})},a.onerror=()=>{a.onerror=a.onload=null,r.signal.aborted||i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},a.src=o}))}(d||(d={})),d.resetRequestQueue();class m{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function g(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function y(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*s,t[1]=i*l+o*s,t[2]=n*-s+a*l,t[3]=i*-s+o*l,t}function v(){var t=new e.A(9);return e.A!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function x(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function _(){var t=new e.A(3);return e.A!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function b(t){var r=new e.A(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r}function w(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function T(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function k(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function A(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function M(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function S(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}function E(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}var C=T;function L(){var t=new e.A(2);return e.A!=Float32Array&&(t[0]=0,t[1]=0),t}function I(t){var e=t[0],r=t[1];return e*e+r*r}function P(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t}_();var z=I;function D(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const r=[];for(const{id:n,url:i}of t){const t=`${n}${i}`;-1===r.indexOf(t)&&(r.push(t),e.push({id:n,url:i}))}}return e}function O(t,e,r){const n=t.split("?");return n[0]+=`${e}${r}`,n.join("?")}function R(t,r,n,i){return e._(this,void 0,void 0,(function*(){const a=D(t),o=n>1?"@2x":"",s={},l={};for(const{id:t,url:n}of a){const a=r.transformRequest(O(n,o,".json"),"SpriteJSON");s[t]=e.h(a,i);const c=r.transformRequest(O(n,o,".png"),"SpriteImage");l[t]=d.getImage(c,i)}return yield Promise.all([...Object.values(s),...Object.values(l)]),F(s,l)}))}function F(t,r){return e._(this,void 0,void 0,(function*(){const e={};for(const n in t){e[n]={};const i=a.getImageCanvasContext((yield r[n]).data),o=(yield t[n]).data;for(const t in o){const{width:r,height:a,x:s,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:f,content:p,textFitWidth:d,textFitHeight:m}=o[t],g={width:r,height:a,x:s,y:l,context:i};e[n][t]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:f,content:p,textFitWidth:d,textFitHeight:m,spriteData:g}}}return e}))}L();class B{constructor(t,e,r,n){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,r,n){const{width:i,height:a}=t,o=!(this.size&&this.size[0]===i&&this.size[1]===a||n),{context:s}=this,{gl:l}=s;if(this.useMipmap=Boolean(r&&r.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!r||!1!==r.premultiply)),o)this.size=[i,a],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,i,a,0,this.format,l.UNSIGNED_BYTE,t.data);else{const{x:r,y:o}=n||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,r,o,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,r,o,i,a,l.RGBA,l.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D)}bind(t,e,r){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),r!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(r=i.LINEAR),t!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,r||t),this.filter=t),e!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function N(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}const j=1;class U extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const r=this.images[t];if(r&&!r.data&&r.spriteData){const t=r.spriteData;r.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),r.spriteData=null}return r}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,r){let n=!0;const i=r.data||r.spriteData;return this._validateStretch(r.stretchX,i&&i.width)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(r.stretchY,i&&i.height)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(r.content,r)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(t,e){if(!t)return!0;let r=0;for(const n of t){if(n[0]{let n=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(n=!1);this.isLoaded()||n?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){const r={};for(const n of t){let t=this.getImage(n);t||(this.fire(new e.k("styleimagemissing",{id:n})),t=this.getImage(n)),t?r[n]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${n}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return r}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const r=this.patterns[t],n=this.getImage(t);if(!n)return null;if(r&&r.position.version===n.version)return r.position;if(r)r.position.version=n.version;else{const r={w:n.data.width+2*j,h:n.data.height+2*j,x:0,y:0},i=new e.I(r,n);this.patterns[t]={bin:r,position:i}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new B(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:r,h:n}=e.p(t),i=this.atlasImage;i.resize({width:r||1,height:n||1});for(const t in this.patterns){const{bin:r}=this.patterns[t],n=r.x+j,a=r.y+j,o=this.getImage(t).data,s=o.width,l=o.height;e.R.copy(o,i,{x:0,y:0},{x:n,y:a},{width:s,height:l}),e.R.copy(o,i,{x:0,y:l-1},{x:n,y:a-1},{width:s,height:1}),e.R.copy(o,i,{x:0,y:0},{x:n,y:a+l},{width:s,height:1}),e.R.copy(o,i,{x:s-1,y:0},{x:n-1,y:a},{width:1,height:l}),e.R.copy(o,i,{x:0,y:0},{x:n+s,y:a},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const r of t){if(this.callbackDispatchedThisFrame[r])continue;this.callbackDispatchedThisFrame[r]=!0;const t=this.getImage(r);t||e.w(`Image with ID: "${r}" was not found`),N(t)&&this.updateImage(r,t)}}}function V(t,r,n,i){return e._(this,void 0,void 0,(function*(){const a=256*r,o=a+255,s=i.transformRequest(n.replace("{fontstack}",t).replace("{range}",`${a}-${o}`),"Glyphs"),l=yield e.l(s,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${r}, ${a}-${o}`);const c={};for(const t of e.n(l.data))c[t.id]=t;return c}))}const q=1e20;class H{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:a="normal",fontStyle:o="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const s=this.size=t+4*e,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${a} ${t}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(t),o=Math.ceil(r),s=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),c=Math.min(this.size-this.buffer,o+Math.ceil(n)),u=l+2*this.buffer,h=c+2*this.buffer,f=Math.max(u*h,0),p=new Uint8ClampedArray(f),d={data:p,width:u,height:h,glyphWidth:l,glyphHeight:c,glyphTop:o,glyphLeft:s,glyphAdvance:e};if(0===l||0===c)return d;const{ctx:m,buffer:g,gridInner:y,gridOuter:v}=this;m.clearRect(g,g,l,c),m.fillText(t,g,g+o);const x=m.getImageData(g,g,l,c);v.fill(q,0,f),y.fill(0,0,f);for(let t=0;t0?t*t:0,y[n]=t<0?t*t:0}}G(v,0,0,u,h,u,this.f,this.v,this.z),G(y,g,g,l,c,u,this.f,this.v,this.z);for(let t=0;t-1);l++,a[l]=s,o[l]=c,o[l+1]=q}for(let s=0,l=0;s65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[i])return{stack:t,id:r,glyph:n};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[i]){const r=Z.loadGlyphRange(t,i,this.url,this.requestManager);e.requests[i]=r}const a=yield e.requests[i];for(const t in a)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=a[+t]);return e.ranges[i]=!0,{stack:t,id:r,glyph:a[r]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(e.u["CJK Unified Ideographs"](t)||e.u["Hangul Syllables"](t)||e.u.Hiragana(t)||e.u.Katakana(t))}_tinySDF(t,r,n){const i=this.localIdeographFontFamily;if(!i)return;if(!this._doesCharSupportLocalGlyph(n))return;const a=2;let o=t.tinySDF;if(!o){let e="400";/bold/i.test(r)?e="900":/medium/i.test(r)?e="500":/light/i.test(r)&&(e="200"),o=t.tinySDF=new Z.TinySDF({fontSize:24*a,buffer:3*a,radius:8*a,cutoff:.25,fontFamily:i,fontWeight:e})}const s=o.draw(String.fromCharCode(n)),l=27.5,c=.5;return{id:n,bitmap:new e.o({width:s.width||30*a,height:s.height||30*a},s.data),metrics:{width:s.glyphWidth/a||24,height:s.glyphHeight/a||24,left:s.glyphLeft/a+c||0,top:s.glyphTop/a-l||-8,advance:s.glyphAdvance/a||24,isDoubleResolution:!0}}}}Z.loadGlyphRange=V,Z.TinySDF=H;class Y{constructor(){this.specification=e.v.light.position}possiblyEvaluate(t,r){return e.y(t.expression.evaluate(r))}interpolate(t,r,n){return{x:e.z.number(t.x,r.x,n),y:e.z.number(t.y,r.y,n),z:e.z.number(t.z,r.z,n)}}}const X="-transition";let $;class J extends e.E{constructor(t){super(),$=$||new e.q({anchor:new e.D(e.v.light.anchor),position:new Y,color:new e.D(e.v.light.color),intensity:new e.D(e.v.light.intensity)}),this._transitionable=new e.T($),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,r={}){if(!this._validate(e.r,t,r))for(const e in t){const r=t[e];e.endsWith(X)?this._transitionable.setTransition(e.slice(0,-X.length),r):this._transitionable.setValue(e,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,r,n){return(!n||!1!==n.validate)&&e.t(this,t.call(e.x,{value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.v}))}}const K=new e.q({"sky-color":new e.D(e.v.sky["sky-color"]),"horizon-color":new e.D(e.v.sky["horizon-color"]),"fog-color":new e.D(e.v.sky["fog-color"]),"fog-ground-blend":new e.D(e.v.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.v.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.v.sky["atmosphere-blend"])}),Q="-transition";class tt extends e.E{constructor(t){super(),this._transitionable=new e.T(K),this.setSky(t),this._transitioning=this._transitionable.untransitioned()}setSky(t,r={}){if(!this._validate(e.B,t,r))for(const e in t){const r=t[e];e.endsWith(Q)?this._transitionable.setTransition(e.slice(0,-Q.length),r):this._transitionable.setValue(e,r)}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,r,n={}){return!1!==(null==n?void 0:n.validate)&&e.t(this,t.call(e.x,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class et{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const r=t.join(",")+String(e);return this.dashEntry[r]||(this.dashEntry[r]=this.addDash(t,e)),this.dashEntry[r]}getDashRanges(t,e,r){const n=[];let i=t.length%2==1?-t[t.length-1]*r:0,a=t[0]*r,o=!0;n.push({left:i,right:a,isDash:o,zeroLength:0===t[0]});let s=t[0];for(let e=1;e1&&(s=t[++o]);const l=Math.abs(i-s.left),c=Math.abs(i-s.right),u=Math.min(l,c);let h;const f=e/r*(n+1);if(s.isDash){const t=n-Math.abs(f);h=Math.sqrt(u*u+t*t)}else h=n-Math.sqrt(u*u+f*f);this.data[a+i]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1))}const e=t[0],r=t[t.length-1];e.isDash===r.isDash&&(e.left=r.left-this.width,r.right=e.right+this.width);const n=this.width*this.nextRow;let i=0,a=t[i];for(let e=0;e1&&(a=t[++i]);const r=Math.abs(e-a.left),o=Math.abs(e-a.right),s=Math.min(r,o),l=a.isDash?s:-s;this.data[n+e]=Math.max(0,Math.min(255,l+128))}}addDash(t,r){const n=r?7:0,i=2*n+1;if(this.nextRow+i>this.height)return e.w("LineAtlas out of space"),null;let a=0;for(let e=0;e{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[nt]}numActive(){return Object.keys(this.active).length}}const at=Math.floor(a.hardwareConcurrency/2);let ot,st;function lt(){return ot||(ot=new it),ot}function ct(){lt().acquire(nt)}function ut(){const t=ot;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(nt),ot=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))}it.workerCount=e.C(globalThis)?Math.max(Math.min(at,3),1):1;class ht{constructor(t,r){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=r;const n=this.workerPool.acquire(r);for(let t=0;t{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const r of this.actors)r.registerMessageHandler(t,e)}}function ft(){return st||(st=new ht(lt(),e.G),st.registerMessageHandler("GR",((t,r,n)=>e.m(r,n)))),st}function pt(t,r){const n=e.H();return e.J(n,n,[1,1,0]),e.K(n,n,[.5*t.width,.5*t.height,1]),e.L(n,n,t.calculatePosMatrix(r.toUnwrapped()))}function dt(t,e,r){if(t)for(const n of t){const t=e[n];if(t&&t.source===r&&"fill-extrusion"===t.type)return!0}else for(const t in e){const n=e[t];if(n.source===r&&"fill-extrusion"===n.type)return!0}return!1}function mt(t,e,r,n,i,a){const o=dt(i&&i.layers,e,t.id),s=a.maxPitchScaleFactor(),l=t.tilesIn(n,s,o);l.sort(vt);const c=[];for(const n of l)c.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(e,r,t._state,n.queryGeometry,n.cameraQueryGeometry,n.scale,i,a,s,pt(t.transform,n.tileID))});const u=xt(c);for(const e in u)u[e].forEach((e=>{const r=e.feature,n=t.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=n}));return u}function gt(t,e,r,n,i,a,o){const s={},l=a.queryRenderedSymbols(n),c=[];for(const t of Object.keys(l).map(Number))c.push(o[t]);c.sort(vt);for(const r of c){const n=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],e,r.bucketIndex,r.sourceLayerIndex,i.filter,i.layers,i.availableImages,t);for(const t in n){const e=s[t]=s[t]||[],i=n[t];i.sort(((t,e)=>{const n=r.featureSortOrder;if(n){const r=n.indexOf(t.featureIndex);return n.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const t of i)e.push(t)}}for(const e in s)s[e].forEach((n=>{const i=n.feature,a=t[e],o=r[a.source].getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o}));return s}function yt(t,e){const r=t.getRenderableIds().map((e=>t.getTileByID(e))),n=[],i={};for(let t=0;tt.id))),o}))}class bt{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}extend(t){const r=this._sw,n=this._ne;let i,a;if(t instanceof e.N)i=t,a=t;else{if(!(t instanceof bt)){if(Array.isArray(t)){if(4===t.length||t.every(Array.isArray)){const e=t;return this.extend(bt.convert(e))}{const r=t;return this.extend(e.N.convert(r))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.N.convert(t)):this}if(i=t._sw,a=t._ne,!i||!a)return this}return r||n?(r.lng=Math.min(i.lng,r.lng),r.lat=Math.min(i.lat,r.lat),n.lng=Math.max(a.lng,n.lng),n.lat=Math.max(a.lat,n.lat)):(this._sw=new e.N(i.lng,i.lat),this._ne=new e.N(a.lng,a.lat)),this}getCenter(){return new e.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new e.N(this.getWest(),this.getNorth())}getSouthEast(){return new e.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:r,lat:n}=e.N.convert(t),i=this._sw.lat<=n&&n<=this._ne.lat;let a=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=r&&r>=this._ne.lng),i&&a}static convert(t){return t instanceof bt?t:t?new bt(t):t}static fromLngLat(t,r=0){const n=360*r/40075017,i=n/Math.cos(Math.PI/180*t.lat);return new bt(new e.N(t.lng-i,t.lat-n),new e.N(t.lng+i,t.lat+n))}}class wt{constructor(t,e,r){this.bounds=bt.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),n={minX:Math.floor(e.O(this.bounds.getWest())*r),minY:Math.floor(e.Q(this.bounds.getNorth())*r),maxX:Math.ceil(e.O(this.bounds.getEast())*r),maxY:Math.ceil(e.Q(this.bounds.getSouth())*r)};return t.x>=n.minX&&t.x=n.minY&&t.y{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};r.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,r)=>{t.reloadPromise={resolve:e,reject:r}}))}else t.actor=this.dispatcher.getActor(),n="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:n,data:r},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class kt extends e.E{constructor(t,r,n,i){super(),this.id=t,this.dispatcher=n,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},r),e.e(this,e.M(r,["url","scheme","tileSize"]))}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield _t(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(e.e(this,t),t.bounds&&(this.tileBounds=new wt(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new e.j(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const r=yield d.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(r&&r.data){this.map._refreshExpiredTiles&&r.cacheControl&&r.expires&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const e=this.map.painter.context,n=e.gl,i=r.data;t.texture=this.map.painter.getTileTexture(i.width),t.texture?t.texture.update(i,{useMipmap:!0}):(t.texture=new B(e,i,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class At extends kt{constructor(t,r,n,i){super(t,r,n,i),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox",this.redFactor=r.redFactor,this.greenFactor=r.greenFactor,this.blueFactor=r.blueFactor,this.baseShift=r.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const r=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(r,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const r=yield d.getImage(n,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(r&&r.data){const n=r.data;this.map._refreshExpiredTiles&&r.cacheControl&&r.expires&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const i=e.b(n)&&e.U()?n:yield this.readImageNow(n),a={type:this.type,uid:t.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:a});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.V()){const r=t.width+2,n=t.height+2;try{return new e.R({width:r,height:n},yield e.W(t,-1,-1,r,n))}catch(t){}}return a.getImageData(t,1)}))}_getNeighboringTiles(t){const r=t.canonical,n=Math.pow(2,r.z),i=(r.x-1+n)%n,a=0===r.x?t.wrap-1:t.wrap,o=(r.x+1+n)%n,s=r.x+1===n?t.wrap+1:t.wrap,l={};return l[new e.S(t.overscaledZ,a,r.z,i,r.y).key]={backfilled:!1},l[new e.S(t.overscaledZ,s,r.z,o,r.y).key]={backfilled:!1},r.y>0&&(l[new e.S(t.overscaledZ,a,r.z,i,r.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&e.e(i,{resourceTiming:n}),this.fire(new e.k("data",Object.assign(Object.assign({},i),{sourceDataType:"metadata"}))),this.fire(new e.k("data",Object.assign(Object.assign({},i),{sourceDataType:"content"})))}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.k("dataabort",{dataType:"source"}));this.fire(new e.j(t))}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const n=yield this.actor.sendAsync({type:e,data:r},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(n,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var St=e.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Et extends e.E{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=e}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield d.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,this.fire(new e.j(t))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const r=t.map(e.Z.fromLngLat);this.tileID=Ct(r),this.minzoom=this.maxzoom=this.tileID.z;const n=r.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new e.$,this._boundsArray.emplaceBack(n[0].x,n[0].y,0,0),this._boundsArray.emplaceBack(n[1].x,n[1].y,e.X,0),this._boundsArray.emplaceBack(n[3].x,n[3].y,0,e.X),this._boundsArray.emplaceBack(n[2].x,n[2].y,e.X,e.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,r=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new B(t,this.image,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}function Ct(t){let r=1/0,n=1/0,i=-1/0,a=-1/0;for(const e of t)r=Math.min(r,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x),a=Math.max(a,e.y);const o=i-r,s=a-n,l=Math.max(o,s),c=Math.max(0,Math.floor(-Math.log(l)/Math.LN2)),u=Math.pow(2,c);return new e.a1(c,Math.floor((r+i)/2*u),Math.floor((n+a)/2*u))}class Lt extends Et{constructor(t,e,r,n){super(t,e,r,n),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.a3(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.j(t))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const r=this.video.seekable;tr.end(0)?this.fire(new e.j(new e.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,r=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new B(t,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class It extends Et{constructor(t,r,n,i){super(t,r,n,i),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.j(new e.a2(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const r=this.map.painter.context,n=r.gl;this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new B(r,this.canvas,n.RGBA,{premultiply:!0});let i=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Pt={},zt=(t,e,r,n)=>{const i=new(Dt(e.type))(t,e,r,n);if(i.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${i.id}`);return i},Dt=t=>{switch(t){case"geojson":return Mt;case"image":return Et;case"raster":return kt;case"raster-dem":return At;case"vector":return Tt;case"video":return Lt;case"canvas":return It}return Pt[t]},Ot=(t,e)=>{Pt[t]=e},Rt=(t,r)=>e._(void 0,void 0,void 0,(function*(){if(Dt(t))throw new Error(`A source type called "${t}" already exists.`);Ot(t,r)}));function Ft(t,e){const r={};if(!e)return r;for(const n of t){const t=n.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)r[e.id]=n}}return r}const Bt="RTLPluginLoaded";class Nt extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ft()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.k(Bt))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let jt=null;function Ut(){return jt||(jt=new Nt),jt}const Vt=3e4;class qt{constructor(t,r){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.a4(),this.uses=0,this.tileSize=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;et)e=!1;else if(r)if(this.expirationTime{this.remove(t,i)}),r)),this.data[n].push(i),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const r in this.data)for(const n of this.data[r])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Gt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,r,n){const i=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][i]=this.stateChanges[t][i]||{},e.e(this.stateChanges[t][i],n),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==i&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][i]){this.deletedStates[t][i]={};for(const e in this.state[t][i])n[e]||(this.deletedStates[t][i][e]=null)}else for(const e in n)this.deletedStates[t]&&this.deletedStates[t][i]&&null===this.deletedStates[t][i][e]&&delete this.deletedStates[t][i][e]}removeFeatureState(t,e,r){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},r&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][r]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(r in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][r]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,r){const n=String(r),i=this.state[t]||{},a=this.stateChanges[t]||{},o=e.e({},i[n],a[n]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][r];if(null===e)return{};for(const t in e)delete o[t]}return o}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,r){const n={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const r={};for(const n in this.stateChanges[t])this.state[t][n]||(this.state[t][n]={}),e.e(this.state[t][n],this.stateChanges[t][n]),r[n]=this.state[t][n];n[t]=r}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const r={};if(null===this.deletedStates[t])for(const e in this.state[t])r[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const r of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][r];r[e]=this.state[t][e]}n[t]=n[t]||{},e.e(n[t],r)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const e in t)t[e].setFeatureState(n,r)}}class Wt extends e.E{constructor(t,e,r){super(),this.id=t,this.dispatcher=r,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=zt(t,e,r,this),this._tiles={},this._cache=new Ht(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Gt,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,r,n){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,r,n)}catch(r){t.state="errored",404!==r.status?this._source.fire(new e.j(r,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const r=this._tiles[e];r.upload(t),r.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Zt).map((t=>t.key))}getRenderableIds(t){const r=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&r.push(this._tiles[e]);return t?r.sort(((t,r)=>{const n=t.tileID,i=r.tileID,a=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new e.P(i.canonical.x,i.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-i.overscaledZ||o.y-a.y||o.x-a.x})).map((t=>t.tileID.key)):r.map((t=>t.tileID)).sort(Zt).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,r){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=r),yield this._loadTile(e,t,r))}))}_tileLoaded(t,r,n){t.timeAdded=a.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,r,n){for(const i in this._tiles){let a=this._tiles[i];if(n[i]||!a.hasData()||a.tileID.overscaledZ<=e||a.tileID.overscaledZ>r)continue;let o=a.tileID;for(;a&&a.tileID.overscaledZ>e+1;){const t=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[t.key],a&&a.hasData()&&(o=t)}let s=o;for(;s.overscaledZ>e;)if(s=s.scaledTo(s.overscaledZ-1),t[s.key]){n[o.key]=o;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=e?r:null}for(let r=t.overscaledZ-1;r>=e;r--){const e=t.scaledTo(r),n=this._getLoadedTile(e);if(n)return n}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const r=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),n=null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,i=Math.floor(r*n),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._cache.setMaxSize(a)}handleWrapJump(t){const e=(t-(void 0===this._prevLng?t:this._prevLng))/360,r=Math.round(e);if(this._prevLng=t,r){const t={};for(const e in this._tiles){const n=this._tiles[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+r),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles){const e=this._tiles[t];this._setTileReloadTimer(t,e)}}}_updateCoveredAndRetainedTiles(t,e,r,n,i,o){const s={},l={},c=Object.keys(t),u=a.now();for(const r of c){const n=t[r],i=this._tiles[r];if(!i||0!==i.fadeEndTime&&i.fadeEndTime<=u)continue;const a=this.findLoadedParent(n,e),o=this.findLoadedSibling(n),c=a||o||null;c&&(this._addTile(c.tileID),s[c.tileID.key]=c.tileID),l[r]=n}this._retainLoadedChildren(l,n,r,t);for(const e in s)t[e]||(this._coveredTiles[e]=!0,t[e]=s[e]);if(o){const e={},r={};for(const t of i)this._tiles[t.key].hasData()?e[t.key]=t:r[t.key]=t;for(const n in r){const i=r[n].children(this._source.maxzoom);this._tiles[i[0].key]&&this._tiles[i[1].key]&&this._tiles[i[2].key]&&this._tiles[i[3].key]&&(e[i[0].key]=t[i[0].key]=i[0],e[i[1].key]=t[i[1].key]=i[1],e[i[2].key]=t[i[2].key]=i[2],e[i[3].key]=t[i[3].key]=i[3],delete r[n])}for(const n in r){const i=r[n],a=this.findLoadedParent(i,this._source.minzoom),o=this.findLoadedSibling(i),s=a||o||null;if(s){e[s.tileID.key]=t[s.tileID.key]=s.tileID;for(const t in e)e[t].isChildOf(s.tileID)&&delete e[t]}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0)}}update(t,r){if(!this._sourceLoaded||this._paused)return;let n;this.transform=t,this.terrain=r,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.S(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const i=t.coveringZoomLevel(this._source),a=Math.max(i-Wt.maxOverzooming,this._source.minzoom),o=Math.max(i+Wt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of n)if(e.canonical.z>this._source.minzoom){const r=e.scaledTo(e.canonical.z-1);t[r.key]=r;const n=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[n.key]=n}n=n.concat(Object.values(t))}const s=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,s&&this.fire(new e.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(n,i);Yt(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,o,i,n,r);for(const t in l)this._tiles[t].clearFadeHold();const c=e.ac(this._tiles,l);for(const t of c){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var r;const n={},i={},a=Math.max(e-Wt.maxOverzooming,this._source.minzoom),o=Math.max(e+Wt.maxUnderzooming,this._source.minzoom),s={};for(const r of t){const t=this._addTile(r);n[r.key]=r,t.hasData()||ethis._source.maxzoom){const t=o.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){n[t.key]=t;continue}}else{const t=o.children(this._source.maxzoom);if(n[t[0].key]&&n[t[1].key]&&n[t[2].key]&&n[t[3].key])continue}let s=t.wasRequested();for(let e=o.overscaledZ-1;e>=a;--e){const a=o.scaledTo(e);if(i[a.key])break;if(i[a.key]=!0,t=this.getTile(a),!t&&s&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(r=this.map)||void 0===r?void 0:r.cancelPendingTileRequestsWhileZooming)||s)&&(n[a.key]=a),s=t.wasRequested(),e)break}}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let r,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){r=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(r=this._getLoadedTile(t),r)break;n=t}for(const t of e)this._loadedParentTiles[t]=r}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,r=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=r}}_addTile(t){let r=this._tiles[t.key];if(r)return r;r=this._cache.getAndRemove(t),r&&(this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,r)));const n=r;return r||(r=new qt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(r,t.key,r.state)),r.uses++,this._tiles[t.key]=r,n||this._source.fire(new e.k("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),r))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,r,n){const i=[],a=this.transform;if(!a)return i;const o=n?a.getCameraQueryGeometry(t):t,s=t.map((t=>a.pointCoordinate(t,this.terrain))),l=o.map((t=>a.pointCoordinate(t,this.terrain))),c=this.getIds();let u=1/0,h=1/0,f=-1/0,p=-1/0;for(const t of l)u=Math.min(u,t.x),h=Math.min(h,t.y),f=Math.max(f,t.x),p=Math.max(p,t.y);for(let t=0;t=0&&g[1].y+m>=0){const t=s.map((t=>o.getTilePoint(t))),e=l.map((t=>o.getTilePoint(t)));i.push({tile:n,tileID:o,queryGeometry:t,cameraQueryGeometry:e,scale:d})}}return i}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type)){const t=a.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return!0}return!1}setFeatureState(t,e,r){t=t||"_geojsonTileLayer",this._state.updateState(t,e,r)}removeFeatureState(t,e,r){t=t||"_geojsonTileLayer",this._state.removeFeatureState(t,e,r)}getFeatureState(t,e){return t=t||"_geojsonTileLayer",this._state.getState(t,e)}setDependencies(t,e,r){const n=this._tiles[t];n&&n.setDependencies(e,r)}reloadTilesForDependencies(t,e){for(const r in this._tiles)this._tiles[r].hasDependency(t,e)&&this._reloadTile(r,"reloading");this._cache.filter((r=>!r.hasDependency(t,e)))}}function Zt(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Yt(t){return"raster"===t||"image"===t||"video"===t}Wt.maxOverzooming=10,Wt.maxUnderzooming=3;class Xt{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(i-o)/s:0;return this.points[a].mult(1-l).add(this.points[r].mult(l))}}function $t(t,e){let r=!0;return"always"===t||"never"!==t&&"never"!==e||(r=!1),r}class Jt{constructor(t,e,r){const n=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(e/r);for(let t=0;tthis.width||n<0||e>this.height)return[];const s=[];if(t<=0&&e<=0&&this.width<=r&&this.height<=n){if(i)return[{key:null,x1:t,y1:e,x2:r,y2:n}];for(let t=0;t0}hitTestCircle(t,e,r,n,i){const a=t-r,o=t+r,s=e-r,l=e+r;if(o<0||a>this.width||l<0||s>this.height)return!1;const c=[],u={hitTest:!0,overlapMode:n,circle:{x:t,y:e,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(a,s,o,l,this._queryCellCircle,c,u,i),c.length>0}_queryCell(t,e,r,n,i,a,o,s){const{seenUids:l,hitTest:c,overlapMode:u}=o,h=this.boxCells[i];if(null!==h){const i=this.bboxes;for(const o of h)if(!l.box[o]){l.box[o]=!0;const h=4*o,f=this.boxKeys[o];if(t<=i[h+2]&&e<=i[h+3]&&r>=i[h+0]&&n>=i[h+1]&&(!s||s(f))&&(!c||!$t(u,f.overlapMode))&&(a.push({key:f,x1:i[h],y1:i[h+1],x2:i[h+2],y2:i[h+3]}),c))return!0}}const f=this.circleCells[i];if(null!==f){const i=this.circles;for(const o of f)if(!l.circle[o]){l.circle[o]=!0;const h=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(i[h],i[h+1],i[h+2],t,e,r,n)&&(!s||s(f))&&(!c||!$t(u,f.overlapMode))){const t=i[h],e=i[h+1],r=i[h+2];if(a.push({key:f,x1:t-r,y1:e-r,x2:t+r,y2:e+r}),c)return!0}}}return!1}_queryCellCircle(t,e,r,n,i,a,o,s){const{circle:l,seenUids:c,overlapMode:u}=o,h=this.boxCells[i];if(null!==h){const t=this.bboxes;for(const e of h)if(!c.box[e]){c.box[e]=!0;const r=4*e,n=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[r+0],t[r+1],t[r+2],t[r+3])&&(!s||s(n))&&!$t(u,n.overlapMode))return a.push(!0),!0}}const f=this.circleCells[i];if(null!==f){const t=this.circles;for(const e of f)if(!c.circle[e]){c.circle[e]=!0;const r=3*e,n=this.circleKeys[e];if(this._circlesCollide(t[r],t[r+1],t[r+2],l.x,l.y,l.radius)&&(!s||s(n))&&!$t(u,n.overlapMode))return a.push(!0),!0}}}_forEachCell(t,e,r,n,i,a,o,s){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(r),h=this._convertToYCellCoord(n);for(let f=l;f<=u;f++)for(let l=c;l<=h;l++){const c=this.xCellCount*l+f;if(i.call(this,t,e,r,n,c,a,o,s))return}}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,r,n,i,a){const o=n-t,s=i-e,l=r+a;return l*l>o*o+s*s}_circleAndRectCollide(t,e,r,n,i,a,o){const s=(a-n)/2,l=Math.abs(t-(n+s));if(l>s+r)return!1;const c=(o-i)/2,u=Math.abs(e-(i+c));if(u>c+r)return!1;if(l<=s||u<=c)return!0;const h=l-s,f=u-c;return h*h+f*f<=r*r}}function Kt(t,r,n,i,a){const o=e.H();return r?(e.K(o,o,[1/a,1/a,1]),n||e.ae(o,o,i.angle)):e.L(o,i.labelPlaneMatrix,t),o}function Qt(t,r,n,i,a){if(r){const r=e.af(t);return e.K(r,r,[a,a,1]),n||e.ae(r,r,-i.angle),r}return i.glCoordMatrix}function te(t,r,n){let i;n?(i=[t.x,t.y,n(t.x,t.y),1],e.ag(i,i,r)):(i=[t.x,t.y,0,1],ye(i,i,r));const a=i[3];return{point:new e.P(i[0]/a,i[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function ee(t,e){return.5+t/e*.5}function re(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function ne(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m){const g=i?t.textSizeData:t.iconSizeData,y=e.ah(g,n.transform.zoom),v=[256/n.width*2+1,256/n.height*2+1],x=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;x.clear();const _=t.lineVertexArray,b=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=n.transform.width/n.transform.height;let T=!1;for(let i=0;iMath.abs(n.x-r.x)*i?{useVertical:!0}:(t===e.ai.vertical?r.yn.x)?{needsFlipping:!0}:null}function oe(t,r,n,i,a,o,s,l,c,u,h){const f=n/24,p=r.lineOffsetX*f,d=r.lineOffsetY*f;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,n=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=ie(f,l,p,d,i,r,h,t);if(!c)return{notEnoughRoom:!0};const g=te(c.first.point,s,t.getElevation).point,y=te(c.last.point,s,t.getElevation).point;if(a&&!i){const t=ae(r.writingMode,g,y,u);if(t)return t}m=[c.first];for(let a=r.glyphStartIndex+1;a0?s.point:se(t.tileAnchorPoint,a,n,1,o,t),c=ae(r.writingMode,n,l,u);if(c)return c}const n=de(f*l.getoffsetX(r.glyphStartIndex),p,d,i,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,h);if(!n||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[n]}for(const t of m)e.ak(c,t.point,t.angle);return{}}function se(t,e,r,n,i,a){return ce(t,e,r,n,i,a)}function le(t,e,r,n,i){return ce(t,e,r,n,void 0,i)}function ce(t,e,r,n,i,a){const o=t.add(t.sub(e)._unit()),s=void 0!==i?te(o,i,a.getElevation).point:he(o.x,o.y,a).point,l=r.sub(s);return r.add(l._mult(n/l.mag()))}function ue(t,r,n){const i=r.projectionCache;if(i.projections[t])return i.projections[t];const a=new e.P(r.lineVertexArray.getx(t),r.lineVertexArray.gety(t)),o=he(a.x,a.y,r);if(o.signedDistanceFromCamera>0)return i.projections[t]=o.point,i.anyProjectionOccluded=i.anyProjectionOccluded||o.isOccluded,o.point;const s=t-n.direction,l=0===n.distanceFromAnchor?r.tileAnchorPoint:new e.P(r.lineVertexArray.getx(s),r.lineVertexArray.gety(s)),c=n.absOffsetX-n.distanceFromAnchor+1;return le(l,a,n.previousVertex,c,r)}function he(t,r,n){const i=t+n.translation[0],a=r+n.translation[1];let o;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(o=n.projection.projectTileCoordinates(i,a,n.unwrappedTileID,n.getElevation),o.point.x=(.5*o.point.x+.5)*n.width,o.point.y=(.5*-o.point.y+.5)*n.height):(o=te(new e.P(i,a),n.labelPlaneMatrix,n.getElevation),o.isOccluded=!1),o}function fe(t,e,r){return t._unit()._perp()._mult(e*r)}function pe(t,r,n,i,a,o,s,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const u=n.add(r);if(t+c.direction=a)return l.projectionCache.offsets[t]=u,u;const h=ue(t+c.direction,l,c),f=fe(h.sub(n),s,c.direction),p=n.add(f),d=h.add(f);return l.projectionCache.offsets[t]=e.al(o,u,p,d)||u,l.projectionCache.offsets[t]}function de(t,e,r,n,i,a,o,s,l){const c=n?t-e:t+e;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let f,p=u>0?a+i:a+i+1;s.projectionCache.cachedAnchorPoint?f=s.projectionCache.cachedAnchorPoint:(f=he(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=f);let d,m,g=f,y=f,v=0,x=0;const _=Math.abs(c),b=[];let w;for(;v+x<=_;){if(p+=u,p=o)return null;v+=x,y=g,m=d;const t={absOffsetX:_,direction:u,distanceFromAnchor:v,previousVertex:y};if(g=ue(p,s,t),0===r)b.push(y),w=g.sub(y);else{let e;const n=g.sub(y);e=0===n.mag()?fe(ue(p+u,s,t).sub(g),r,u):fe(n,r,u),m||(m=y.add(e)),d=pe(p,e,g,a,o,m,r,s,t),b.push(m),w=d.sub(m)}x=w.mag()}const T=(_-v)/x,k=w._mult(T)._add(m||y),A=h+Math.atan2(g.y-y.y,g.x-y.x);return b.push(k),{point:k,angle:l?A:0,path:b}}const me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ge(t,e){for(let r=0;r=1;t--)l.push(o.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const t=l[0].clone(),r=l[0].clone();for(let e=1;e=n.x&&r.x<=i.x&&t.y>=n.y&&r.y<=i.y?[l]:r.xi.x||r.yi.y?[]:e.am([l],n.x,n.y,i.x,i.y)}for(const e of m){a.reset(e,.25*r);let n=0;n=a.length<=.5*r?1:Math.ceil(a.paddedLength/h)+1;for(let e=0;ete(t,r,e.getElevation)))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let n=1/0,i=1/0,a=-1/0,o=-1/0;for(const s of t){const t=new e.P(s.x+ve,s.y+ve);n=Math.min(n,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y),r.push(t)}const s=this.grid.query(n,i,a,o).concat(this.ignoredGrid.query(n,i,a,o)),l={},c={};for(const t of s){const n=t.key;if(void 0===l[n.bucketInstanceId]&&(l[n.bucketInstanceId]={}),l[n.bucketInstanceId][n.featureIndex])continue;const i=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.an(r,i)&&(l[n.bucketInstanceId][n.featureIndex]=!0,void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]=[]),c[n.bucketInstanceId].push(n.featureIndex))}return c}insertCollisionBox(t,e,r,n,i,a){const o={bucketInstanceId:n,featureIndex:i,collisionGroupID:a,overlapMode:e};(r?this.ignoredGrid:this.grid).insert(o,t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,r,n,i,a){const o=r?this.ignoredGrid:this.grid,s={bucketInstanceId:n,featureIndex:i,collisionGroupID:a,overlapMode:e};for(let e=0;e=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(t,e,r,n){return r>=0&&t=0&&ethis.projectAndGetPerspectiveRatio(n,t.x,t.y,i,c)));A=t.some((t=>!t.isOccluded)),k=t.map((t=>t.point))}else A=!0;return{box:e.ap(k),allPointsOccluded:!A}}}function _e(t,r,n){return r*(e.X/(t.tileSize*Math.pow(2,n-t.tileID.overscaledZ)))}class be{constructor(t,e,r,n){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):n&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class we{constructor(t,e,r,n,i){this.text=new be(t?t.text:null,e,r,i),this.icon=new be(t?t.icon:null,e,n,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Te{constructor(t,e,r){this.text=t,this.icon=e,this.skipFade=r}}class ke{constructor(){this.invProjMatrix=e.H(),this.viewportMatrix=e.H(),this.circles=[]}}class Ae{constructor(t,e,r,n,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=r,this.bucketIndex=n,this.tileID=i}}class Me{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function Se(t,r,n,i,a){const{horizontalAlign:o,verticalAlign:s}=e.av(t),l=-(o-.5)*r,c=-(s-.5)*n;return new e.P(l+i[0]*a,c+i[1]*a)}class Ee{constructor(t,e,r,n,i,a){this.transform=t.clone(),this.terrain=r,this.collisionIndex=new xe(this.transform,e),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new Me(i),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(r,n)=>e.getElevation(t,r,n):null}getBucketParts(t,r,n,i){const a=n.getBucket(r),o=n.latestFeatureIndex;if(!a||!o||r.id!==a.layerIds[0])return;const s=n.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/e.X,f=n.tileID.toUnwrapped(),p=this.transform.calculatePosMatrix(f),d="map"===l.get("text-pitch-alignment"),m="map"===l.get("text-rotation-alignment"),g=_e(n,1,this.transform.zoom),y=this.collisionIndex.mapProjection.translatePosition(this.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),v=this.collisionIndex.mapProjection.translatePosition(this.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),x=Kt(p,d,m,this.transform,g);let _=null;if(d){const t=Qt(p,d,m,this.transform,g);_=e.L([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[a.bucketInstanceId]=new Ae(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,n.tileID);const b={bucket:a,layout:l,translationText:y,translationIcon:v,posMatrix:p,unwrappedTileID:f,textLabelPlaneMatrix:x,labelToScreenMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:e.ah(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(const e of a.sortKeyRanges){const{sortKey:r,symbolInstanceStart:n,symbolInstanceEnd:i}=e;t.push({sortKey:r,symbolInstanceStart:n,symbolInstanceEnd:i,parameters:b})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:b})}attemptAnchorPlacement(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x){const _=e.ar[t.textAnchor],b=[t.textOffset0,t.textOffset1],w=Se(_,n,i,b,a),T=this.collisionIndex.placeCollisionBox(r,f,l,c,u,s,o,g,h.predicate,x,w);if((!v||this.collisionIndex.placeCollisionBox(v,f,l,c,u,s,o,y,h.predicate,x,w).placeable)&&T.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:i,anchor:_,textBoxScale:a,prevAnchor:t},this.markUsedJustification(d,_,p,m),d.allowVerticalPlacement&&(this.markUsedOrientation(d,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,r,n){const{bucket:i,layout:a,translationText:o,translationIcon:s,posMatrix:l,unwrappedTileID:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,textPixelRatio:f,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:m,collisionGroup:g}=t.parameters,y=a.get("text-optional"),v=a.get("icon-optional"),x=e.as(a,"text-overlap","text-allow-overlap"),_="always"===x,b=e.as(a,"icon-overlap","icon-allow-overlap"),w="always"===b,T="map"===a.get("text-rotation-alignment"),k="map"===a.get("text-pitch-alignment"),A="none"!==a.get("icon-text-fit"),M="viewport-y"===a.get("symbol-z-order"),S=_&&(w||!i.hasIconData()||v),E=w&&(_||!i.hasTextData()||y);!i.collisionArrays&&d&&i.deserializeCollisionBoxes(d);const C=this.retainedQueryData[i.bucketInstanceId].tileID,L=this._getTerrainElevationFunc(C),I=(t,d,w)=>{var M,C;if(r[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new Te(!1,!1,!1));let I=!1,P=!1,z=!0,D=null,O={box:null,placeable:!1,offscreen:null},R={box:null,placeable:!1,offscreen:null},F=null,B=null,N=null,j=0,U=0,V=0;d.textFeatureIndex?j=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=t.featureIndex),d.verticalTextFeatureIndex&&(U=d.verticalTextFeatureIndex);const q=d.textBox;if(q){const r=r=>{let n=e.ai.horizontal;if(i.allowVerticalPlacement&&!r&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,n=e,this.markUsedOrientation(i,n,t))}return n},a=(r,n)=>{if(i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of i.writingModes)if(t===e.ai.vertical?(O=n(),R=O):O=r(),O&&O.placeable)break}else O=r()},u=t.textAnchorOffsetStartIndex,h=t.textAnchorOffsetEndIndex;if(h===u){const n=(e,r)=>{const n=this.collisionIndex.placeCollisionBox(e,x,f,l,c,k,T,o,g.predicate,L);return n&&n.placeable&&(this.markUsedOrientation(i,r,t),this.placedOrientations[t.crossTileID]=r),n};a((()=>n(q,e.ai.horizontal)),(()=>{const r=d.verticalTextBox;return i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&r?n(r,e.ai.vertical):{box:null,offscreen:null}})),r(O&&O.placeable)}else{let p=e.ar[null===(C=null===(M=this.prevPlacement)||void 0===M?void 0:M.variableOffsets[t.crossTileID])||void 0===C?void 0:C.anchor];const m=(r,a,d)=>{const m=r.x2-r.x1,y=r.y2-r.y1,v=t.textBoxScale,_=A&&"never"===b?a:null;let w=null,M="never"===x?1:2,S="never";p&&M++;for(let e=0;em(q,d.iconBox,e.ai.horizontal)),(()=>{const r=d.verticalTextBox,n=O&&O.placeable;return i.allowVerticalPlacement&&!n&&t.numVerticalGlyphVertices>0&&r?m(r,d.verticalIconBox,e.ai.vertical):{box:null,occluded:!0,offscreen:null}})),O&&(I=O.placeable,z=O.offscreen);const y=r(O&&O.placeable);if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(i,e.anchor,t,y))}}}if(F=O,I=F&&F.placeable,z=F&&F.offscreen,t.useRuntimeCollisionCircles){const r=i.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),s=e.aj(i.textSizeData,m,r),f=a.get("text-padding"),p=t.collisionCircleDiameter;B=this.collisionIndex.placeCollisionCircles(x,r,i.lineVertexArray,i.glyphOffsetArray,s,l,c,u,h,n,k,g.predicate,p,f,o,L),B.circles.length&&B.collisionDetected&&!n&&e.w("Collisions detected, but collision boxes are not shown"),I=_||B.circles.length>0&&!B.collisionDetected,z=z&&B.offscreen}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,b,f,l,c,k,T,s,g.predicate,L,A&&D?D:void 0);R&&R.placeable&&d.verticalIconBox?(N=t(d.verticalIconBox),P=N.placeable):(N=t(d.iconBox),P=N.placeable),z=z&&N.offscreen}const H=y||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=v||0===t.numIconVertices;H||G?G?H||(P=P&&I):I=P&&I:P=I=P&&I;const W=I&&F.placeable,Z=P&&N.placeable;if(W&&(R&&R.placeable&&U?this.collisionIndex.insertCollisionBox(F.box,x,a.get("text-ignore-placement"),i.bucketInstanceId,U,g.ID):this.collisionIndex.insertCollisionBox(F.box,x,a.get("text-ignore-placement"),i.bucketInstanceId,j,g.ID)),Z&&this.collisionIndex.insertCollisionBox(N.box,b,a.get("icon-ignore-placement"),i.bucketInstanceId,V,g.ID),B&&I&&this.collisionIndex.insertCollisionCircles(B.circles,x,a.get("text-ignore-placement"),i.bucketInstanceId,j,g.ID),n&&this.storeCollisionData(i.bucketInstanceId,w,d,F,N,B),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===i.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new Te(I||S,P||E,z||i.justReloaded),r[t.crossTileID]=!0};if(M){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=i.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const r=e[t];I(i.symbolInstances.get(r),i.collisionArrays[r],r)}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:n.crossTileID)}markUsedOrientation(t,r,n){const i=r===e.ai.horizontal||r===e.ai.horizontalOnly?r:0,a=r===e.ai.vertical?r:0,o=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const e of o)t.text.placedSymbolArray.get(e).placedOrientation=i;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let r=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const n=e?e.symbolFadeChange(t):1,i=e?e.opacities:{},a=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],a=i[t];a?(this.opacities[t]=new we(a,n,e.text,e.icon),r=r||e.text!==a.text.placed||e.icon!==a.icon.placed):(this.opacities[t]=new we(null,n,e.text,e.icon,e.skipFade),r=r||e.text||e.icon)}for(const t in i){const e=i[t];if(!this.opacities[t]){const i=new we(e,n,!1,!1);i.isHidden()||(this.opacities[t]=i,r=r||e.text.placed||e.icon.placed)}}for(const t in a)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=a[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const r={};for(const n of e){const e=n.getBucket(t);e&&n.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,n.tileID,r,n.collisionBoxArray)}}updateBucketOpacities(t,r,n,i){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const a=t.layers[0],o=a.layout,s=new we(null,0,!1,!1,!0),l=o.get("text-allow-overlap"),c=o.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===o.get("text-rotation-alignment"),f="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),d=new we(null,0,l&&(c||!t.hasIconData()||o.get("icon-optional")),c&&(l||!t.hasTextData()||o.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const m=(t,e,r)=>{for(let n=0;n0||o>0,x=i.numIconVertices>0,_=this.placedOrientations[i.crossTileID],b=_===e.ai.vertical,w=_===e.ai.horizontal||_===e.ai.horizontalOnly;if(v){const e=Fe(y.text),r=b?Be:e;m(t.text,a,r);const n=w?Be:e;m(t.text,o,n);const s=y.text.isHidden();[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=s||b?1:0)})),i.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=s||w?1:0);const l=this.variableOffsets[i.crossTileID];l&&this.markUsedJustification(t,l.anchor,i,_);const c=this.placedOrientations[i.crossTileID];c&&(this.markUsedJustification(t,"left",i,c),this.markUsedOrientation(t,c,i))}if(x){const e=Fe(y.icon),r=!(p&&i.verticalPlacedIconSymbolIndex&&b);if(i.placedIconSymbolIndex>=0){const n=r?e:Be;m(t.icon,i.numIconVertices,n),t.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=y.icon.isHidden()}if(i.verticalPlacedIconSymbolIndex>=0){const n=r?Be:e;m(t.icon,i.numVerticalIconVertices,n),t.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden()}}const T=g&&g.has(r)?g.get(r):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.P(0,0);if(n.textBox||n.verticalTextBox){let e=!0;if(u){const t=this.variableOffsets[l];t?(r=Se(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),h&&r._rotate(f?this.transform.angle:-this.transform.angle)):e=!1}if(n.textBox||n.verticalTextBox){let i;n.textBox&&(i=b),n.verticalTextBox&&(i=w),Ce(t.textCollisionBox.collisionVertexArray,y.text.placed,!e||i,T.text,r.x,r.y)}}if(n.iconBox||n.verticalIconBox){const e=Boolean(!w&&n.verticalIconBox);let i;n.iconBox&&(i=e),n.verticalIconBox&&(i=!e),Ce(t.iconCollisionBox.collisionVertexArray,y.icon.placed,i,T.icon,p?r.x:0,p?r.y:0)}}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ce(t,e,r,n,i,a){n&&0!==n.length||(n=[0,0,0,0]);const o=n[0]-ve,s=n[1]-ve,l=n[2]-ve,c=n[3]-ve;t.emplaceBack(e?1:0,r?1:0,i||0,a||0,o,s),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,l,s),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,l,c),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,o,c)}const Le=Math.pow(2,25),Ie=Math.pow(2,24),Pe=Math.pow(2,17),ze=Math.pow(2,16),De=Math.pow(2,9),Oe=Math.pow(2,8),Re=Math.pow(2,1);function Fe(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*Le+e*Ie+r*Pe+e*ze+r*De+e*Oe+r*Re+e}const Be=0;function Ne(){return{isOccluded:(t,e,r)=>!1,getPitchedTextCorrection:(t,e,r)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(t,e,r,n){throw new Error("Not implemented.")},translatePosition:(t,e,r,n)=>je(t,e,r,n),getCircleRadiusCorrection:t=>1}}function je(t,e,r,n,i=!1){if(!r[0]&&!r[1])return[0,0];const a=i?"map"===n?t.angle:0:"viewport"===n?-t.angle:0;if(a){const t=Math.sin(a),e=Math.cos(a);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e]}return[i?r[0]:_e(e,r[0],t.zoom),i?r[1]:_e(e,r[1],t.zoom)]}class Ue{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,r,n,i){const a=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&a.now()-n>2;for(;this._currentPlacementIndex>=0;){const n=e[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=a)&&(!n.maxzoom||n.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new Ue(n)),this._inProgressLayer.continuePlacement(r[n.source],this.placement,this._showCollisionBoxes,n,i))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const qe=512/e.X/2,He=128;class Ge{constructor(t,r,n){this.tileID=t,this.bucketInstanceId=n,this._symbolsByKey={};const i=new Map;for(let t=0;t({x:Math.floor(t.anchorX*qe),y:Math.floor(t.anchorY*qe)}))),crossTileIDs:r.map((t=>t.crossTileID))};if(n.positions.length>He){const t=new e.aw(n.positions.length,16,Uint16Array);for(const{x:e,y:r}of n.positions)t.add(e,r);t.finish(),delete n.positions,n.index=t}this._symbolsByKey[t]=n}}getScaledCoordinates(t,r){const{x:n,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:l}=r.canonical,c=l-a,u=qe/Math.pow(2,c),h=(o*e.X+t.anchorX)*u,f=(s*e.X+t.anchorY)*u,p=n*e.X*qe,d=i*e.X*qe;return{x:Math.floor(h-p),y:Math.floor(f-d)}}findMatches(t,e,r){const n=this.tileID.canonical.zt))}}class We{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ze{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const r=this.indexes[t],n={};for(const t in r){const i=r[t];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),n[i.tileID.key]=i}this.indexes[t]=n}this.lng=t}addBucket(t,e,r){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(const r in i){const a=i[r];a.tileID.isChildOf(t)&&a.findMatches(e.symbolInstances,t,n)}else{const a=i[t.scaledTo(Number(r)).key];a&&a.findMatches(e.symbolInstances,t,n)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Xe=(t,r)=>e.t(t,r&&r.filter((t=>"source.canvas"!==t.identifier))),$e=e.ax();class Je extends e.E{constructor(t,r={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload()}},this.map=t,this.dispatcher=new ht(lt(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new U,this.imageManager.setEventedParent(this),this.glyphManager=new Z(t._requestManager,r.localIdeographFontFamily),this.lineAtlas=new et(256,512),this.crossTileSymbolIndex=new Ye,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.az()),Ut().on(Bt,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const r=e.getSource();if(r&&r.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===r.id&&this._validateLayer(e)}}))}loadURL(t,r={},n){this.fire(new e.k("dataloading",{dataType:"style"})),r.validate="boolean"!=typeof r.validate||r.validate;const i=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;e.h(i,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,r,n)})).catch((t=>{this._loadStyleRequest=null,t&&!a.signal.aborted&&this.fire(new e.j(t))}))}loadJSON(t,r={},n){this.fire(new e.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,r.validate=!1!==r.validate,this._load(t,r,n)})).catch((()=>{}))}loadEmpty(){this.fire(new e.k("dataloading",{dataType:"style"})),this._load($e,{validate:!1})}_load(t,r,n){var i;const a=r.transformStyle?r.transformStyle(n,t):t;if(!r.validate||!Xe(this,e.x(a))){this._loaded=!0,this.stylesheet=a;for(const t in a.sources)this.addSource(t,a.sources[t],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new J(this.stylesheet.light),this.sky=new tt(this.stylesheet.sky),this.map.setTerrain(null!==(i=this.stylesheet.terrain)&&void 0!==i?i:null),this.fire(new e.k("data",{dataType:"style"})),this.fire(new e.k("style.load"))}}_createLayers(){const t=e.aA(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const r of t){const t=e.aB(r);t.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=t}}_loadSprite(t,r=!1,n=void 0){let i;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,R(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const n=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of n)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const n in t[e]){const i="default"===e?n:`${e}:${n}`;this._spritesImagesIds[e].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,t[e][n],!1):this.imageManager.addImage(i,t[e][n]),r&&(this._changedImages[i]=!0)}}})).catch((t=>{this._spriteRequest=null,i=t,this.fire(new e.j(i))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),r&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"})),n&&n(i)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}_validateLayer(t){const r=this.sourceCaches[t.source];if(!r)return;const n=t.sourceLayer;if(!n)return;const i=r.getSource();("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.j(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const e=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e);const r=[];for(const n of t)e[n]&&r.push(e[n]);return r}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const r of e){const e=this._layers[r];"custom"!==e.type&&(t[r]=e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.sky&&this.sky.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const r=this._changed;if(r){const e=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(e.length||r.length)&&this._updateWorkerLayers(e,r);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const n={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];n[t]=e.used,e.used=!1}for(const e of this._order){const r=this._layers[e];r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)&&r.source&&(this.sourceCaches[r.source].used=!0)}for(const t in n){const r=this.sourceCaches[t];!!n[t]!=!!r.used&&r.fire(new e.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.z=t.zoom,r&&this.fire(new e.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,r={}){var n;this._checkLoaded();const i=this.serialize();if(t=r.transformStyle?r.transformStyle(i,t):t,(null===(n=r.validate)||void 0===n||n)&&Xe(this,e.x(t)))return!1;(t=e.aC(t)).layers=e.aA(t.layers);const a=e.aD(i,t),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const t of o.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],r=[];for(const n of t)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,n.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,n.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,n.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,n.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,n.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,n.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,n.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,n.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,n.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,n.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,n.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,n.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,n.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,n.args)));break;case"setTransition":e.push((()=>{}));break;default:r.push(n.command)}return{operations:e,unimplemented:r}}addImage(t,r){if(this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,r),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,r,n={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(e.x.source,`sources.${t}`,r,null,n))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const i=this.sourceCaches[t]=new Wt(t,r,this.dispatcher);i.style=this,i.setEventedParent(this,(()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:t}))),i.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const r in this._layers)if(this._layers[r].source===t)return this.fire(new e.j(new Error(`Source "${t}" cannot be removed while layer "${r}" is using it.`)));const r=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],r.fire(new e.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),r.setEventedParent(null),r.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const r=this.sourceCaches[t].getSource();if("geojson"!==r.type)throw new Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,r,n={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.j(new Error(`Layer "${i}" already exists on this map.`)));let a;if("custom"===t.type){if(Xe(this,e.aE(t)))return;a=e.aB(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(i,t.source),t=e.aC(t),t=e.e(t,{source:i})),this._validate(e.x.layer,`layers.${i}`,t,{arrayIndex:-1},n))return;a=e.aB(t),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}const o=r?this._order.indexOf(r):this._order.length;if(r&&-1===o)this.fire(new e.j(new Error(`Cannot add layer "${i}" before non-existing layer "${r}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&"custom"!==a.type){const t=this._removedLayers[i];delete this._removedLayers[i],t.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(t,r){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===r)return;const n=this._order.indexOf(t);this._order.splice(n,1);const i=r?this._order.indexOf(r):this._order.length;r&&-1===i?this.fire(new e.j(new Error(`Cannot move layer "${t}" before non-existing layer "${r}".`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const r=this._layers[t];if(!r)return void this.fire(new e.j(new Error(`Cannot remove non-existing layer "${t}".`)));r.setEventedParent(null);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=r,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],r.onRemove&&r.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,r,n){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===r&&i.maxzoom===n||(null!=r&&(i.minzoom=r),null!=n&&(i.maxzoom=n),this._updateLayer(i)):this.fire(new e.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,r,n={}){this._checkLoaded();const i=this.getLayer(t);if(i){if(!e.aF(i.filter,r))return null==r?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(e.x.filter,`layers.${i.id}.filter`,r,null,n)||(i.filter=e.aC(r),this._updateLayer(i)))}else this.fire(new e.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.aC(this.getLayer(t).filter)}setLayoutProperty(t,r,n,i={}){this._checkLoaded();const a=this.getLayer(t);a?e.aF(a.getLayoutProperty(r),n)||(a.setLayoutProperty(r,n,i),this._updateLayer(a)):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,r){const n=this.getLayer(t);if(n)return n.getLayoutProperty(r);this.fire(new e.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,r,n,i={}){this._checkLoaded();const a=this.getLayer(t);a?e.aF(a.getPaintProperty(r),n)||(a.setPaintProperty(r,n,i)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,r){this._checkLoaded();const n=t.source,i=t.sourceLayer,a=this.sourceCaches[n];if(void 0===a)return void this.fire(new e.j(new Error(`The source '${n}' does not exist in the map's style.`)));const o=a.getSource().type;"geojson"===o&&i?this.fire(new e.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||i?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),a.setFeatureState(i,t.id,r)):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,r){this._checkLoaded();const n=t.source,i=this.sourceCaches[n];if(void 0===i)return void this.fire(new e.j(new Error(`The source '${n}' does not exist in the map's style.`)));const a=i.getSource().type,o="vector"===a?t.sourceLayer:void 0;"vector"!==a||o?r&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.j(new Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(o,t.id,r):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const r=t.source,n=t.sourceLayer,i=this.sourceCaches[r];if(void 0!==i)return"vector"!==i.getSource().type||n?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),i.getFeatureState(n,t.id)):void this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.j(new Error(`The source '${r}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.aG(this.sourceCaches,(t=>t.serialize())),r=this._serializeByIds(this._order),n=this.map.getTerrain()||void 0,i=this.stylesheet;return e.aH({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,sources:t,layers:r,terrain:n},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,r={},n=[];for(let i=this._order.length-1;i>=0;i--){const a=this._order[i];if(e(a)){r[a]=i;for(const e of t){const t=e[a];if(t)for(const e of t)n.push(e)}}}n.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const i=[];for(let a=this._order.length-1;a>=0;a--){const o=this._order[a];if(e(o))for(let t=n.length-1;t>=0;t--){const e=n[t].feature;if(r[e.layer.id]t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(r,l[r.source],t.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((i=i||this._layerOrderChanged||0===r)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.now(),t.zoom))&&(this.pauseablePlacement=new Ve(t,this.map.terrain,this._order,i,e,r,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,r){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(r.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[r.source];return e&&e.setDependencies(r.tileID.key,r.type,r.icons),t}))}getGlyphs(t,r){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(r.stacks),e=this.sourceCaches[r.source];return e&&e.setDependencies(r.tileID.key,r.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,r={}){this._checkLoaded(),t&&this._validate(e.x.glyphs,"glyphs",t,null,r)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,r,n={},i){this._checkLoaded();const a=[{id:t,url:r}],o=[...D(this.stylesheet.sprite),...a];this._validate(e.x.sprite,"sprite",o,null,n)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(t){this._checkLoaded();const r=D(this.stylesheet.sprite);if(r.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;r.splice(r.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=r.length>0?r:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}else this.fire(new e.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return D(this.stylesheet.sprite)}setSprite(t,r={},n){this._checkLoaded(),t&&this._validate(e.x.sprite,"sprite",t,null,r)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,n):(this._unloadSprite(),n&&n(null)))}}var Ke=e.Y([{name:"a_pos",type:"Int16",components:2}]),Qe="uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",tr="attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}",er="uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",rr="uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",nr="varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ir="uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}",ar="void main() {gl_FragColor=vec4(1.0);}",or="attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}",sr="uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",lr="uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}",cr="uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}",ur="uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}",hr="varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}",fr="attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}",pr="varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",dr="attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}",mr="uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",gr="attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}",yr="#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",vr="attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}",xr="varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",_r="attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}",br="uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",wr="uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}",Tr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",kr="uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}",Ar="varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Mr="uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}",Sr="uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Er="uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}",Cr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Lr="uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}",Ir="uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Pr="uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}",zr="uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Dr="\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}",Or="uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Rr="\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}",Fr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Br="\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}",Nr="uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",jr="\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}",Ur="uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Vr="uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}",qr="uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Hr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}",Gr="#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Wr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}",Zr="#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Yr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}",Xr="varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",$r="precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",Jr="uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}",Kr="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}",Qr="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}",tn="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}",en="uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}",rn="attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}";const nn={prelude:an("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:an(Qe,tr),backgroundPattern:an(er,rr),circle:an(nr,ir),clippingMask:an(ar,or),heatmap:an(sr,lr),heatmapTexture:an(cr,ur),collisionBox:an(hr,fr),collisionCircle:an(pr,dr),debug:an(mr,gr),fill:an(yr,vr),fillOutline:an(xr,_r),fillOutlinePattern:an(br,wr),fillPattern:an(Tr,kr),fillExtrusion:an(Ar,Mr),fillExtrusionPattern:an(Sr,Er),hillshadePrepare:an(Cr,Lr),hillshade:an(Ir,Pr),line:an(zr,Dr),lineGradient:an(Or,Rr),linePattern:an(Fr,Br),lineSDF:an(Nr,jr),raster:an(Ur,Vr),symbolIcon:an(qr,Hr),symbolSDF:an(Gr,Wr),symbolTextAndIcon:an(Zr,Yr),terrain:an(Jr,tn),terrainDepth:an(Xr,Kr),terrainCoords:an($r,Qr),sky:an(en,rn)};function an(t,e){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=e.match(/attribute ([\w]+) ([\w]+)/g),i=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return t=t.replace(r,((t,e,r,n,i)=>(s[i]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nvarying ${r} ${n} ${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = u_${i};\n#endif\n`))),e=e.replace(r,((t,e,r,n,i)=>{const a="float"===n?"vec2":"vec4",o=i.match(/color/)?"color":a;return s[i]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nattribute ${r} ${a} a_${i};\nvarying ${r} ${n} ${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nattribute ${r} ${a} a_${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = a_${i};\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`})),{fragmentSource:t,vertexSource:e,staticAttributes:n,staticUniforms:o}}class on{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,r,n,i,a,o,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!c&&t({u_depth:new e.aI(t,r.u_depth),u_terrain:new e.aI(t,r.u_terrain),u_terrain_dim:new e.aJ(t,r.u_terrain_dim),u_terrain_matrix:new e.aK(t,r.u_terrain_matrix),u_terrain_unpack:new e.aL(t,r.u_terrain_unpack),u_terrain_exaggeration:new e.aJ(t,r.u_terrain_exaggeration)}),ln=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texture:new e.aI(t,r.u_texture),u_ele_delta:new e.aJ(t,r.u_ele_delta),u_fog_matrix:new e.aK(t,r.u_fog_matrix),u_fog_color:new e.aM(t,r.u_fog_color),u_fog_ground_blend:new e.aJ(t,r.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.aJ(t,r.u_fog_ground_blend_opacity),u_horizon_color:new e.aM(t,r.u_horizon_color),u_horizon_fog_blend:new e.aJ(t,r.u_horizon_fog_blend)}),cn=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ele_delta:new e.aJ(t,r.u_ele_delta)}),un=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texture:new e.aI(t,r.u_texture),u_terrain_coords_id:new e.aJ(t,r.u_terrain_coords_id),u_ele_delta:new e.aJ(t,r.u_ele_delta)}),hn=(t,r,n,i,a)=>({u_matrix:t,u_texture:0,u_ele_delta:r,u_fog_matrix:n,u_fog_color:i?i.properties.get("fog-color"):e.aN.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:i?i.calculateFogBlendOpacity(a):0,u_horizon_color:i?i.properties.get("horizon-color"):e.aN.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1}),fn=(t,e)=>({u_matrix:t,u_ele_delta:e}),pn=(t,e,r)=>({u_matrix:t,u_terrain_coords_id:e/255,u_texture:0,u_ele_delta:r});function dn(t){const e=[];for(let r=0;r>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}function yn(t,e,r,n){const i=r.imageManager.getPattern(t.from.toString()),a=r.imageManager.getPattern(t.to.toString()),{width:o,height:s}=r.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,r.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[o,s],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/_e(n,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}const vn=(t,e,r,n)=>{const i=e.style.light,a=i.properties.get("position"),o=[a.x,a.y,a.z],s=v();"viewport"===i.properties.get("anchor")&&x(s,-e.transform.angle),E(o,o,s);const l=i.properties.get("color");return{u_matrix:t,u_lightpos:o,u_lightintensity:i.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+r,u_opacity:n}},xn=(t,r,n,i,a,o,s)=>e.e(vn(t,r,n,i),gn(o,r,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8}),_n=t=>({u_matrix:t}),bn=(t,r,n,i)=>e.e(_n(t),gn(n,r,i)),wn=(t,e)=>({u_matrix:t,u_world:e}),Tn=(t,r,n,i,a)=>e.e(bn(t,r,n,i),{u_world:a}),kn=(t,e,r,n)=>{const i=t.transform;let a,o;if("map"===n.paint.get("circle-pitch-alignment")){const t=_e(r,1,i.zoom);a=!0,o=[t,t]}else a=!1,o=i.pixelsToGLUnits;return{u_camera_to_center_distance:i.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,r,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:o}},An=(t,e)=>({u_matrix:e,u_pixel_extrude_scale:[1/t.width,1/t.height]}),Mn=(t,e,r)=>({u_matrix:t,u_inv_matrix:e,u_camera_to_center_distance:r.cameraToCenterDistance,u_viewport_size:[r.width,r.height]}),Sn=(t,e,r=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:r}),En=t=>({u_matrix:t}),Cn=(t,e,r,n)=>({u_matrix:t,u_extrude_scale:_e(e,1,r),u_intensity:n}),Ln=(t,r,n,i)=>{const a=e.H();e.aQ(a,0,t.width,t.height,0,0,1);const o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:n,u_color_ramp:i,u_opacity:r.paint.get("heatmap-opacity")}},In=(t,e,r,n)=>{const i=r.paint.get("hillshade-shadow-color"),a=r.paint.get("hillshade-highlight-color"),o=r.paint.get("hillshade-accent-color");let s=r.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===r.paint.get("hillshade-illumination-anchor")&&(s-=t.transform.angle);const l=!t.options.moving;return{u_matrix:n?n.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:zn(t,e.tileID),u_light:[r.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:a,u_accent:o}},Pn=(t,r)=>{const n=r.stride,i=e.H();return e.aQ(i,0,e.X,-e.X,0,0,1),e.J(i,i,[0,-e.X,0]),{u_matrix:i,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:r.getUnpackVector()}};function zn(t,r){const n=Math.pow(2,r.canonical.z),i=r.canonical.y;return[new e.Z(0,i/n).toLngLat().lat,new e.Z(0,(i+1)/n).toLngLat().lat]}const Dn=(t,e,r,n)=>{const i=t.transform;return{u_matrix:Nn(t,e,r,n),u_ratio:1/_e(e,1,i.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/i.pixelsToGLUnits[0],1/i.pixelsToGLUnits[1]]}},On=(t,r,n,i,a)=>e.e(Dn(t,r,n,a),{u_image:0,u_image_height:i}),Rn=(t,e,r,n,i)=>{const a=t.transform,o=Bn(e,a);return{u_matrix:Nn(t,e,r,i),u_texsize:e.imageAtlasTexture.size,u_ratio:1/_e(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Fn=(t,r,n,i,a,o)=>{const s=t.transform,l=t.lineAtlas,c=Bn(r,s),u="round"===n.layout.get("line-cap"),h=l.getDash(i.from,u),f=l.getDash(i.to,u),p=h.width*a.fromScale,d=f.width*a.toScale;return e.e(Dn(t,r,n,o),{u_patternscale_a:[c/p,-h.height/2],u_patternscale_b:[c/d,-f.height/2],u_sdfgamma:l.width/(256*Math.min(p,d)*t.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:f.y,u_mix:a.t})};function Bn(t,e){return 1/_e(t,1,e.tileZoom)}function Nn(t,e,r,n){return t.translatePosMatrix(n?n.posMatrix:e.tileID.posMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const jn=(t,e,r,n,i)=>({u_matrix:t,u_tl_parent:e,u_scale_parent:r,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:qn(i.paint.get("raster-saturation")),u_contrast_factor:Vn(i.paint.get("raster-contrast")),u_spin_weights:Un(i.paint.get("raster-hue-rotate"))});function Un(t){t*=Math.PI/180;const e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}function Vn(t){return t>0?1/(1-t):1+t}function qn(t){return t>0?1-1/(1.001-t):-t}const Hn=(t,e,r,n,i,a,o,s,l,c,u,h,f,p)=>{const d=o.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+r,u_aspect_ratio:d.width/d.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:l,u_coord_matrix:c,u_is_text:+h,u_pitch_with_map:+n,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:f,u_texture:0,u_translation:u,u_pitched_scale:p}},Gn=(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m)=>{const g=s.transform;return e.e(Hn(t,r,n,i,a,o,s,l,c,u,h,f,p,m),{u_gamma_scale:i?Math.cos(g._pitch)*g.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+d})},Wn=(t,r,n,i,a,o,s,l,c,u,h,f,p,d)=>e.e(Gn(t,r,n,i,a,o,s,l,c,u,h,!0,f,!0,d),{u_texsize_icon:p,u_texture_icon:1}),Zn=(t,e,r)=>({u_matrix:t,u_opacity:e,u_color:r}),Yn=(t,r,n,i,a,o)=>e.e(yn(i,o,n,a),{u_matrix:t,u_opacity:r}),Xn=(t,e,r)=>({u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:(e.height/2+e.getHorizon())*r,u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*r}),$n={fillExtrusion:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_lightpos:new e.aO(t,r.u_lightpos),u_lightintensity:new e.aJ(t,r.u_lightintensity),u_lightcolor:new e.aO(t,r.u_lightcolor),u_vertical_gradient:new e.aJ(t,r.u_vertical_gradient),u_opacity:new e.aJ(t,r.u_opacity)}),fillExtrusionPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_lightpos:new e.aO(t,r.u_lightpos),u_lightintensity:new e.aJ(t,r.u_lightintensity),u_lightcolor:new e.aO(t,r.u_lightcolor),u_vertical_gradient:new e.aJ(t,r.u_vertical_gradient),u_height_factor:new e.aJ(t,r.u_height_factor),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade),u_opacity:new e.aJ(t,r.u_opacity)}),fill:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix)}),fillPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),fillOutline:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world)}),fillOutlinePattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),circle:(t,r)=>({u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_scale_with_map:new e.aI(t,r.u_scale_with_map),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_extrude_scale:new e.aP(t,r.u_extrude_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_matrix:new e.aK(t,r.u_matrix)}),collisionBox:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_pixel_extrude_scale:new e.aP(t,r.u_pixel_extrude_scale)}),collisionCircle:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_inv_matrix:new e.aK(t,r.u_inv_matrix),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_viewport_size:new e.aP(t,r.u_viewport_size)}),debug:(t,r)=>({u_color:new e.aM(t,r.u_color),u_matrix:new e.aK(t,r.u_matrix),u_overlay:new e.aI(t,r.u_overlay),u_overlay_scale:new e.aJ(t,r.u_overlay_scale)}),clippingMask:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix)}),heatmap:(t,r)=>({u_extrude_scale:new e.aJ(t,r.u_extrude_scale),u_intensity:new e.aJ(t,r.u_intensity),u_matrix:new e.aK(t,r.u_matrix)}),heatmapTexture:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world),u_image:new e.aI(t,r.u_image),u_color_ramp:new e.aI(t,r.u_color_ramp),u_opacity:new e.aJ(t,r.u_opacity)}),hillshade:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_latrange:new e.aP(t,r.u_latrange),u_light:new e.aP(t,r.u_light),u_shadow:new e.aM(t,r.u_shadow),u_highlight:new e.aM(t,r.u_highlight),u_accent:new e.aM(t,r.u_accent)}),hillshadePrepare:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_dimension:new e.aP(t,r.u_dimension),u_zoom:new e.aJ(t,r.u_zoom),u_unpack:new e.aL(t,r.u_unpack)}),line:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels)}),lineGradient:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_image:new e.aI(t,r.u_image),u_image_height:new e.aJ(t,r.u_image_height)}),linePattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texsize:new e.aP(t,r.u_texsize),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_image:new e.aI(t,r.u_image),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),lineSDF:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_patternscale_a:new e.aP(t,r.u_patternscale_a),u_patternscale_b:new e.aP(t,r.u_patternscale_b),u_sdfgamma:new e.aJ(t,r.u_sdfgamma),u_image:new e.aI(t,r.u_image),u_tex_y_a:new e.aJ(t,r.u_tex_y_a),u_tex_y_b:new e.aJ(t,r.u_tex_y_b),u_mix:new e.aJ(t,r.u_mix)}),raster:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_tl_parent:new e.aP(t,r.u_tl_parent),u_scale_parent:new e.aJ(t,r.u_scale_parent),u_buffer_scale:new e.aJ(t,r.u_buffer_scale),u_fade_t:new e.aJ(t,r.u_fade_t),u_opacity:new e.aJ(t,r.u_opacity),u_image0:new e.aI(t,r.u_image0),u_image1:new e.aI(t,r.u_image1),u_brightness_low:new e.aJ(t,r.u_brightness_low),u_brightness_high:new e.aJ(t,r.u_brightness_high),u_saturation_factor:new e.aJ(t,r.u_saturation_factor),u_contrast_factor:new e.aJ(t,r.u_contrast_factor),u_spin_weights:new e.aO(t,r.u_spin_weights)}),symbolIcon:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texture:new e.aI(t,r.u_texture),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),symbolSDF:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texture:new e.aI(t,r.u_texture),u_gamma_scale:new e.aJ(t,r.u_gamma_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_is_halo:new e.aI(t,r.u_is_halo),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),symbolTextAndIcon:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texsize_icon:new e.aP(t,r.u_texsize_icon),u_texture:new e.aI(t,r.u_texture),u_texture_icon:new e.aI(t,r.u_texture_icon),u_gamma_scale:new e.aJ(t,r.u_gamma_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_is_halo:new e.aI(t,r.u_is_halo),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),background:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_opacity:new e.aJ(t,r.u_opacity),u_color:new e.aM(t,r.u_color)}),backgroundPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_opacity:new e.aJ(t,r.u_opacity),u_image:new e.aI(t,r.u_image),u_pattern_tl_a:new e.aP(t,r.u_pattern_tl_a),u_pattern_br_a:new e.aP(t,r.u_pattern_br_a),u_pattern_tl_b:new e.aP(t,r.u_pattern_tl_b),u_pattern_br_b:new e.aP(t,r.u_pattern_br_b),u_texsize:new e.aP(t,r.u_texsize),u_mix:new e.aJ(t,r.u_mix),u_pattern_size_a:new e.aP(t,r.u_pattern_size_a),u_pattern_size_b:new e.aP(t,r.u_pattern_size_b),u_scale_a:new e.aJ(t,r.u_scale_a),u_scale_b:new e.aJ(t,r.u_scale_b),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aJ(t,r.u_tile_units_to_pixels)}),terrain:ln,terrainDepth:cn,terrainCoords:un,sky:(t,r)=>({u_sky_color:new e.aM(t,r.u_sky_color),u_horizon_color:new e.aM(t,r.u_horizon_color),u_horizon:new e.aJ(t,r.u_horizon),u_sky_horizon_blend:new e.aJ(t,r.u_sky_horizon_blend)})};class Jn{constructor(t,e,r){this.context=t;const n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){const t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}}const Kn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qn{constructor(t,e,r,n){this.length=e.length,this.attributes=r,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;const i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let r=0;r0){const r=e.H();e.aR(r,d.placementInvProjMatrix,t.transform.glCoordMatrix),e.aR(r,r,d.placementViewportMatrix),c.push({circleArray:g,circleOffset:h,transform:p.posMatrix,invTransform:r,coord:p}),u+=g.length/4,h=u}m&&l.draw(o,s.LINES,Gi.disabled,Yi.disabled,t.colorModeForRenderPass(),Ji.disabled,An(t.transform,p.posMatrix),t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!a||!c.length)return;const f=t.useProgram("collisionCircle"),p=new e.aS;p.resize(4*u),p._trim();let d=0;for(const t of c)for(let e=0;er.style.map.terrain.getElevation(a,t,e):null,i=h.translatePosition(u,t,s,l);oa(o,f,p,c,u,y,a.posMatrix,e,m,v,h,i,a.toUnwrapped(),n)}}}function aa(t,r,n,i,a,o){const s=r.tileAnchorPoint.add(new e.P(r.translation[0],r.translation[1]));if(r.pitchWithMap){let t=i.mult(o);return n||(t=t.rotate(-a)),te(s.add(t),r.labelPlaneMatrix,r.getElevation).point}if(n){const e=he(r.tileAnchorPoint.x+1,r.tileAnchorPoint.y,r).point.sub(t),n=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(i.rotate(n))}return t.add(i)}function oa(t,r,n,i,a,o,s,l,c,u,h,f,p,d){const m=t.text.placedSymbolArray,g=t.text.dynamicLayoutVertexArray,y=t.icon.dynamicLayoutVertexArray,v={};g.clear();for(let y=0;y=0&&(v[x.associatedIconIndex]={shiftedAnchor:L,angle:I})}else ge(x.numGlyphs,g)}if(u){y.clear();const r=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(l,e,r):null,r="map"===n.layout.get("text-rotation-alignment");ne(c,l.posMatrix,t,a,j,V,v,u,r,g,l.toUnwrapped(),m.width,m.height,q,e)}const W=l.posMatrix,Z=a&&A||G,Y=x||Z?ea:j,X=U,$=p&&0!==n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let J;J=p?c.iconsInText?Wn(k.kind,L,_,v,x,Z,t,W,Y,X,q,P,R,S):Gn(k.kind,L,_,v,x,Z,t,W,Y,X,q,a,P,!0,S):Hn(k.kind,L,_,v,x,Z,t,W,Y,X,q,a,P,S);const K={program:C,buffers:h,uniformValues:J,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:D,atlasInterpolationIcon:O,isSDF:p,hasHalo:$};if(w&&c.canOverlap){T=!0;const t=h.segments.get();for(const r of t)M.push({segments:new e.a0([r]),sortKey:r.sortKey,state:K,terrainData:I})}else M.push({segments:h.segments,sortKey:0,state:K,terrainData:I})}T&&M.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of M){const r=e.state;if(p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),r.isSDF){const i=r.uniformValues;r.hasHalo&&(i.u_is_halo=1,ca(r.buffers,e.segments,n,t,r.program,k,h,f,i,e.terrainData)),i.u_is_halo=0}ca(r.buffers,e.segments,n,t,r.program,k,h,f,r.uniformValues,e.terrainData)}}function ca(t,e,r,n,i,a,o,s,l,c){const u=n.context,h=u.gl;i.draw(u,h.TRIANGLES,a,o,s,Ji.disabled,l,c,r.id,t.layoutVertexBuffer,t.indexBuffer,e,r.paint,n.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ua(t,r,n,i){if("translucent"!==t.renderPass)return;const a=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),s=n.paint.get("circle-stroke-opacity"),l=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=t.context,u=c.gl,h=t.depthModeForSublayer(0,Gi.ReadOnly),f=Yi.disabled,p=t.colorModeForRenderPass(),d=[];for(let a=0;at.sortKey-e.sortKey));for(const e of d){const{programConfiguration:r,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:l}=e.state,d=e.segments;i.draw(c,u.TRIANGLES,h,f,p,Ji.disabled,s,l,n.id,a,o,d,n.paint,t.transform.zoom,r)}}function ha(t,r,n,i){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const a=t.context,o=a.gl,s=Yi.disabled,l=new Vi([o.ONE,o.ONE],e.aN.transparent,[!0,!0,!0,!0]);fa(a,t,n),a.clear({color:e.aN.transparent});for(let e=0;e20&&a.texParameterf(a.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax);const _=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n),b=_?n:null,w=b?b.posMatrix:t.transform.calculatePosMatrix(n.toUnwrapped(),f),T=jn(w,v||[0,0],y||1,g,r);o instanceof Et?s.draw(i,a.TRIANGLES,u,Yi.disabled,l,Ji.disabled,T,_,r.id,o.boundsBuffer,t.quadTriangleIndexBuffer,o.boundsSegments):s.draw(i,a.TRIANGLES,u,c[n.overscaledZ],l,Ji.disabled,T,_,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}}function Aa(t,r,n,i,o,s){const l=i.paint.get("raster-fade-duration");if(!s&&l>0){const i=a.now(),s=(i-t.timeAdded)/l,c=r?(i-r.timeAdded)/l:-1,u=n.getSource(),h=o.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),f=!r||Math.abs(r.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),p=f&&t.refreshedUponExpiration?1:e.ad(f?s:1-c,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}function Ma(t,e,r,n){const i=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const o=t.context,s=o.gl,l=t.transform,c=l.tileSize,u=r.paint.get("background-pattern");if(t.isPatternMissing(u))return;const h=!u&&1===i.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==h)return;const f=Yi.disabled,p=t.depthModeForSublayer(0,"opaque"===h?Gi.ReadWrite:Gi.ReadOnly),d=t.colorModeForRenderPass(),m=t.useProgram(u?"backgroundPattern":"background"),g=n||l.coveringTiles({tileSize:c,terrain:t.style.map.terrain});u&&(o.activeTexture.set(s.TEXTURE0),t.imageManager.bind(t.context));const y=r.getCrossfadeParameters();for(const e of g){const l=n?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),h=u?Yn(l,a,t,u,{tileID:e,tileSize:c},y):Zn(l,a,i),g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);m.draw(o,s.TRIANGLES,p,f,d,Ji.disabled,h,g,r.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}}const Sa=new e.aN(1,0,0,1),Ea=new e.aN(0,1,0,1),Ca=new e.aN(0,0,1,1),La=new e.aN(1,0,1,1),Ia=new e.aN(0,1,1,1);function Pa(t){const e=t.transform.padding,r=3;Da(t,t.transform.height-(e.top||0),r,Sa),Da(t,e.bottom||0,r,Ea),Oa(t,e.left||0,r,Ca),Oa(t,t.transform.width-(e.right||0),r,La);const n=t.transform.centerPoint;za(t,n.x,t.transform.height-n.y,Ia)}function za(t,e,r,n){const i=20,a=2;Ra(t,e-a/2,r-i/2,a,i,n),Ra(t,e-i/2,r-a/2,i,a,n)}function Da(t,e,r,n){Ra(t,0,e+r/2,t.transform.width,r,n)}function Oa(t,e,r,n){Ra(t,e-r/2,0,r,t.transform.height,n)}function Ra(t,e,r,n,i,a){const o=t.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio,i*t.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Fa(t,e,r){for(let n=0;n ${n.overscaledZ}`),Na(t,`${v} ${m}kB`),s.draw(i,a.TRIANGLES,l,c,Vi.alphaBlended,Ji.disabled,Sn(o,e.aN.transparent,y),null,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(i,a.LINE_STRIP,l,c,u,Ji.disabled,Sn(o,e.aN.red),f,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Na(t,e){t.initDebugOverlayCanvas();const r=t.debugOverlayCanvas,n=t.context.gl,i=t.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,r.width,r.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(e,5,5),i.strokeText(e,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}function ja(t,e){let r=null;const n=Object.values(t._layers).flatMap((r=>r.source&&!r.isHidden(e)?[t.sourceCaches[r.source]]:[])),i=n.filter((t=>"vector"===t.getSource().type)),a=n.filter((t=>"vector"!==t.getSource().type)),o=t=>{(!r||r.getSource().maxzoomo(t))),r||a.forEach((t=>o(t))),r}function Ua(t,e,r){const n=t.context,i=r.implementation;if("offscreen"===t.renderPass){const e=i.prerender;e&&(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),e.call(i,n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(Yi.disabled);const e="3d"===i.renderingMode?new Gi(t.context.gl.LEQUAL,Gi.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Gi.ReadOnly);n.setDepthMode(e),i.render(n.gl,t.transform.customLayerMatrix(),{farZ:t.transform.farZ,nearZ:t.transform.nearZ,fov:t.transform._fov,modelViewProjectionMatrix:t.transform.modelViewProjectionMatrix,projectionMatrix:t.transform.projectionMatrix}),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}}function Va(t,r){const n=t.context,i=n.gl,a=Vi.unblended,o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=r.getTerrainMesh(),l=r.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");n.bindFramebuffer.set(r.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aN.transparent,depth:1});for(const e of l){const l=r.getTerrainData(e.tileID),u=t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),h=fn(u,r.getMeshFrameDelta(t.transform.zoom));c.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,h,l,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}function qa(t,r){const n=t.context,i=n.gl,a=Vi.unblended,o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=r.getTerrainMesh(),l=r.getCoordsTexture(),c=r.sourceCache.getRenderableTiles(),u=t.useProgram("terrainCoords");n.bindFramebuffer.set(r.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aN.transparent,depth:1}),r.coordsIndex=[];for(const e of c){const c=r.getTerrainData(e.tileID);n.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,l.texture);const h=t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),f=pn(h,255-r.coordsIndex.length,r.getMeshFrameDelta(t.transform.zoom));u.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,f,c,"terrain",s.vertexBuffer,s.indexBuffer,s.segments),r.coordsIndex.push(e.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}function Ha(t,e,r){const n=t.context,i=n.gl,a=t.colorModeForRenderPass(),o=new Gi(i.LEQUAL,Gi.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh();n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]);for(const c of r){const r=t.renderToTexture.getTexture(c),u=e.getTerrainData(c.tileID);n.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,r.texture);const h=t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),f=e.getMeshFrameDelta(t.transform.zoom),p=t.transform.calculateFogMatrix(c.tileID.toUnwrapped()),d=hn(h,f,p,t.style.sky,t.transform.pitch);s.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,d,u,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class Ga{constructor(t,e,r){this.vertexBuffer=t,this.indexBuffer=e,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}function Wa(t,r){const n=t.context,i=n.gl,a=Xn(r,t.style.map.transform,t.pixelRatio),o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=Yi.disabled,l=t.colorModeForRenderPass(),c=t.useProgram("sky");if(!r.mesh){const t=new e.aX;t.emplaceBack(-1,-1),t.emplaceBack(1,-1),t.emplaceBack(1,1),t.emplaceBack(-1,1);const i=new e.aY;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),r.mesh=new Ga(n.createVertexBuffer(t,Ke.members),n.createIndexBuffer(i),e.a0.simpleSegment(0,0,t.length,i.length))}c.draw(n,i.TRIANGLES,o,s,l,Ji.disabled,a,void 0,"sky",r.mesh.vertexBuffer,r.mesh.indexBuffer,r.mesh.segments)}class Za{constructor(t,r){this.context=new qi(t),this.transform=r,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Wt.maxUnderzooming+Wt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ye}resize(t,e,r){if(this.width=Math.floor(t*r),this.height=Math.floor(e*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,r=new e.aX;r.emplaceBack(0,0),r.emplaceBack(e.X,0),r.emplaceBack(0,e.X),r.emplaceBack(e.X,e.X),this.tileExtentBuffer=t.createVertexBuffer(r,Ke.members),this.tileExtentSegments=e.a0.simpleSegment(0,0,4,2);const n=new e.aX;n.emplaceBack(0,0),n.emplaceBack(e.X,0),n.emplaceBack(0,e.X),n.emplaceBack(e.X,e.X),this.debugBuffer=t.createVertexBuffer(n,Ke.members),this.debugSegments=e.a0.simpleSegment(0,0,4,5);const i=new e.$;i.emplaceBack(0,0,0,0),i.emplaceBack(e.X,0,e.X,0),i.emplaceBack(0,e.X,0,e.X),i.emplaceBack(e.X,e.X,e.X,e.X),this.rasterBoundsBuffer=t.createVertexBuffer(i,St.members),this.rasterBoundsSegments=e.a0.simpleSegment(0,0,4,2);const a=new e.aX;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(a,Ke.members),this.viewportSegments=e.a0.simpleSegment(0,0,4,2);const o=new e.aZ;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);const s=new e.aY;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const l=this.context.gl;this.stencilClearMode=new Yi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}clearStencil(){const t=this.context,r=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=e.H();e.aQ(n,0,this.width,this.height,0,0,1),e.K(n,n,[r.drawingBufferWidth,r.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,r.TRIANGLES,Gi.disabled,this.stencilClearMode,Vi.disabled,Ji.disabled,En(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const r=this.context,n=r.gl;this.nextStencilID+e.length>256&&this.clearStencil(),r.setColorMode(Vi.disabled),r.setDepthMode(Gi.disabled);const i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);i.draw(r,n.TRIANGLES,Gi.disabled,new Yi({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Vi.disabled,Ji.disabled,En(t.posMatrix),a,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Yi({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Yi({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,r=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=r[r.length-1].overscaledZ,i=r[0].overscaledZ-n+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],e=o[t.source],r=s[t.source];this._renderTileClippingMasks(t,r),this.renderLayer(this,e,t,r)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer0),i&&(e.b0(r,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,Va(this,this.style.map.terrain),qa(this,this.style.map.terrain))}renderLayer(t,e,r,n){if(!r.isHidden(this.transform.zoom)&&("background"===r.type||"custom"===r.type||(n||[]).length))switch(this.id=r.id,r.type){case"symbol":ra(t,e,r,n,this.style.placement.variableOffsets);break;case"circle":ua(t,e,r,n);break;case"heatmap":ha(t,e,r,n);break;case"line":ma(t,e,r,n);break;case"fill":ya(t,e,r,n);break;case"fill-extrusion":xa(t,e,r,n);break;case"hillshade":ba(t,e,r,n);break;case"raster":ka(t,e,r,n);break;case"background":Ma(t,e,r,n);break;case"custom":Ua(t,e,r)}}translatePosMatrix(t,r,n,i,a){if(!n[0]&&!n[1])return t;const o=a?"map"===i?this.transform.angle:0:"viewport"===i?-this.transform.angle:0;if(o){const t=Math.sin(o),e=Math.cos(o);n=[n[0]*e-n[1]*t,n[0]*t+n[1]*e]}const s=[a?n[0]:_e(r,n[0],this.transform.zoom),a?n[1]:_e(r,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.J(l,t,s),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),r=this.imageManager.getPattern(t.to.toString());return!e||!r}useProgram(t,e){this.cache=this.cache||{};const r=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[r]||(this.cache[r]=new mn(this.context,nn[t],e,$n[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[r]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;const t=this.context.gl;this.debugOverlayTexture=new B(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class Ya{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,r,n){const i=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]],a=Math.pow(2,n),o=i.map((n=>{const i=1/(n=e.ag([],n,t))[3]/r*a;return e.b1(n,n,[i,i,1/n[3],i])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=A([],S([],C([],o[t[0]],o[t[1]]),C([],o[t[2]],o[t[1]]))),r=-M(e,o[t[1]]);return e.concat(r)}));return new Ya(o,s)}}class Xa{constructor(t,e){this.min=t,this.max=e,this.center=k([],w([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],r=b(this.min),n=b(this.max);for(let t=0;t=0&&o++;if(0===o)return 0;o!==r.length&&(n=!1)}if(n)return 2;for(let e=0;e<3;e++){let r=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let i=0;ithis.max[e]-this.min[e])return 0}return 1}}class $a{constructor(t=0,e=0,r=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(r)||r<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=r,this.right=n}interpolate(t,r,n){return null!=r.top&&null!=t.top&&(this.top=e.z.number(t.top,r.top,n)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.z.number(t.bottom,r.bottom,n)),null!=r.left&&null!=t.left&&(this.left=e.z.number(t.left,r.left,n)),null!=r.right&&null!=t.right&&(this.right=e.z.number(t.right,r.right,n)),this}getCenter(t,r){const n=e.ad((this.left+t-this.right)/2,0,t),i=e.ad((this.top+r-this.bottom)/2,0,r);return new e.P(n,i)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new $a(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Ja=85.051129;class Ka{constructor(t,r,n,i,a){this.tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=null==n?0:n,this._maxPitch=null==i?60:i,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new $a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new Ka(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const r=-e.b3(t,-180,180)*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=g(),y(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=e.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,r){this._unmodified=!1,this._edgeInsets.interpolate(t,e,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const r=[new e.b4(0,t)];if(this._renderWorldCopies){const n=this.pointCoordinate(new e.P(0,0)),i=this.pointCoordinate(new e.P(this.width,0)),a=this.pointCoordinate(new e.P(this.width,this.height)),o=this.pointCoordinate(new e.P(0,this.height)),s=Math.floor(Math.min(n.x,i.x,a.x,o.x)),l=Math.floor(Math.max(n.x,i.x,a.x,o.x)),c=1;for(let n=s-c;n<=l+c;n++)0!==n&&r.push(new e.b4(n,t))}return r}coveringTiles(t){var r,n;let i=this.coveringZoomLevel(t);const a=i;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const o=this.pointCoordinate(this.getCameraPoint()),s=e.Z.fromLngLat(this.center),l=Math.pow(2,i),c=[l*o.x,l*o.y,0],u=[l*s.x,l*s.y,0],h=Ya.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,i);let f=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(f=i);const p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,d=t=>({aabb:new Xa([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],g=[],y=i,v=t.reparseOverscaled?a:i;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(d(-t)),m.push(d(t));for(m.push(d(0));m.length>0;){const i=m.pop(),a=i.x,o=i.y;let s=i.fullyVisible;if(!s){const t=i.aabb.intersects(h);if(0===t)continue;s=2===t}const l=t.terrain?c:u,d=i.aabb.distanceX(l),x=i.aabb.distanceY(l),_=Math.max(Math.abs(d),Math.abs(x)),b=p+(1<b&&i.zoom>=f){const t=y-i.zoom,r=c[0]-.5-(a<>1),h=i.zoom+1;let f=i.aabb.quadrant(l);if(t.terrain){const a=new e.S(h,i.wrap,h,c,u),o=t.terrain.getMinMaxElevation(a),s=null!==(r=o.minElevation)&&void 0!==r?r:this.elevation,l=null!==(n=o.maxElevation)&&void 0!==n?n:this.elevation;f=new Xa([f.min[0],f.min[1],s],[f.max[0],f.max[1],l])}m.push({aabb:f,zoom:h,x:c,y:u,wrap:i.wrap,fullyVisible:s})}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const r=e.ad(t.lat,-Ja,Ja);return new e.P(e.O(t.lng)*this.worldSize,e.Q(r)*this.worldSize)}unproject(t){return new e.Z(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const r=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,i=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(i,this.tileZoom);if(!(this.elevation-a))return;const o=n+r-a,s=Math.cos(this._pitch)*this.cameraToCenterDistance/o/e.b5(1,i.lat)/this.tileSize,l=this.scaleZoom(s);this._elevation=a,this._center=i,this.zoom=l}setLocationAtPoint(t,r){const n=this.pointCoordinate(r),i=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(t),o=new e.Z(a.x-(n.x-i.x),a.y-(n.y-i.y));this.center=this.coordinateLocation(o),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,r){if(r){const e=r.pointCoordinate(t);if(null!=e)return e}const n=0,i=[t.x,t.y,0,1],a=[t.x,t.y,1,1];e.ag(i,i,this.pixelMatrixInverse),e.ag(a,a,this.pixelMatrixInverse);const o=i[3],s=a[3],l=i[0]/o,c=a[0]/s,u=i[1]/o,h=a[1]/s,f=i[2]/o,p=a[2]/s,d=f===p?0:(n-f)/(p-f);return new e.Z(e.z.number(l,c,d)/this.worldSize,e.z.number(u,h,d)/this.worldSize)}coordinatePoint(t,r=0,n=this.pixelMatrix){const i=[t.x*this.worldSize,t.y*this.worldSize,r,1];return e.ag(i,i,n),new e.P(i[0]/i[3],i[1]/i[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new bt).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new bt([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-Ja,Ja])}calculateTileMatrix(t){const r=t.canonical,n=this.worldSize/this.zoomScale(r.z),i=r.x+Math.pow(2,r.z)*t.wrap,a=e.ao(new Float64Array(16));return e.J(a,a,[i*n,r.y*n,0]),e.K(a,a,[n/e.X,n/e.X,1]),a}calculatePosMatrix(t,r=!1){const n=t.key,i=r?this._alignedPosMatrixCache:this._posMatrixCache;if(i[n])return i[n];const a=this.calculateTileMatrix(t);return e.L(a,r?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,a),i[n]=new Float32Array(a),i[n]}calculateFogMatrix(t){const r=t.key,n=this._fogMatrixCache;if(n[r])return n[r];const i=this.calculateTileMatrix(t);return e.L(i,this.fogMatrix,i),n[r]=new Float32Array(i),n[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,r){r=e.ad(+r,this.minZoom,this.maxZoom);const n={center:new e.N(t.lng,t.lat),zoom:r};let i=this.lngRange;if(!this._renderWorldCopies&&null===i){const t=180-1e-10;i=[-t,t]}const a=this.tileSize*this.zoomScale(n.zoom);let o=0,s=a,l=0,c=a,u=0,h=0;const{x:f,y:p}=this.size;if(this.latRange){const t=this.latRange;o=e.Q(t[1])*a,s=e.Q(t[0])*a,s-os&&(y=s-t)}if(i){const t=(l+c)/2;let r=d;this._renderWorldCopies&&(r=e.b3(d,t-a/2,t+a/2));const n=f/2;r-nc&&(g=c-n)}if(void 0!==g||void 0!==y){const t=new e.P(null!=g?g:d,null!=y?y:m);n.center=this.unproject.call({worldSize:a},t).wrap()}return n}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:r}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=r,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this._fov/2,r=this.centerOffset,n=this.point.x,i=this.point.y;this.cameraToCenterDistance=.5/Math.tan(t)*this.height,this._pixelPerMeter=e.b5(1,this.center.lat)*this.worldSize;let a=e.ao(new Float64Array(16));e.K(a,a,[this.width/2,-this.height/2,1]),e.J(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=e.ao(new Float64Array(16)),e.K(a,a,[1,-1,1]),e.J(a,a,[-1,-1,0]),e.K(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;const o=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),s=Math.min(this.elevation,this.minElevationForCurrentTile),l=o-s*this._pixelPerMeter/Math.cos(this._pitch),c=s<0?l:o,u=Math.PI/2+this._pitch,h=this._fov*(.5+r.y/this.height),f=Math.sin(h)*c/Math.sin(e.ad(Math.PI-u-h,.01,Math.PI-.01)),p=this.getHorizon(),d=2*Math.atan(p/this.cameraToCenterDistance)*(.5+r.y/(2*p)),m=Math.sin(d)*c/Math.sin(e.ad(Math.PI-u-d,.01,Math.PI-.01)),g=Math.min(f,m);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*g+c),this.nearZ=this.height/50,a=new Float64Array(16),e.b6(a,this._fov,this.width/this.height,this.nearZ,this.farZ),a[8]=2*-r.x/this.width,a[9]=2*r.y/this.height,this.projectionMatrix=e.af(a),e.K(a,a,[1,-1,1]),e.J(a,a,[0,0,-this.cameraToCenterDistance]),e.b7(a,a,this._pitch),e.ae(a,a,this.angle),e.J(a,a,[-n,-i,0]),this.mercatorMatrix=e.K([],a,[this.worldSize,this.worldSize,this.worldSize]),e.K(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.L(new Float64Array(16),this.labelPlaneMatrix,a),e.J(a,a,[0,0,-this.elevation]),this.modelViewProjectionMatrix=a,this.invModelViewProjectionMatrix=e.at([],a),this.fogMatrix=new Float64Array(16),e.b6(this.fogMatrix,this._fov,this.width/this.height,o,this.farZ),this.fogMatrix[8]=2*-r.x/this.width,this.fogMatrix[9]=2*r.y/this.height,e.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),e.b7(this.fogMatrix,this.fogMatrix,this._pitch),e.ae(this.fogMatrix,this.fogMatrix,this.angle),e.J(this.fogMatrix,this.fogMatrix,[-n,-i,0]),e.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=e.L(new Float64Array(16),this.labelPlaneMatrix,a);const y=this.width%2/2,v=this.height%2/2,x=Math.cos(this.angle),_=Math.sin(this.angle),b=n-Math.round(n)+x*y+_*v,w=i-Math.round(i)+x*v+_*y,T=new Float64Array(a);if(e.J(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedModelViewProjectionMatrix=T,a=e.at(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new e.P(0,0)),r=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.ag(r,r,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=this._pitch,r=Math.tan(t)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,r))}getCameraQueryGeometry(t){const r=this.getCameraPoint();if(1===t.length)return[t[0],r];{let n=r.x,i=r.y,a=r.x,o=r.y;for(const e of t)n=Math.min(n,e.x),i=Math.min(i,e.y),a=Math.max(a,e.x),o=Math.max(o,e.y);return[new e.P(n,i),new e.P(a,i),new e.P(a,o),new e.P(n,o),new e.P(n,i)]}}lngLatToCameraDepth(t,r){const n=this.locationCoordinate(t),i=[n.x*this.worldSize,n.y*this.worldSize,r,1];return e.ag(i,i,this.modelViewProjectionMatrix),i[2]/i[3]}}function Qa(t,e){let r,n=!1,i=null,a=null;const o=()=>{i=null,n&&(t.apply(a,r),i=setTimeout(o,e),n=!1)};return(...t)=>(n=!0,a=this,r=t,i||o(),i)}class to{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.+)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let r=e;r.split("&").length>0&&(r=r.split("&")[0]),this._hashName&&(r=`${this._hashName}=${e}`);let n=window.location.hash.replace(r,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let i=window.location.href.replace(/(#.+)?$/,n);i=i.replace("&&","&"),window.history.replaceState(window.history.state,null,i)},this._updateHash=Qa(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,n),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${a}/${o}/${r}`:`${r}/${o}/${a}`,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const r=window.location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===t?(e=!0,`${n}=${c}`):r})).filter((t=>t));return e||r.push(`${t}=${c}`),`#${r.join("&")}`}return`#${c}`}}const eo={linearity:.3,easing:e.b8(0,0,.3,1)},ro=e.e({deceleration:2500,maxSpeed:1400},eo),no=e.e({deceleration:20,maxSpeed:1400},eo),io=e.e({deceleration:1e3,maxSpeed:360},eo),ao=e.e({deceleration:1e3,maxSpeed:90},eo);class oo{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=a.now(),r=160;for(;t.length>0&&e-t[0].time>r;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)r.zoom+=t.zoomDelta||0,r.bearing+=t.bearingDelta||0,r.pitch+=t.pitchDelta||0,t.panDelta&&r.pan._add(t.panDelta),t.around&&(r.around=t.around),t.pinchAround&&(r.pinchAround=t.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(r.pan.mag()){const a=lo(r.pan.mag(),n,e.e({},ro,t||{}));i.offset=r.pan.mult(a.amount/r.pan.mag()),i.center=this._map.transform.center,so(i,a)}if(r.zoom){const t=lo(r.zoom,n,no);i.zoom=this._map.transform.zoom+t.amount,so(i,t)}if(r.bearing){const t=lo(r.bearing,n,io);i.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),so(i,t)}if(r.pitch){const t=lo(r.pitch,n,ao);i.pitch=this._map.transform.pitch+t.amount,so(i,t)}if(i.zoom||i.bearing){const t=void 0===r.pinchAround?r.around:r.pinchAround;i.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(i,{noMoveStart:!0})}}function so(t,e){(!t.duration||t.durationr.unproject(t))),l=a.reduce(((t,e,r,n)=>t.add(e.div(n.length))),new e.P(0,0));super(t,{points:a,point:l,lngLats:s,lngLat:r.unproject(l),originalEvent:n}),this._defaultPrevented=!1}}class ho extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,r){super(t,{originalEvent:r}),this._defaultPrevented=!1}}class fo{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new ho(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new co(t.type,this._map,t))}mouseup(t){this._map.fire(new co(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new co(t.type,this._map,t))}dblclick(t){return this._firePreventable(new co(t.type,this._map,t))}mouseover(t){this._map.fire(new co(t.type,this._map,t))}mouseout(t){this._map.fire(new co(t.type,this._map,t))}touchstart(t){return this._firePreventable(new uo(t.type,this._map,t))}touchmove(t){this._map.fire(new uo(t.type,this._map,t))}touchend(t){this._map.fire(new uo(t.type,this._map,t))}touchcancel(t){this._map.fire(new uo(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class po{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new co(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new co("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new co(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class mo{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class go{constructor(t,e){this._map=t,this._tr=new mo(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(o.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const r=e;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)t.fitScreenCoordinates(n,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(o.remove(this._box),this._box=null),o.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new e.k(t,{originalEvent:r}))}}function yo(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const r={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=vo(e),this.touches=yo(r,e)))}touchmove(t,e,r){if(this.aborted||!this.centroid)return;const n=yo(r,e);for(const t in this.touches){const e=this.touches[t],r=n[t];(!r||r.dist(e)>bo)&&(this.aborted=!0)}}touchend(t,e,r){if((!this.centroid||t.timeStamp-this.startTime>_o)&&(this.aborted=!0),0===r.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class To{constructor(t){this.singleTap=new wo(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,r){this.singleTap.touchstart(t,e,r)}touchmove(t,e,r){this.singleTap.touchmove(t,e,r)}touchend(t,e,r){const n=this.singleTap.touchend(t,e,r);if(n){const e=t.timeStamp-this.lastTimethis.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(n)},{originalEvent:t})}):i?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(i)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ao{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const r=this._lastPoint;if(!r)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const n=e.length?e[0]:e;return!this._moved&&n.dist(r){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}},Oo=({enable:t,clickTolerance:e})=>{const r=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&!t.ctrlKey});return new Ao({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:r,enable:t,assignEvents:Do})},Ro=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:r=.8})=>{const n=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&t.ctrlKey||o.mouseButton(t)===zo});return new Ao({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*r}),moveStateManager:n,enable:t,assignEvents:Do})},Fo=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:r=-.5})=>{const n=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&t.ctrlKey||o.mouseButton(t)===zo});return new Ao({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*r}),moveStateManager:n,enable:t,assignEvents:Do})};class Bo{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,r){return this._calculateTransform(t,e,r)}touchmove(t,e,r){if(this._active){if(!this._shouldBePrevented(r.length))return t.preventDefault(),this._calculateTransform(t,e,r);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,r){this._calculateTransform(t,e,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,r,n){n.length>0&&(this._active=!0);const i=yo(n,r),a=new e.P(0,0),o=new e.P(0,0);let s=0;for(const t in i){const e=i[t],r=this._touches[t];r&&(a._add(e),o._add(e.sub(r)),s++,i[t]=e)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;const l=o.div(s);return this._sum._add(l),this._sum.mag()Math.abs(t.x)}const Yo=100;class Xo extends No{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,r){super.touchstart(t,e,r),this._currentTouchCount=r.length}_start(t){this._lastPoints=t,Zo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=t[0].sub(this._lastPoints[0]),i=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,i,r.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,r){if(void 0!==this._valid)return this._valid;const n=2,i=t.mag()>=n,a=e.mag()>=n;if(!i&&!a)return;if(!i||!a)return void 0===this._firstMove&&(this._firstMove=r),r-this._firstMove0==e.y>0;return Zo(t)&&Zo(e)&&o}}const $o={panStep:100,bearingStep:15,pitchStep:10};class Jo{constructor(t){this._tr=new mo(t);const e=$o;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,r=0,n=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,n=0),{cameraAnimation:o=>{const s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:Ko,zoom:e?Math.round(s.zoom)+e*(t.shiftKey?2:1):s.zoom,bearing:s.bearing+r*this._bearingStep,pitch:s.pitch+n*this._pitchStep,offset:[-i*this._panStep,-a*this._panStep],center:s.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ko(t){return t*(2-t)}const Qo=4.000244140625,ts=.01,es=1/450,rs=2;class ns{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new mo(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=ts,this._wheelZoomRate=es}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=a.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==e&&e%Qo==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const r=o.mousePos(this._map.getCanvas(),t),n=this._tr;r.y>n.transform.height/2-n.transform.getHorizon()?this._around=e.N.convert(this._aroundCenter?n.center:n.unproject(r)):this._around=e.N.convert(n.center),this._aroundPoint=n.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Qo?this._wheelZoomRate:this._defaultZoomRate;let r=rs/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*r))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:t.zoom,n=this._startZoom,i=this._easing;let o,s=!1;const l=a.now()-this._lastWheelEventTime;if("wheel"===this._type&&n&&i&&l){const t=Math.min(l/200,1),a=i(t);o=e.z.number(n,r,a),t<1?this._frameId||(this._frameId=!0):s=!0}else o=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=e.b9;if(this._prevEase){const t=this._prevEase,n=(a.now()-t.start)/t.duration,i=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(i*i+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.b8(o,s,.25,1)}return this._prevEase={start:a.now(),duration:t,easing:r},r}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class is{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class as{constructor(t){this._tr=new mo(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class os{constructor(){this._tap=new To({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,r){if(!this._swipePoint)if(this._tapTime){const n=e[0],i=t.timeStamp-this._tapTime0&&(this._swipePoint=n,this._swipeTouch=r[0].identifier):this.reset()}else this._tap.touchstart(t,e,r)}touchmove(t,e,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;const n=e[0],i=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(t,e,r)}touchend(t,e,r){if(this._tapTime)this._swipePoint&&0===r.length&&this.reset();else{const n=this._tap.touchend(t,e,r);n&&(this._tapTime=t.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ss{constructor(t,e,r){this._el=t,this._mousePan=e,this._touchPan=r}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ls{constructor(t,e,r){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class cs{constructor(t,e,r,n){this._el=t,this._touchZoom=e,this._touchRotate=r,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class us{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=o.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=e,this._container.appendChild(n);const i=document.createElement("div");i.className="maplibregl-mobile-message",i.textContent=r,this._container.appendChild(i),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(o.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,r){this._enabled&&(this._map.fire(new e.k("cooperativegestureprevented",{gestureType:t,originalEvent:r})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const hs=t=>t.zoom||t.drag||t.pitch||t.rotate;class fs extends e.k{}function ps(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ds{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},i={},a={},s=t.touches,l=s?this._getMapTouches(s):void 0,c=l?o.touchPos(this._map.getCanvas(),l):o.mousePos(this._map.getCanvas(),t);for(const{handlerName:o,handler:s,allowed:u}of this._handlers){if(!s.isEnabled())continue;let h;this._blockedByActive(a,u,o)?s.reset():s[e||t.type]&&(h=s[e||t.type](t,c,l),this.mergeHandlerResult(n,i,h,o,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||s.isActive())&&(a[o]=s)}const u={};for(const t in this._previousActiveHandlers)a[t]||(u[t]=r);this._previousActiveHandlers=a,(Object.keys(u).length||ps(n))&&(this._changes.push([n,i,u]),this._triggerRenderFrame()),(Object.keys(a).length||ps(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new oo(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,r]of this._listeners)o.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,e,r]of this._listeners)o.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,r=e.getCanvasContainer();this._add("mapEvent",new fo(e,t));const n=e.boxZoom=new go(e,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();const i=e.cooperativeGestures=new us(e,t.cooperativeGestures);this._add("cooperativeGestures",i),t.cooperativeGestures&&i.enable();const a=new ko(e),o=new as(e);e.doubleClickZoom=new is(o,a),this._add("tapZoom",a),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const s=new os;this._add("tapDragZoom",s);const l=e.touchPitch=new Xo(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const c=Ro(t),u=Fo(t);e.dragRotate=new ls(t,c,u),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const h=Oo(t),f=new Bo(t,e);e.dragPan=new ss(r,h,f),this._add("mousePan",h),this._add("touchPan",f,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const p=new Wo,d=new qo;e.touchZoomRotate=new cs(r,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const m=e.scrollZoom=new ns(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",m,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const g=e.keyboard=new Jo(e);this._add("keyboard",g),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new po(e))}_add(t,e,r){this._handlers.push({handlerName:t,handler:e,allowed:r}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(hs(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,r){for(const n in t)if(n!==r&&(!e||e.indexOf(n)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const r of t){const t=r.target;this._el.contains(t)&&e.push(r)}return e}mergeHandlerResult(t,r,n,i,a){if(!n)return;e.e(t,n);const o={handlerName:i,originalEvent:n.originalEvent||a};void 0!==n.zoomDelta&&(r.zoom=o),void 0!==n.panDelta&&(r.drag=o),void 0!==n.pitchDelta&&(r.pitch=o),void 0!==n.bearingDelta&&(r.rotate=o)}_applyChanges(){const t={},r={},n={};for(const[i,a,o]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.e(r,a),e.e(n,o);this._updateMapTransform(t,r,n),this._changes=[]}_updateMapTransform(t,e,r){const n=this._map,i=n._getTransformForUpdate(),a=n.terrain;if(!(ps(t)||a&&this._terrainMovement))return this._fireEvents(e,r,!0);let{panDelta:o,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:u,pinchAround:h}=t;void 0!==h&&(u=h),n._stop(!0),u=u||n.transform.centerPoint;const f=i.pointLocation(o?u.sub(o):u);l&&(i.bearing+=l),c&&(i.pitch+=c),s&&(i.zoom+=s),a?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?i.center=i.pointLocation(i.centerPoint.sub(o)):i.setLocationAtPoint(f,u):(this._terrainMovement=!0,this._map._elevationFreeze=!0,i.setLocationAtPoint(f,u)):i.setLocationAtPoint(f,u),n._applyUpdatedTransform(i),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,r,!0)}_fireEvents(t,r,n){const i=hs(this._eventsInProgress),o=hs(t),s={};for(const e in t){const{originalEvent:r}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=r),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:r}=t[e];this._fireEvent(e,r)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=r[e]||n,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const u=hs(this._eventsInProgress),h=(i||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();t.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(t)}if(n&&h){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new fs("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class ms extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{const t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new e.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,r,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},r),n)}panTo(t,r,n){return this.easeTo(e.e({center:t},r),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,r,n){return this.easeTo(e.e({zoom:t},r),n)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,r,n){return this.easeTo(e.e({bearing:t},r),n)}resetNorth(t,r){return this.rotateTo(0,e.e({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(i.zoom=e.z.number(o,y,n)),this._rotating&&(i.bearing=e.z.number(s,u,n)),this._pitching&&(i.pitch=e.z.number(l,h,n)),this._padding&&(i.interpolatePadding(c,f,n),d=i.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n),b)i.setLocationAtPoint(b,w);else{const t=i.zoomScale(i.zoom-o),e=y>o?Math.min(2,_):Math.max(.5,_),r=Math.pow(e,1-n),a=i.unproject(v.add(x.mult(n*r)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,d)}this._applyUpdatedTransform(i),this._fireMoveEvents(r)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(r,e)}),t),this}_prepareEase(t,r,n={}){this._moving=!0,r||n.moving||this.fire(new e.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const r=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&r!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart,n=(r-(e*t+this._elevationStart))/(1-t);this._elevationStart+=t*(e-n),this._elevationTarget=r}this.transform.elevation=e.z.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){const e=t.getCameraPosition(),r=this.terrain.getElevationForLngLatZoom(e.lngLat,t.zoom);if(e.altitudethis._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const r=t.clone();for(const t of e){const e=r.clone(),{center:n,zoom:i,pitch:a,bearing:o,elevation:s}=t(e);n&&(e.center=n),void 0!==i&&(e.zoom=i),void 0!==a&&(e.pitch=a),void 0!==o&&(e.bearing=o),void 0!==s&&(e.elevation=s),r.apply(e)}this.transform.apply(r)}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;delete this._easeId;const n=this._zooming,i=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.k("zoomend",t)),i&&this.fire(new e.k("rotateend",t)),a&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t))}flyTo(t,r){var n;if(!t.essential&&a.prefersReducedMotion){const n=e.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,r)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b9},t);const i=this._getTransformForUpdate(),o=i.zoom,s=i.bearing,l=i.pitch,c=i.padding,u="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:l,f="padding"in t?t.padding:i.padding,p=e.P.convert(t.offset);let d=i.centerPoint.add(p);const m=i.pointLocation(d),{center:g,zoom:y}=i.getConstrained(e.N.convert(t.center||m),null!==(n=t.zoom)&&void 0!==n?n:o);this._normalizeCenter(g,i);const v=i.zoomScale(y-o),x=i.project(m),_=i.project(g).sub(x);let b=t.curve;const w=Math.max(i.width,i.height),T=w/v,k=_.mag();if("minZoom"in t){const r=e.ad(Math.min(t.minZoom,o,y),i.minZoom,i.maxZoom),n=w/i.zoomScale(r-o);b=Math.sqrt(n/k*2)}const A=b*b;function M(t){const e=(T*T-w*w+(t?-1:1)*A*A*k*k)/(2*(t?T:w)*A*k);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function E(t){return(Math.exp(t)+Math.exp(-t))/2}function C(t){return S(t)/E(t)}const L=M(!1);let I=function(t){return E(L)/E(L+b*t)},P=function(t){return w*((E(L)*C(L+b*t)-S(L))/A)/k},z=(M(!0)-L)/b;if(Math.abs(k)<1e-6||!isFinite(z)){if(Math.abs(w-T)<1e-6)return this.easeTo(t,r);const e=T0,I=t=>Math.exp(e*b*t)}if("duration"in t)t.duration=+t.duration;else{const e="screenSpeed"in t?+t.screenSpeed/b:+t.speed;t.duration=1e3*z/e}return t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==u,this._pitching=h!==l,this._padding=!i.isPaddingEqual(f),this._prepareEase(r,!1),this.terrain&&this._prepareElevation(g),this._ease((n=>{const a=n*z,m=1/I(a);i.zoom=1===n?y:o+i.scaleZoom(m),this._rotating&&(i.bearing=e.z.number(s,u,n)),this._pitching&&(i.pitch=e.z.number(l,h,n)),this._padding&&(i.interpolatePadding(c,f,n),d=i.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n);const v=1===n?g:i.unproject(x.add(_.mult(P(a))).mult(m));i.setLocationAtPoint(i.renderWorldCopies?v.wrap():v,d),this._applyUpdatedTransform(i),this._fireMoveEvents(r)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(r)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var r;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(r=this.handlers)||void 0===r||r.stop(!1),this}_ease(t,e,r){!1===r.animate||0===r.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,r){t=e.b3(t,-180,180);const n=Math.abs(t-r);return Math.abs(t-360-r)180?-360:r<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const gs={compact:!0,customAttribution:'MapLibre'};class ys{constructor(t=gs){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=o.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=o.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){o.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const r=this._map._getUIString(`AttributionControl.${e}`);t.title=r,t.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const r in e){const n=e[r];if(n.used||n.usedForTerrain){const e=n.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,r)=>{for(let n=r+1;n=0)return!1;return!0}));const r=t.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,t.length?(this._innerContainer.innerHTML=r,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class vs{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=o.create("div","maplibregl-ctrl");const e=o.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){o.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class xs{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,r=e?this._queue.concat(e):this._queue;for(const e of r)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const r of e)if(!r.cancelled&&(r.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var _s=e.Y([{name:"a_pos3d",type:"Int16",components:3}]);class bs extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,r){this.sourceCache.update(t,r),this._renderableTilesKeys=[];const n={};for(const i of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:r}))n[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.posMatrix=new Float64Array(16),e.aQ(i.posMatrix,0,e.X,0,e.X,0,1),this._tiles[i.key]=new qt(i,this.tileSize));for(const t in this._tiles)n[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const r=this._tiles[e];(!t||r.tileID.equals(t)||r.tileID.isChildOf(t)||t.isChildOf(r.tileID))&&(r.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const r={};for(const n of this._renderableTilesKeys){const i=this._tiles[n].tileID;if(i.canonical.equals(t.canonical)){const i=t.clone();i.posMatrix=new Float64Array(16),e.aQ(i.posMatrix,0,e.X,0,e.X,0,1),r[n]=i}else if(i.canonical.isChildOf(t.canonical)){const a=t.clone();a.posMatrix=new Float64Array(16);const o=i.canonical.z-t.canonical.z,s=i.canonical.x-(i.canonical.x>>o<>o<>o;e.aQ(a.posMatrix,0,c,0,c,0,1),e.J(a.posMatrix,a.posMatrix,[-s*c,-l*c,0]),r[n]=a}else if(t.canonical.isChildOf(i.canonical)){const a=t.clone();a.posMatrix=new Float64Array(16);const o=t.canonical.z-i.canonical.z,s=t.canonical.x-(t.canonical.x>>o<>o<>o;e.aQ(a.posMatrix,0,e.X,0,e.X,0,1),e.J(a.posMatrix,a.posMatrix,[s*c,l*c,0]),e.K(a.posMatrix,a.posMatrix,[1/2**o,1/2**o,0]),r[n]=a}}return r}getSourceTile(t,e){const r=this.sourceCache._source;let n=t.overscaledZ-this.deltaZoom;if(n>r.maxzoom&&(n=r.maxzoom),n=r.minzoom&&(!i||!i.dem);)i=this.sourceCache.getTileByID(t.scaledTo(n--).key);return i}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class ws{constructor(t,e,r){this.painter=t,this.sourceCache=new bs(e),this.options=r,this.exaggeration="number"==typeof r.exaggeration?r.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,r,n,i=e.X){var a;if(!(r>=0&&r=0&&nt.canonical.z&&(t.canonical.z>=n?i=t.canonical.z-n:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=t.canonical.x-(t.canonical.x>>i<>i<>8<<4|t>>8,r[e+3]=0;const n=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(r.buffer)),i=new B(t,n,t.gl.RGBA,{premultiply:!1});return i.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const r=new Uint8Array(4),n=this.painter.context,i=n.gl,a=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,r),n.bindFramebuffer.set(null);const l=r[0]+(r[2]>>4<<8),c=r[1]+((15&r[2])<<8),u=this.coordsIndex[255-r[3]],h=u&&this.sourceCache.getTileByID(u);if(!h)return null;const f=this._coordsTextureSize,p=(1<t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse))}}const ks={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class As{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Ts(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((r=>!t._layers[r].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const r=t.sourceCaches[e].getVisibleCoordinates();for(const t of r){const r=this.terrain.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(r[t])}}this._coordsDescendingInvStr={};for(const e of t._order){const r=t._layers[e],n=r.source;if(ks[r.type]&&!this._coordsDescendingInvStr[n]){this._coordsDescendingInvStr[n]={};for(const t in this._coordsDescendingInv[n])this._coordsDescendingInvStr[n][t]=this._coordsDescendingInv[n][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[e][t.tileID.key];r&&r!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const r=t.type,n=this.painter,i=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(ks[r]&&(this._prevType&&ks[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!i))return!0;if(ks[this._prevType]||ks[r]&&i){this._prevType=r;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(Ha(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[t]){const e=this.pool.getObjectForId(r.rtt[t].id);if(e.stamp===r.rtt[t].stamp){this.pool.useObject(e);continue}}const a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),r.rtt[t]={id:a.id,stamp:a.stamp},n.context.bindFramebuffer.set(a.fbo.framebuffer),n.context.clear({color:e.aN.transparent,stencil:0}),n.currentStencilSource=void 0;for(let t=0;tr.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitchPs)throw new Error(`maxPitch must be less than or equal to ${Ps}`);if(super(new Ka(r.minZoom,r.maxZoom,r.minPitch,r.maxPitch,r.renderWorldCopies),{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new xs,this._controls=[],this._mapId=e.a4(),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=!0===r.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=!0===r.preserveDrawingBuffer,this._antialias=!0===r.antialias,this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ms),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this.transformCameraUpdate=r.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=d.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))).on("moveend",(()=>this._update(!1))).on("zoom",(()=>this._update(!0))).on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})).once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=Qa((t=>{this._trackResize&&!this._removed&&this.resize(t)._update()}),50);this._resizeObserver=new ResizeObserver((r=>{t?e(r):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new ds(this,r);const n="string"==typeof r.hash&&r.hash||void 0;this._hash=r.hash&&new to(n).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,e.e({},r.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new ys("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new vs,r.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.k(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.k("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,r){if(void 0===r&&(r=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[r];return-1!==r.indexOf("bottom")?i.insertBefore(n,i.firstChild):i.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,r,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(r,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,r,n)}resize(t){var r;const n=this._containerDimensions(),i=n[0],a=n[1],o=this._getClampedPixelRatio(i,a);if(this._resizeCanvas(i,a,o),this.painter.resize(i,a,o),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(i,a);this._resizeCanvas(i,a,e),this.painter.resize(i,a,e)}this.transform.resize(i,a),null===(r=this._requestedCameraState)||void 0===r||r.resize(i,a);const s=!this._moving;return s&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),s&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){const{0:r,1:n}=this._maxCanvasSize,i=this.getPixelRatio(),a=t*i,o=e*i,s=a>r?r/a:1,l=o>n?n/o:1;return Math.min(s,l)*i}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(bt.convert(t)),this._update()}setMinZoom(t){if((t=null==t?Es:t)>=Es&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?Ls:t)=Ls&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()Ps)throw new Error(`maxPitch must be less than or equal to ${Ps}`);if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.N.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,r){if("mouseenter"===t||"mouseover"===t){let n=!1;const i=i=>{const a=this.getLayer(e)?this.queryRenderedFeatures(i.point,{layers:[e]}):[];a.length?n||(n=!0,r.call(this,new co(t,this,i.originalEvent,{features:a}))):n=!1};return{layer:e,listener:r,delegates:{mousemove:i,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1;const i=i=>{(this.getLayer(e)?this.queryRenderedFeatures(i.point,{layers:[e]}):[]).length?n=!0:n&&(n=!1,r.call(this,new co(t,this,i.originalEvent)))},a=e=>{n&&(n=!1,r.call(this,new co(t,this,e.originalEvent)))};return{layer:e,listener:r,delegates:{mousemove:i,mouseout:a}}}{const n=t=>{const n=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,r.call(this,t),delete t.features)};return{layer:e,listener:r,delegates:{[t]:n}}}}on(t,e,r){if(void 0===r)return super.on(t,e);const n=this._createDelegatedListener(t,e,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(n);for(const t in n.delegates)this.on(t,n.delegates[t]);return this}once(t,e,r){if(void 0===r)return super.once(t,e);const n=this._createDelegatedListener(t,e,r);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,r){if(void 0===r)return super.off(t,e);const n=n=>{const i=n[t];for(let t=0;tthis._updateStyle(t,e)));const r=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Je(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,r):this.style.loadJSON(t,e,r),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Je(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,r){if("string"==typeof t){const n=t,i=this._requestManager.transformRequest(n,"Style");e.h(i,new AbortController).then((t=>{this._updateDiff(t.data,r)})).catch((t=>{t&&this.fire(new e.j(t))}))}else"object"==typeof t&&this._updateDiff(t,r)}_updateDiff(t,r){try{this.style.setState(t,r)&&this._update(!0)}catch(n){e.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const r=this.style&&this.style.sourceCaches[t];if(void 0!==r)return r.loaded();this.fire(new e.j(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const r=this.style.sourceCaches[t.source];if(!r)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&r.reload();for(const r in this.style._layers){const n=this.style._layers[r];"hillshade"===n.type&&n.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new ws(this.painter,r,t),this.painter.renderToTexture=new As(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const r=t[e]._tiles;for(const t in r){const e=r[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,r,n={}){const{pixelRatio:i=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;this._lazyInitEmptyStyle();const f=0;if(!(r instanceof HTMLImageElement||e.b(r))){if(void 0===r.width||void 0===r.height)return this.fire(new e.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:n,height:a,data:p}=r,d=r;return this.style.addImage(t,{data:new e.R({width:n,height:a},new Uint8Array(p)),pixelRatio:i,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:f,userImage:d}),d.onAdd&&d.onAdd(this,t),this}}{const{width:n,height:p,data:d}=a.getImageData(r);this.style.addImage(t,{data:new e.R({width:n,height:p},d),pixelRatio:i,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:f})}}updateImage(t,r){const n=this.style.getImage(t);if(!n)return this.fire(new e.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=r instanceof HTMLImageElement||e.b(r)?a.getImageData(r):r,{width:o,height:s,data:l}=i;if(void 0===o||void 0===s)return this.fire(new e.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==n.data.width||s!==n.data.height)return this.fire(new e.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(r instanceof HTMLImageElement||e.b(r));return n.data.replace(l,c),this.style.updateImage(t,n),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return d.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,r){return this.style.setLayerZoomRange(t,e,r),this._update(!0)}setFilter(t,e,r={}){return this.style.setFilter(t,e,r),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,r,n={}){return this.style.setPaintProperty(t,e,r,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,r,n={}){return this.style.setLayoutProperty(t,e,r,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,r,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t){return this._lazyInitEmptyStyle(),this.style.setSky(t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=o.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=o.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const r=this._containerDimensions(),n=this._getClampedPixelRatio(r[0],r[1]);this._resizeCanvas(r[0],r[1],n);const i=this._controlContainer=o.create("div","maplibregl-control-container",t),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{a[t]=o.create("div",`maplibregl-ctrl-${t} `,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,r){this._canvas.width=Math.floor(r*t),this._canvas.height=Math.floor(r*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(r=>{e={requestedAttributes:t},r&&(e.statusMessage=r.statusMessage,e.type=r.type)}),{once:!0});const r=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!r){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Za(r,this.transform),s.testSupport(r)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){const r=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=a.now();this.style.zoomHistory.update(t,i);const o=new e.a9(t,{now:i,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=o.crossFadingFactor();1===s&&s===this._crossFadingFactor||(n=!0,this._crossFadingFactor=s),this.style.update(o)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,r,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding}),this.fire(new e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.be.mark(e.bf.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const i=this._sourcesDirty||this._styleDirty||this._placementDirty;return i||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||i||(this._fullyLoaded=!0,e.be.mark(e.bf.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),d.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const r=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==r?void 0:r.loseContext)&&r.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),o.remove(this._canvasContainer),o.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.be.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((t=>{e.be.frame(t),this._frameRequest=null,this._render(t)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return Ss}getCameraTargetElevation(){return this.transform.elevation}};const Os=t=>{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},Rs=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:r=.8})=>{const n=new Io;return new Ao({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*r}),moveStateManager:n,enable:t,assignEvents:Os})},Fs=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:r=-.5})=>{const n=new Io;return new Ao({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*r}),moveStateManager:n,enable:t,assignEvents:Os})},Bs={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ns{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,e)=>{const r=this._map._getUIString(`NavigationControl.${e}`);t.title=r,t.setAttribute("aria-label",r)},this.options=e.e({},Bs,t),this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=o.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new js(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){o.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const r=o.create("button",t,this._container);return r.type="button",r.addEventListener("click",e),r}}class js{constructor(t,r,n=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),o.mousePos(this.element,t)),o.addEventListener(window,"mousemove",this.mousemove),o.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,o.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),o.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const i=t.dragRotate._mouseRotate.getClickTolerance(),a=t.dragRotate._mousePitch.getClickTolerance();this.element=r,this.mouseRotate=Ro({clickTolerance:i,enable:!0}),this.touchRotate=Rs({clickTolerance:i,enable:!0}),this.map=t,n&&(this.mousePitch=Fo({clickTolerance:a,enable:!0}),this.touchPitch=Fs({clickTolerance:a,enable:!0})),o.addEventListener(r,"mousedown",this.mousedown),o.addEventListener(r,"touchstart",this.touchstart,{passive:!1}),o.addEventListener(r,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),o.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),o.disableDrag()}moveMouse(t,e){const r=this.map,{bearingDelta:n}=this.mouseRotate.dragMove(t,e)||{};if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){const{pitchDelta:n}=this.mousePitch.dragMove(t,e)||{};n&&r.setPitch(r.getPitch()+n)}}moveTouch(t,e){const r=this.map,{bearingDelta:n}=this.touchRotate.dragMove(t,e)||{};if(n&&r.setBearing(r.getBearing()+n),this.touchPitch){const{pitchDelta:n}=this.touchPitch.dragMove(t,e)||{};n&&r.setPitch(r.getPitch()+n)}}off(){const t=this.element;o.removeEventListener(t,"mousedown",this.mousedown),o.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),o.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.removeEventListener(window,"touchend",this.touchend),o.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){o.enableDrag(),o.removeEventListener(window,"mousemove",this.mousemove),o.removeEventListener(window,"mouseup",this.mouseup),o.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.removeEventListener(window,"touchend",this.touchend)}}let Us;function Vs(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==Us&&!t)return Us;if(void 0===window.navigator.permissions)return Us=!!window.navigator.geolocation,Us;try{const t=yield window.navigator.permissions.query({name:"geolocation"});Us="denied"!==t.state}catch(t){Us=!!window.navigator.geolocation}return Us}))}function qs(t,r,n){const i=new e.N(t.lng,t.lat);if(t=new e.N(t.lng,t.lat),r){const i=new e.N(t.lng-360,t.lat),a=new e.N(t.lng+360,t.lat),o=n.locationPoint(t).distSqr(r);n.locationPoint(i).distSqr(r)180;){const e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t.lng!==i.lng&&n.locationPoint(t).y>n.height/2-n.getHorizon()?t:i}const Hs={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Gs(t,e,r){const n=t.classList;for(const t in Hs)n.remove(`maplibregl-${r}-anchor-${t}`);n.add(`maplibregl-${r}-anchor-${e}`)}class Ws extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,r=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==r&&13!==r||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,r=this._element;this._popup&&(e===r||r.contains(e))&&this.togglePopup()},this._update=t=>{var e;if(!this._map)return;const r=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!r)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies?this._lngLat=qs(this._lngLat,this._flatPos,this._map.transform):this._lngLat=null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let n="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?n=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),o.setTransform(this._element,`${Hs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${n}`),a.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o.create("div");const r=o.createNS("http://www.w3.org/2000/svg","svg"),n=41,i=27;r.setAttributeNS(null,"display","block"),r.setAttributeNS(null,"height",`${n}px`),r.setAttributeNS(null,"width",`${i}px`),r.setAttributeNS(null,"viewBox",`0 0 ${i} ${n}`);const a=o.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=o.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=o.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of c){const e=o.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const u=o.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"fill",this._color);const h=o.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),u.appendChild(h);const f=o.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"fill","#000000");const p=o.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),f.appendChild(p);const d=o.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(6.0, 7.0)"),d.setAttributeNS(null,"fill","#FFFFFF");const m=o.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=o.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const y=o.createNS("http://www.w3.org/2000/svg","circle");y.setAttributeNS(null,"fill","#FFFFFF"),y.setAttributeNS(null,"cx","5.5"),y.setAttributeNS(null,"cy","5.5"),y.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(y),s.appendChild(l),s.appendChild(u),s.appendChild(f),s.appendChild(d),s.appendChild(m),r.appendChild(s),r.setAttributeNS(null,"height",n*this._scale+"px"),r.setAttributeNS(null,"width",i*this._scale+"px"),this._element.appendChild(r),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),Gs(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),o.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,r=13.5,n=Math.abs(r)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[n,-1*(e-r+n)],"bottom-right":[-n,-1*(e-r+n)],left:[r,-1*(e-r)],right:[-r,-1*(e-r)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var r,n;if(!(null===(r=this._map)||void 0===r?void 0:r.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const i=this._map,a=i.terrain.depthAtPoint(this._pos),o=i.terrain.getElevationForLngLatZoom(this._lngLat,i.transform.tileZoom),s=.006;if(i.transform.lngLatToCameraDepth(this._lngLat,o)-as;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Zs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ys=0,Xs=!1;class $s extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const r=new e.N(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,i=this._map.getBearing(),a=e.e({bearing:i},this.options.fitBoundsOptions),o=bt.fromLngLat(r,n);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const r=new e.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Xs)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o.create("button","maplibregl-ctrl-geolocate",this._container),o.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ws({element:this._dotElement}),this._circleElement=o.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ws({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{const r=t.originalEvent&&"resize"===t.originalEvent.type;t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||r||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")),this.fire(new e.k("userlocationlostfocus")))}))}},this.options=e.e({},Zs,t)}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),Vs().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),o.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ys=0,Xs=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),r=t.coords;return e&&(r.longitudee.getEast()||r.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),r=t.getNorthEast(),n=e.distanceTo(r),i=this._map._container.clientHeight,a=Math.ceil(this._accuracy/(n/i)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ys--,Xs=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.k("trackuserlocationstart")),this.fire(new e.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ys++,Ys>1?(t={maximumAge:6e5,timeout:0},Xs=!0):(t=this.options.positionOptions,Xs=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}}const Js={maxWidth:100,unit:"metric"};class Ks{constructor(t){this._onMove=()=>{Qs(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Qs(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Js),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){o.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}}function Qs(t,e,r){const n=r&&r.maxWidth||100,i=t._container.clientHeight/2,a=t.unproject([0,i]),o=t.unproject([n,i]),s=a.distanceTo(o);if(r&&"imperial"===r.unit){const r=3.2808*s;r>5280?tl(e,n,r/5280,t._getUIString("ScaleControl.Miles")):tl(e,n,r,t._getUIString("ScaleControl.Feet"))}else r&&"nautical"===r.unit?tl(e,n,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?tl(e,n,s/1e3,t._getUIString("ScaleControl.Kilometers")):tl(e,n,s,t._getUIString("ScaleControl.Meters"))}function tl(t,e,r,n){const i=rl(r),a=i/r;t.style.width=e*a+"px",t.innerHTML=`${i} ${n}`}function el(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}function rl(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let r=t/e;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:el(r),e*r}class nl extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){o.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=o.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);o.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}}class il{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=o.create("button","maplibregl-ctrl-terrain",this._container),o.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){o.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}}const al={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ol=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");class sl extends e.E{constructor(t){super(),this.remove=()=>(this._content&&o.remove(this._content),this._container&&(o.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var e;const r=this._lngLat||this._trackPointer;if(!this._map||!r||!this._content)return;if(!this._container){if(this._container=o.create("div","maplibregl-popup",this._map.getContainer()),this._tip=o.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer?this._lngLat=qs(this._lngLat,this._flatPos,this._map.transform):this._lngLat=null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let i=this.options.anchor;const a=ll(this.options.offset);if(!i){const t=this._container.offsetWidth,e=this._container.offsetHeight;let r;r=n.y+a.bottom.ythis._map.transform.height-e?["bottom"]:[],n.xthis._map.transform.width-t/2&&r.push("right"),i=0===r.length?"bottom":r.join("-")}let s=n.add(a[i]);this.options.subpixelPositioning||(s=s.round()),o.setTransform(this._container,`${Hs[i]} translate(${s.x}px,${s.y}px)`),Gs(this._container,i,"popup")},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(al),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),r=document.createElement("body");let n;for(r.innerHTML=t;n=r.firstChild,n;)e.appendChild(n);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=o.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=o.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(ol);t&&t.focus()}}function ll(t){if(t){if("number"==typeof t){const r=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(r,r),"top-right":new e.P(-r,r),bottom:new e.P(0,-t),"bottom-left":new e.P(r,-r),"bottom-right":new e.P(-r,-r),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const r=e.P.convert(t);return{center:r,top:r,"top-left":r,"top-right":r,bottom:r,"bottom-left":r,"bottom-right":r,left:r,right:r}}return{center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return ll(new e.P(0,0))}const cl=r.version;function ul(t,e){return Ut().setRTLTextPlugin(t,e)}function hl(){return Ut().getRTLTextPluginStatus()}function fl(){return cl}function pl(){return it.workerCount}function dl(t){it.workerCount=t}function ml(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS}function gl(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t}function yl(){return e.a.WORKER_URL}function vl(t){e.a.WORKER_URL=t}function xl(t){return ft().broadcast("IS",t)}t.AJAXError=e.bg,t.Evented=e.E,t.LngLat=e.N,t.MercatorCoordinate=e.Z,t.Point=e.P,t.addProtocol=e.bh,t.config=e.a,t.removeProtocol=e.bi,t.AttributionControl=ys,t.BoxZoomHandler=go,t.CanvasSource=It,t.CooperativeGesturesHandler=us,t.DoubleClickZoomHandler=is,t.DragPanHandler=ss,t.DragRotateHandler=ls,t.EdgeInsets=$a,t.FullscreenControl=nl,t.GeoJSONSource=Mt,t.GeolocateControl=$s,t.Hash=to,t.ImageSource=Et,t.KeyboardHandler=Jo,t.LngLatBounds=bt,t.LogoControl=vs,t.Map=Ds,t.MapMouseEvent=co,t.MapTouchEvent=uo,t.MapWheelEvent=ho,t.Marker=Ws,t.NavigationControl=Ns,t.Popup=sl,t.RasterDEMTileSource=At,t.RasterTileSource=kt,t.ScaleControl=Ks,t.ScrollZoomHandler=ns,t.Style=Je,t.TerrainControl=il,t.TwoFingersTouchPitchHandler=Xo,t.TwoFingersTouchRotateHandler=Wo,t.TwoFingersTouchZoomHandler=qo,t.TwoFingersTouchZoomRotateHandler=cs,t.VectorTileSource=Tt,t.VideoSource=Lt,t.addSourceType=Rt,t.clearPrewarmedResources=ut,t.getMaxParallelImageRequests=ml,t.getRTLTextPluginStatus=hl,t.getVersion=fl,t.getWorkerCount=pl,t.getWorkerUrl=yl,t.importScriptInWorkers=xl,t.prewarm=ct,t.setMaxParallelImageRequests=gl,t.setRTLTextPlugin=ul,t.setWorkerCount=dl,t.setWorkerUrl=vl})),t}()},88640:function(t,e,r){"use strict";function n(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function i(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function a(){}r.d(e,{GW:function(){return tt},Dj:function(){return W}});var o=.7,s=1/o,l="\\s*([+-]?\\d+)\\s*",c="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",u="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",h=/^#([0-9a-f]{3,8})$/,f=new RegExp("^rgb\\(".concat(l,",").concat(l,",").concat(l,"\\)$")),p=new RegExp("^rgb\\(".concat(u,",").concat(u,",").concat(u,"\\)$")),d=new RegExp("^rgba\\(".concat(l,",").concat(l,",").concat(l,",").concat(c,"\\)$")),m=new RegExp("^rgba\\(".concat(u,",").concat(u,",").concat(u,",").concat(c,"\\)$")),g=new RegExp("^hsl\\(".concat(c,",").concat(u,",").concat(u,"\\)$")),y=new RegExp("^hsla\\(".concat(c,",").concat(u,",").concat(u,",").concat(c,"\\)$")),v={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function x(){return this.rgb().formatHex()}function _(){return this.rgb().formatRgb()}function b(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=h.exec(t))?(r=e[1].length,e=parseInt(e[1],16),6===r?w(e):3===r?new A(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===r?T(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===r?T(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=f.exec(t))?new A(e[1],e[2],e[3],1):(e=p.exec(t))?new A(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=d.exec(t))?T(e[1],e[2],e[3],e[4]):(e=m.exec(t))?T(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=g.exec(t))?I(e[1],e[2]/100,e[3]/100,1):(e=y.exec(t))?I(e[1],e[2]/100,e[3]/100,e[4]):v.hasOwnProperty(t)?w(v[t]):"transparent"===t?new A(NaN,NaN,NaN,0):null}function w(t){return new A(t>>16&255,t>>8&255,255&t,1)}function T(t,e,r,n){return n<=0&&(t=e=r=NaN),new A(t,e,r,n)}function k(t,e,r,n){return 1===arguments.length?((i=t)instanceof a||(i=b(i)),i?new A((i=i.rgb()).r,i.g,i.b,i.opacity):new A):new A(t,e,r,null==n?1:n);var i}function A(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function M(){return"#".concat(L(this.r)).concat(L(this.g)).concat(L(this.b))}function S(){var t=E(this.opacity);return"".concat(1===t?"rgb(":"rgba(").concat(C(this.r),", ").concat(C(this.g),", ").concat(C(this.b)).concat(1===t?")":", ".concat(t,")"))}function E(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function C(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function L(t){return((t=C(t))<16?"0":"")+t.toString(16)}function I(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new z(t,e,r,n)}function P(t){if(t instanceof z)return new z(t.h,t.s,t.l,t.opacity);if(t instanceof a||(t=b(t)),!t)return new z;if(t instanceof z)return t;var e=(t=t.rgb()).r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),o=Math.max(e,r,n),s=NaN,l=o-i,c=(o+i)/2;return l?(s=e===o?(r-n)/l+6*(r0&&c<1?0:s,new z(s,l,c,t.opacity)}function z(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function D(t){return(t=(t||0)%360)<0?t+360:t}function O(t){return Math.max(0,Math.min(1,t||0))}function R(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}function F(t,e,r,n,i){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*r+(1+3*t+3*a-3*o)*n+o*i)/6}n(a,b,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:x,formatHex:x,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return P(this).formatHsl()},formatRgb:_,toString:_}),n(A,k,i(a,{brighter:function(t){return t=null==t?s:Math.pow(s,t),new A(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?o:Math.pow(o,t),new A(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},clamp:function(){return new A(C(this.r),C(this.g),C(this.b),E(this.opacity))},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:M,formatHex:M,formatHex8:function(){return"#".concat(L(this.r)).concat(L(this.g)).concat(L(this.b)).concat(L(255*(isNaN(this.opacity)?1:this.opacity)))},formatRgb:S,toString:S})),n(z,(function(t,e,r,n){return 1===arguments.length?P(t):new z(t,e,r,null==n?1:n)}),i(a,{brighter:function(t){return t=null==t?s:Math.pow(s,t),new z(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?o:Math.pow(o,t),new z(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new A(R(t>=240?t-240:t+120,i,n),R(t,i,n),R(t<120?t+240:t-120,i,n),this.opacity)},clamp:function(){return new z(D(this.h),O(this.s),O(this.l),E(this.opacity))},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=E(this.opacity);return"".concat(1===t?"hsl(":"hsla(").concat(D(this.h),", ").concat(100*O(this.s),"%, ").concat(100*O(this.l),"%").concat(1===t?")":", ".concat(t,")"))}}));var B=function(t){return function(){return t}};function N(t,e){return function(r){return t+r*e}}function j(t){return 1==(t=+t)?U:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):B(isNaN(e)?r:e)}}function U(t,e){var r=e-t;return r?N(t,r):B(isNaN(t)?e:t)}var V=function t(e){var r=j(e);function n(t,e){var n=r((t=k(t)).r,(e=k(e)).r),i=r(t.g,e.g),a=r(t.b,e.b),o=U(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return n.gamma=t,n}(1);function q(t){return function(e){var r,n,i=e.length,a=new Array(i),o=new Array(i),s=new Array(i);for(r=0;r=1?(r=1,e-1):Math.floor(r*e),i=t[n],a=t[n+1],o=n>0?t[n-1]:2*i-a,s=na&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:W(r,n)})),a=$.lastIndex;return aESRI"},"ortoInstaMaps":{"type":"raster","tiles":["https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"],"tileSize":256,"maxzoom":13},"ortoICGC":{"type":"raster","tiles":["https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"],"tileSize":256,"minzoom":13.1,"maxzoom":20},"openmaptiles":{"type":"vector","url":"https://geoserveis.icgc.cat/contextmaps/basemap.json"}},"sprite":"https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1","glyphs":"https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#F4F9F4"}},{"id":"ortoEsri","type":"raster","source":"ortoEsri","maxzoom":16,"layout":{"visibility":"visible"}},{"id":"ortoICGC","type":"raster","source":"ortoICGC","minzoom":13.1,"maxzoom":19,"layout":{"visibility":"visible"}},{"id":"ortoInstaMaps","type":"raster","source":"ortoInstaMaps","maxzoom":13,"layout":{"visibility":"visible"}},{"id":"waterway_tunnel","type":"line","source":"openmaptiles","source-layer":"waterway","minzoom":14,"filter":["all",["in","class","river","stream","canal"],["==","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,6]]},"line-dasharray":[2,4]}},{"id":"waterway-other","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["!in","class","canal","river","stream"],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,2]]}}},{"id":"waterway-stream-canal","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["all",["in","class","canal","stream"],["!=","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,6]]}}},{"id":"waterway-river","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["all",["==","class","river"],["!=","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.2,"stops":[[10,0.8],[20,4]]},"line-opacity":0.5}},{"id":"water-offset","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","maxzoom":8,"filter":["==","$type","Polygon"],"layout":{"visibility":"visible"},"paint":{"fill-opacity":0,"fill-color":"#a0c8f0","fill-translate":{"base":1,"stops":[[6,[2,0]],[8,[0,0]]]}}},{"id":"water","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","layout":{"visibility":"visible"},"paint":{"fill-color":"hsl(210, 67%, 85%)","fill-opacity":0}},{"id":"water-pattern","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","layout":{"visibility":"visible"},"paint":{"fill-translate":[0,2.5],"fill-pattern":"wave","fill-opacity":1}},{"id":"landcover-ice-shelf","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"landcover","filter":["==","subclass","ice_shelf"],"layout":{"visibility":"visible"},"paint":{"fill-color":"#fff","fill-opacity":{"base":1,"stops":[[0,0.9],[10,0.3]]}}},{"id":"tunnel-service-track-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","service","track"]],"layout":{"line-join":"round"},"paint":{"line-color":"#cfcdca","line-dasharray":[0.5,0.25],"line-width":{"base":1.2,"stops":[[15,1],[16,4],[20,11]]}}},{"id":"tunnel-minor-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","minor"]],"layout":{"line-join":"round"},"paint":{"line-color":"#cfcdca","line-opacity":{"stops":[[12,0],[12.5,1]]},"line-width":{"base":1.2,"stops":[[12,0.5],[13,1],[14,4],[20,15]]}}},{"id":"tunnel-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[8,1.5],[20,17]]}}},{"id":"tunnel-trunk-primary-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.7}},{"id":"tunnel-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","motorway"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-dasharray":[0.5,0.25],"line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.5}},{"id":"tunnel-path","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","tunnel"],["==","class","path"]]],"paint":{"line-color":"#cba","line-dasharray":[1.5,0.75],"line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]}}},{"id":"tunnel-service-track","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","service","track"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff","line-width":{"base":1.2,"stops":[[15.5,0],[16,2],[20,7.5]]}}},{"id":"tunnel-minor","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","minor_road"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff","line-opacity":1,"line-width":{"base":1.2,"stops":[[13.5,0],[14,2.5],[20,11.5]]}}},{"id":"tunnel-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff4c6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,10]]}}},{"id":"tunnel-trunk-primary","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff4c6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"tunnel-motorway","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","motorway"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"#ffdaa6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"tunnel-railway","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]},"line-dasharray":[2,2]}},{"id":"ferry","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["in","class","ferry"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(108, 159, 182, 1)","line-width":1.1,"line-dasharray":[2,2]}},{"id":"aeroway-taxiway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":12,"filter":["all",["in","class","taxiway"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(153, 153, 153, 1)","line-width":{"base":1.5,"stops":[[11,2],[17,12]]},"line-opacity":1}},{"id":"aeroway-runway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":12,"filter":["all",["in","class","runway"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(153, 153, 153, 1)","line-width":{"base":1.5,"stops":[[11,5],[17,55]]},"line-opacity":1}},{"id":"aeroway-taxiway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":4,"filter":["all",["in","class","taxiway"],["==","$type","LineString"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(255, 255, 255, 1)","line-width":{"base":1.5,"stops":[[11,1],[17,10]]},"line-opacity":{"base":1,"stops":[[11,0],[12,1]]}}},{"id":"aeroway-runway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":4,"filter":["all",["in","class","runway"],["==","$type","LineString"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(255, 255, 255, 1)","line-width":{"base":1.5,"stops":[[11,4],[17,50]]},"line-opacity":{"base":1,"stops":[[11,0],[12,1]]}}},{"id":"highway-motorway-link-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":12,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway_link"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"highway-link-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"highway-minor-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!=","brunnel","tunnel"],["in","class","minor","service","track"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#cfcdca","line-opacity":{"stops":[[12,0],[12.5,0]]},"line-width":{"base":1.2,"stops":[[12,0.5],[13,1],[14,4],[20,15]]}}},{"id":"highway-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":0.5,"line-width":{"base":1.2,"stops":[[8,1.5],[20,17]]}}},{"id":"highway-primary-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":{"stops":[[7,0],[8,0.6]]},"line-width":{"base":1.2,"stops":[[7,0],[8,0.6],[9,1.5],[20,22]]}}},{"id":"highway-trunk-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","trunk"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":{"stops":[[5,0],[6,0.5]]},"line-width":{"base":1.2,"stops":[[5,0],[6,0.6],[7,1.5],[20,22]]}}},{"id":"highway-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":4,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[4,0],[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":{"stops":[[4,0],[5,0.5]]}}},{"id":"highway-path","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["==","class","path"]]],"paint":{"line-color":"#cba","line-dasharray":[1.5,0.75],"line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]}}},{"id":"highway-motorway-link","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":12,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway_link"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"highway-link","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"highway-minor","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!=","brunnel","tunnel"],["in","class","minor","service","track"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#fff","line-opacity":0.5,"line-width":{"base":1.2,"stops":[[13.5,0],[14,2.5],[20,11.5]]}}},{"id":"highway-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[8,0.5],[20,13]]},"line-opacity":0.5}},{"id":"highway-primary","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["in","class","primary"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[8.5,0],[9,0.5],[20,18]]},"line-opacity":0}},{"id":"highway-trunk","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["in","class","trunk"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"highway-motorway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"railway-transit","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","transit"],["!in","brunnel","tunnel"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.77)","line-width":{"base":1.4,"stops":[[14,0.4],[20,1]]}}},{"id":"railway-transit-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","transit"],["!in","brunnel","tunnel"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.68)","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,2],[20,6]]}}},{"id":"railway-service","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","rail"],["has","service"]]],"paint":{"line-color":"hsla(0, 0%, 73%, 0.77)","line-width":{"base":1.4,"stops":[[14,0.4],[20,1]]}}},{"id":"railway-service-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","rail"],["has","service"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.68)","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,2],[20,6]]}}},{"id":"railway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!has","service"],["!in","brunnel","bridge","tunnel"],["==","class","rail"]]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]}}},{"id":"railway-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!has","service"],["!in","brunnel","bridge","tunnel"],["==","class","rail"]]],"paint":{"line-color":"#bbb","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,3],[20,8]]}}},{"id":"bridge-motorway-link-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"bridge-link-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"bridge-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[8,1.5],[20,28]]}}},{"id":"bridge-trunk-primary-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"hsl(28, 76%, 67%)","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,26]]}}},{"id":"bridge-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.5}},{"id":"bridge-path-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","bridge"],["==","class","path"]]],"paint":{"line-color":"#f8f4f0","line-width":{"base":1.2,"stops":[[15,1.2],[20,18]]}}},{"id":"bridge-path","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","bridge"],["==","class","path"]]],"paint":{"line-color":"#cba","line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]},"line-dasharray":[1.5,0.75]}},{"id":"bridge-motorway-link","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"bridge-link","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"bridge-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,20]]}}},{"id":"bridge-trunk-primary","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]}}},{"id":"bridge-motorway","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"bridge-railway","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]}}},{"id":"bridge-railway-hatching","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,3],[20,8]]}}},{"id":"cablecar","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["==","class","cable_car"],"layout":{"visibility":"visible","line-cap":"round"},"paint":{"line-color":"hsl(0, 0%, 70%)","line-width":{"base":1,"stops":[[11,1],[19,2.5]]}}},{"id":"cablecar-dash","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["==","class","cable_car"],"layout":{"visibility":"visible","line-cap":"round"},"paint":{"line-color":"hsl(0, 0%, 70%)","line-width":{"base":1,"stops":[[11,3],[19,5.5]]},"line-dasharray":[2,3]}},{"id":"boundary-land-level-4","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",[">=","admin_level",4],["<=","admin_level",8],["!=","maritime",1]],"layout":{"line-join":"round"},"paint":{"line-color":"#9e9cab","line-dasharray":[3,1,1,1],"line-width":{"base":1.4,"stops":[[4,0.4],[5,1],[12,3]]},"line-opacity":0.6}},{"id":"boundary-land-level-2","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["==","admin_level",2],["!=","maritime",1],["!=","disputed",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"hsl(248, 7%, 66%)","line-width":{"base":1,"stops":[[0,0.6],[4,1.4],[5,2],[12,2]]}}},{"id":"boundary-land-disputed","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["!=","maritime",1],["==","disputed",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"hsl(248, 7%, 70%)","line-dasharray":[1,3],"line-width":{"base":1,"stops":[[0,0.6],[4,1.4],[5,2],[12,8]]}}},{"id":"boundary-water","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["in","admin_level",2,4],["==","maritime",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"rgba(154, 189, 214, 1)","line-width":{"base":1,"stops":[[0,0.6],[4,1],[5,1],[12,1]]},"line-opacity":{"stops":[[6,0],[10,0]]}}},{"id":"waterway-name","type":"symbol","source":"openmaptiles","source-layer":"waterway","minzoom":13,"filter":["all",["==","$type","LineString"],["has","name"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin} {name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"line","text-letter-spacing":0.2,"symbol-spacing":350},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-lakeline","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["==","$type","LineString"],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"line","symbol-spacing":350,"text-letter-spacing":0.2},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-ocean","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["all",["==","$type","Point"],["==","class","ocean"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"point","symbol-spacing":350,"text-letter-spacing":0.2},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-other","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["all",["==","$type","Point"],["!in","class","ocean"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":{"stops":[[0,10],[6,14]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"point","symbol-spacing":350,"text-letter-spacing":0.2,"visibility":"visible"},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"poi-level-3","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":16,"filter":["all",["==","$type","Point"],[">=","rank",25]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"poi-level-2","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":15,"filter":["all",["==","$type","Point"],["<=","rank",24],[">=","rank",15]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"poi-level-1","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":14,"filter":["all",["==","$type","Point"],["<=","rank",14],["has","name"]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":11,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"rgba(191, 228, 172, 1)","text-halo-width":1,"text-halo-color":"rgba(30, 29, 29, 1)"}},{"id":"poi-railway","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":13,"filter":["all",["==","$type","Point"],["has","name"],["==","class","railway"],["==","subclass","station"]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9,"icon-optional":false,"icon-ignore-placement":false,"icon-allow-overlap":false,"text-ignore-placement":false,"text-allow-overlap":false,"text-optional":true},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"road_oneway","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["all",["==","oneway",1],["in","class","motorway","trunk","primary","secondary","tertiary","minor","service"]],"layout":{"symbol-placement":"line","icon-image":"oneway","symbol-spacing":75,"icon-padding":2,"icon-rotation-alignment":"map","icon-rotate":90,"icon-size":{"stops":[[15,0.5],[19,1]]}},"paint":{"icon-opacity":0.5}},{"id":"road_oneway_opposite","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["all",["==","oneway",-1],["in","class","motorway","trunk","primary","secondary","tertiary","minor","service"]],"layout":{"symbol-placement":"line","icon-image":"oneway","symbol-spacing":75,"icon-padding":2,"icon-rotation-alignment":"map","icon-rotate":-90,"icon-size":{"stops":[[15,0.5],[19,1]]}},"paint":{"icon-opacity":0.5}},{"id":"highway-name-path","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":15.5,"filter":["==","class","path"],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-color":"#f8f4f0","text-color":"hsl(30, 23%, 62%)","text-halo-width":0.5}},{"id":"highway-name-minor","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":15,"filter":["all",["==","$type","LineString"],["in","class","minor","service","track"]],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-blur":0.5,"text-color":"#765","text-halo-width":1}},{"id":"highway-name-major","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":12.2,"filter":["in","class","primary","secondary","tertiary","trunk"],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-blur":0.5,"text-color":"#765","text-halo-width":1}},{"id":"highway-shield","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":8,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["!in","network","us-interstate","us-highway","us-state"]],"layout":{"text-size":10,"icon-image":"road_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[10,"point"],[11,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-opacity":1,"text-color":"rgba(20, 19, 19, 1)","text-halo-color":"rgba(230, 221, 221, 0)","text-halo-width":2,"icon-color":"rgba(183, 18, 18, 1)","icon-opacity":0.3,"icon-halo-color":"rgba(183, 55, 55, 0)"}},{"id":"highway-shield-us-interstate","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":7,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["in","network","us-interstate"]],"layout":{"text-size":10,"icon-image":"{network}_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[7,"point"],[7,"line"],[8,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-color":"rgba(0, 0, 0, 1)"}},{"id":"highway-shield-us-other","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":9,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["in","network","us-highway","us-state"]],"layout":{"text-size":10,"icon-image":"{network}_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[10,"point"],[11,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-color":"rgba(0, 0, 0, 1)"}},{"id":"place-other","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","minzoom":12,"filter":["!in","class","city","town","village","country","continent"],"layout":{"text-letter-spacing":0.1,"text-size":{"base":1.2,"stops":[[12,10],[15,14]]},"text-font":["Noto Sans Bold"],"text-field":"{name:latin}\\n{name:nonlatin}","text-transform":"uppercase","text-max-width":9,"visibility":"visible"},"paint":{"text-color":"rgba(255,255,255,1)","text-halo-width":1.2,"text-halo-color":"rgba(57, 28, 28, 1)"}},{"id":"place-village","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","minzoom":10,"filter":["==","class","village"],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[10,12],[15,16]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(255, 255, 255, 1)","text-halo-width":1.2,"text-halo-color":"rgba(10, 9, 9, 0.8)"}},{"id":"place-town","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["==","class","town"],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[10,14],[15,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(255, 255, 255, 1)","text-halo-width":1.2,"text-halo-color":"rgba(22, 22, 22, 0.8)"}},{"id":"place-city","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["!=","capital",2],["==","class","city"]],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[7,14],[11,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(0, 0, 0, 1)","text-halo-width":1.2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-city-capital","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","capital",2],["==","class","city"]],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[7,14],[11,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"icon-image":"star_11","text-offset":[0.4,0],"icon-size":0.8,"text-anchor":"left","visibility":"visible"},"paint":{"text-color":"#333","text-halo-width":1.2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-other","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],[">=","rank",3],["!has","iso_a2"]],"layout":{"text-font":["Noto Sans Italic"],"text-field":"{name:latin}","text-size":{"stops":[[3,11],[7,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-3","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],[">=","rank",3],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[3,11],[7,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-2","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],["==","rank",2],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[2,11],[5,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-1","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],["==","rank",1],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[1,11],[4,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-continent","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","maxzoom":1,"filter":["==","class","continent"],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":14,"text-max-width":6.25,"text-transform":"uppercase","visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}}],"id":"qebnlkra6"}')},51962:function(t){"use strict";t.exports=JSON.parse('{"version":8,"name":"orto","metadata":{},"center":[1.537786,41.837539],"zoom":12,"bearing":0,"pitch":0,"light":{"anchor":"viewport","color":"white","intensity":0.4,"position":[1.15,45,30]},"sources":{"ortoEsri":{"type":"raster","tiles":["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],"tileSize":256,"maxzoom":18,"attribution":"ESRI © ESRI"},"ortoInstaMaps":{"type":"raster","tiles":["https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"],"tileSize":256,"maxzoom":13},"ortoICGC":{"type":"raster","tiles":["https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"],"tileSize":256,"minzoom":13.1,"maxzoom":20},"openmaptiles":{"type":"vector","url":"https://geoserveis.icgc.cat/contextmaps/basemap.json"}},"sprite":"https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1","glyphs":"https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#F4F9F4"}},{"id":"ortoEsri","type":"raster","source":"ortoEsri","maxzoom":16,"layout":{"visibility":"visible"}},{"id":"ortoICGC","type":"raster","source":"ortoICGC","minzoom":13.1,"maxzoom":19,"layout":{"visibility":"visible"}},{"id":"ortoInstaMaps","type":"raster","source":"ortoInstaMaps","maxzoom":13,"layout":{"visibility":"visible"}}]}')}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={id:n,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}return r.m=t,r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.b=document.baseURI||self.location.href,r.nc=void 0,r(20260)}()},t.exports=e()}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t=r(647),e=r.n(t),n=r(453),i=r.n(n),a=r(653),o=r.n(a);function s(t,e){let r;return function(...n){const i=this;clearTimeout(r),r=setTimeout((()=>t.apply(i,n)),e)}}function l(t){return Math.round(t.getTime()/1e3)}function c(t){return new Date(1e3*t)}function u(t,e){const r=document.getElementById("notifications"),n=document.getElementById("notification-template").content.cloneNode(!0).firstElementChild,i=n.querySelector(".btn-close");let a="";"info"===t?(n.classList.add("bg-primary","text-white"),i.classList.add("btn-close-white"),a="fa-circle-info"):"success"===t?(n.classList.add("bg-success","text-white"),i.classList.add("btn-close-white"),a="fa-circle-check"):"warning"===t?(n.classList.add("bg-warning","text-body"),a="fa-circle-exclamation"):"error"===t?(n.classList.add("bg-danger","text-white"),i.classList.add("btn-close-white"),a="fa-circle-exclamation"):(n.classList.add("bg-secondary","text-white"),i.classList.add("btn-close-white"),a="fa-comment"),n.querySelector(".toast-body").innerHTML=` `+e,r.appendChild(n);new(o())(n,{autohide:!0,delay:1e4}).show(),n.addEventListener("hidden.bs.toast",(()=>{n.remove()}))}const h="varnishmon.",f=`${h}time-range-from`,p=`${h}time-range-to`,d=["now-1h","now"];function m(t=!1){if(!t){const t=g(f),e=g(p);if(null!=t&&null!=e)return[t,e]}return varnishmon.config.scraper.enabled?d:[c(varnishmon.storage.earliest),c(varnishmon.storage.latest)]}function g(t){try{let e=localStorage.getItem(t);if(null!=e)return e}catch(e){console.error(`Failed to read '${t}' from local storage!`,e)}return null}function y(t,e){e instanceof Date&&(e=e.toISOString());try{localStorage.setItem(t,e)}catch(e){console.error(`Failed to write '${t}' to local storage!`,e)}}const v=`${h}refresh-interval`,x=[[-1,"auto"],[0,"disabled"],[1,"1s"],[2,"2s"],[3,"3s"],[4,"4s"],[5,"5s"],[10,"10s"],[15,"15s"],[30,"30s"],[60,"1m"]];function _(t){return Number.isInteger(t)&&x.map((t=>t[0])).includes(t)}const b=`${h}filter`,w=`${h}filter-history`;function T(){try{let t=localStorage.getItem(w);if(null!=t)return JSON.parse(t)}catch(t){console.error(`Failed to read '${w}' from local storage!`,t)}return[]}const k=`${h}verbosity`,A=["normal","debug"];function M(t){return A.includes(t)}const S=`${h}columns`,E=[1,2,3,4,6,12];function C(t){return Number.isInteger(t)&&E.includes(t)}const L=`${h}aggregator`,I=["avg","min","max","first","last","count"];function P(t){return I.includes(t)}const z=`${h}step`;function D(t){return Number.isInteger(t)&&t>=varnishmon.config.scraper.period}const O=[/^MGT[.](?!(?:uptime)$)/,new RegExp("MAIN[.](?!(?:"+["backend_busy","backend_conn","backend_fail","backend_recycle","backend_req","backend_retry","backend_reuse","backend_unhealthy","backend_wait_fail","backend_wait","bans_lurker_obj_killed_cutoff","bans_lurker_obj_killed","bans_obj_killed","bans","bgfetch_no_thread","busy_killed","busy_sleep","busy_wakeup","c_ykey_purges","cache_hit_grace","cache_hit","cache_hitmiss","cache_hitpass","cache_miss","client_req_400","client_req_417","client_req","client_resp_500","esi_errors","esi_maxdepth","esi_req","esi_warnings","fetch_1xx","fetch_204","fetch_304","fetch_bad","fetch_chunked","fetch_eof","fetch_failed","fetch_fast304","fetch_head","fetch_length","fetch_none","fetch_stale_deliver","fetch_stale_rearm","g_mem_file","g_mem_private","g_mem_rss","g_mem_swap","goto_dns_cache_hits","goto_dns_lookup_fails","goto_dns_lookups","losthdr","n_backend","n_expired","n_gunzip","n_gzip","n_lru_limited","n_lru_moved","n_lru_nuked","n_obj_purged","n_object_hitmiss","n_object_hitpass","n_object","n_objectcore","n_objecthead","n_purges","n_test_gunzip","n_vcl","req_dropped","req_reset","s_fetch","s_pass","s_pipe_hdrbytes","s_pipe_in","s_pipe_out","s_pipe","s_req_bodybytes","s_req_hdrbytes","s_resp_bodybytes","s_resp_hdrbytes","s_sess","s_synth","sc_bankrupt","sc_rapid_reset","sc_sock_closed","sc_vcl_failure","sess_closed_err","sess_closed","sess_conn","sess_drop","sess_dropped","sess_fail_ebadf","sess_fail_econnaborted","sess_fail_eintr","sess_fail_emfile","sess_fail_enomem","sess_fail_other","sess_fail","sess_herd","sess_queued","sess_readahead","shm_cont","shm_cycles","shm_flushes","shm_records","thread_queue_len","threads_created","threads_destroyed","threads_failed","threads_limited","threads","uptime","vcl_fail","vmods","ws_backend_overflow","ws_client_overflow","ws_session_overflow","ws_thread_overflow"].join("|")+")$)"),new RegExp("MSE[.](?!.*[.](?:"+["c_fail","c_memcache_hit","c_memcache_miss","c_ykey_purged","g_bytes","g_space","g_sparenode","g_ykey_keys","n_lru_moved","n_lru_nuked","n_vary"].join("|")+")$)"),new RegExp("MSE_BOOK[.](?!.*[.](?:"+["c_insert_timeout","c_waterlevel_purge","c_waterlevel_queue","c_waterlevel_runs","g_banlist_bytes","g_banlist_space","g_bytes","g_space","n_vary"].join("|")+")$)"),new RegExp("MSE_STORE[.](?!.*[.](?:"+["c_aio_finished_bytes_read","c_aio_finished_bytes_write","c_aio_finished_read","c_aio_finished_write","c_waterlevel_purge","c_waterlevel_queue","g_alloc_bytes","g_free_bytes","g_objects","g_ykey_keys"].join("|")+")$)"),new RegExp("MSE4[.](?!(?:"+["g_varyspec","g_ykey_keys","c_ykey_purged"].join("|")+")$)"),new RegExp("MSE4_MEM[.](?!(?:"+["c_allocation","c_allocation_buffer","c_allocation_ephemeral","c_allocation_failure","c_allocation_pass","c_allocation_persisted","c_allocation_reqbody","c_allocation_synthetic","c_eviction","c_eviction_failure","c_eviction_reorder","c_free","c_free_buffer","c_free_ephemeral","c_free_pass","c_free_persisted","c_free_reqbody","c_free_synthetic","c_memcache_hit","c_memcache_miss","g_allocations","g_bytes","g_bytes_buffer","g_bytes_ephemeral","g_bytes_pass","g_bytes_persisted","g_bytes_reqbody","g_bytes_synthetic","g_objects","g_objects_ephemeral","g_objects_pass","g_objects_persisted","g_objects_reqbody","g_objects_synthetic","g_space"].join("|")+")$)"),new RegExp("MSE4_BOOK[.](?!.*[.](?:"+["c_freeslot_queued","c_submitslot_queued","c_ykey_purged","g_freeslot_queue","g_objects","g_slots_unused","g_slots_used","g_submitslot_queue","g_unreachable_objects","g_varyspec","g_ykey_keys","online"].join("|")+")$)"),new RegExp("MSE4_STORE[.](?!.*[.](?:"+["online","g_bytes_used","g_bytes_unused","g_objects","g_allocation_queue","c_allocation_queued","g_io_queued","g_io_queued_read","g_io_queued_write","c_io_finished_read","c_io_finished_write","c_io_finished_bytes_read","c_io_finished_bytes_write","g_io_blocked_read","g_io_blocked_write","c_io_limited"].join("|")+")$)"),new RegExp("MSE4_BANJRN[.](?!.*[.](?:"+["g_ban_bytes","g_bans","g_bytes","g_overflow_ban_bytes","g_overflow_bans","g_space"].join("|")+")$)"),new RegExp("MSE4_CAT[.](?!.*[.](?:"+["c_allocation","c_allocation_ephemeral","c_allocation_pass","c_allocation_persisted","c_eviction","c_eviction_failure","c_eviction_reorder","c_free","c_free_ephemeral","c_free_pass","c_free_persisted","c_memcache_hit","c_memcache_miss","g_allocations","g_bytes","g_bytes_ephemeral","g_bytes_pass","g_bytes_persisted","g_objects","g_objects_ephemeral","g_objects_pass","g_objects_persisted"].join("|")+")$)"),new RegExp("SMA[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_space"].join("|")+")$)"),new RegExp("SMF[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_smf_frag","g_smf_large","g_smf","g_space"].join("|")+")$)"),new RegExp("SMU[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_space"].join("|")+")$)"),/^BROTLI[.]/,/^SLICER[.]/,new RegExp("VMOD_HTTP[.](?!(?:"+["handle_abandon","handle_completed","handle_internal_error","handle_limited","handle_requests"].join("|")+")$)"),new RegExp("KVSTORE[.](?!.*[.](?:"+[].join("|")+")$)"),new RegExp("ACCG[.](?!.*[.](?:"+["backend_200_count","backend_2xx_count","backend_304_count","backend_3xx_count","backend_404_count","backend_4xx_count","backend_503_count","backend_5xx_count","backend_req_bodybytes","backend_req_count","backend_req_hdrbytes","backend_resp_bodybytes","backend_resp_hdrbytes","client_200_count","client_2xx_count","client_304_count","client_3xx_count","client_404_count","client_4xx_count","client_503_count","client_5xx_count","client_grace_hit_count","client_hit_count","client_hit_req_bodybytes","client_hit_req_hdrbytes","client_hit_resp_bodybytes","client_hit_resp_hdrbytes","client_miss_count","client_miss_req_bodybytes","client_miss_req_hdrbytes","client_miss_resp_bodybytes","client_miss_resp_hdrbytes","client_pass_count","client_pass_req_bodybytes","client_pass_req_hdrbytes","client_pass_resp_bodybytes","client_pass_resp_hdrbytes","client_pipe_count","client_pipe_req_bodybytes","client_pipe_req_hdrbytes","client_pipe_resp_bodybytes","client_pipe_resp_hdrbytes","client_req_bodybytes","client_req_count","client_req_hdrbytes","client_resp_bodybytes","client_resp_hdrbytes","client_synth_count","client_synth_req_bodybytes","client_synth_req_hdrbytes","client_synth_resp_bodybytes","client_synth_resp_hdrbytes"].join("|")+")$)"),new RegExp("ACCG_DIAG[.](?!.*[.](?:"+["bereq_dropped","create_namespace_failure","key_without_namespace","namespace_already_set","namespace_undefined","out_of_key_slots","req_dropped","set_key_failure"].join("|")+")$)"),new RegExp("VBE[.](?!.*[.](?:"+["bereq_bodybytes","bereq_hdrbytes","beresp_bodybytes","beresp_hdrbytes","busy","conn","fail","happy","is_healthy","pipe_hdrbytes","pipe_in","pipe_out","req","unhealthy"].join("|")+")$)"),/^WAITER[.]/,/^MEMPOOL[.]/,/^LCK[.]/],R=[/^(MAIN[.]backend)/,/^(MAIN[.]bans)_?/,/^(MAIN[.]cache)/,/^(MAIN[.]client)/,/^(MAIN[.]esi_)/,/^(MAIN[.]fetch)/,/^(MAIN[.]g_mem)/,/^(MAIN[.]s_)/,/^(MAIN[.]sc_)/,/^(MAIN[.]sess_)/,/^(MAIN[.]shm_)/,/^(MAIN[.]thread)s?_?/,/^(MAIN[.]vgs_)/,/^(MAIN[.]ws_)/,/^(WAITER[.])/,/^(MEMPOOL[.])/,/^(LCK[.])/],F=[/^MGT[.]/,/^MAIN[.][*]$/,/^MAIN[.]/,/^MSE[.]/,/^MSE_/,/^MSE4[.]/,/^MSE4_/,/^SMA[.]/,/^SMF[.]/,/^SMU[.]/,/^BROTLI[.]/,/^SLICER[.]/,/^VMOD_/,/^KVSTORE[.]/,/^ACCG[.]/,/^ACCG_DIAG[.]/,/^VBE[.]/,/^WAITER[.]/,/^MEMPOOL[.]/,/^LCK[.]/];function B(t){t.sort(((t,e)=>t.name.localeCompare(e.name))),function(t){t.forEach((t=>{t.debug=-1!==O.findIndex((e=>e.test(t.name)))}))}(t);const e=function(t){const e={};return t.forEach((t=>{let r="";for(let e of R){const n=t.name.match(e);if(n&&n[1]){r=n[1]+"*";break}}if(""===r){const e=t.name.split(".");e.length>1&&(r=e.slice(0,-1).join(".")+".*")}e[r]||(e[r]=[]),e[r].push(t)})),Object.keys(e).map((t=>({name:t,metrics:e[t]})))}(t);return e.sort(((t,e)=>{const r=F.findIndex((e=>e.test(t.name))),n=F.findIndex((t=>t.test(e.name)));return-1!==r&&-1!==n?r-n:-1!==r?-1:-1!==n?1:t.name.localeCompare(e.name)})),e}function N(t,e){const r=t.sort(((t,e)=>t[0]-e[0])),n=[];for(let t=0;t{t.forEach((t=>{t.target.chart.handleVisibilityChange(t.isIntersecting)}))}),{threshold:.1}),G=new ResizeObserver((t=>{t.forEach((t=>{t.target.chart.handleSizeChange()}))}));const W=class{constructor(t,e,r,n,i,a){this.container=t,this.metric=e,this.rangeFactory=r,this.refreshInterval=n,this.aggregator=i,this.step=a,this.listeners={},this.initializing=!1,this.refreshing=!1,this.debouncedHandleRefresh=s(this.handleRefresh.bind(this),500),this.visible=!1,this.interval=null,this.lastRefresh=0,this.pendingRefresh=!1,this.error=null,this.graph={element:null,x:null,y:null,step:null,range:null,zoomRange:null},H.observe(this.container),G.observe(this.container)}async init(){if(!this.initializing){this.initializing=!0;try{this.processMetric(await this.getMetric()),this.graph.element=this.renderGraph(),this.setupInterval(),this.lastRefresh=l(new Date),this.pendingRefresh=!1}catch(t){this.setError(`Failed to fetch samples of a metric: ${t}`)}finally{this.initializing=!1}}}async handleRefresh(){if(!this.refreshing){this.refreshing=!0;try{if(null!=this.graph.element&&(this.pendingRefresh=!0,this.visible))try{this.processMetric(await this.getMetric()),this.updateGraph(!1),this.clearError(),this.lastRefresh=l(new Date),this.pendingRefresh=!1}catch(t){this.setError(`Failed to fetch samples of a metric: ${t}`)}}finally{this.refreshing=!1}}}handleVisibilityChange(t){this.visible=t,this.visible?null==this.graph.element?this.init():(null==this.interval&&this.setupInterval(),(this.pendingRefresh||this.refreshInterval>0&&l(new Date)-this.lastRefresh>this.refreshInterval)&&this.debouncedHandleRefresh()):this.stopInterval()}handleSizeChange(){null!=this.graph.element&&this.debouncedHandleRefresh()}handleGraphRelayout(t){if(t["xaxis.range[0]"]&&t["xaxis.range[1]"]?this.graph.zoomRange=[new Date(t["xaxis.range[0]"]),new Date(t["xaxis.range[1]"])]:t["xaxis.range"]&&Array.isArray(t["xaxis.range"])&&2===t["xaxis.range"].length?this.graph.zoomRange=[new Date(t["xaxis.range"][0]),new Date(t["xaxis.range"][1])]:this.graph.zoomRange=null,null!=this.graph.zoomRange&&(l(this.graph.zoomRange[0])l(this.graph.range[1])&&(this.graph.zoomRange[1]=this.graph.range[1])),null!=this.graph.zoomRange){const t=l(this.graph.zoomRange[1])-l(this.graph.zoomRange[0]);if(tt!==e)))}notifyEventListeners(t,e){this.listeners[t]&&this.listeners[t].forEach((t=>t(e)))}redraw(t,e,r){let n="normal"===e&&this.metric.debug;if(!n){const e=t.split(/\s+/).filter((t=>t.length>0));e.length>0&&(n=!e.some((t=>this.metric.name.includes(t))))}this.container.classList.toggle("d-none",n),this.container.classList.forEach((t=>{t.startsWith("col-")&&this.container.classList.remove(t)})),this.container.classList.add("col-"+12/r)}setRefreshInterval(t){this.refreshInterval=t,this.visible&&null!=this.graph.element&&this.setupInterval()}refresh(){null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setAggregator(t){this.aggregator=t,null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setStep(t){this.step=t,null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setZoomRange(t){this.graph.zoomRange=t,null!=this.graph.element&&this.updateGraph(!0)}destroy(){H.unobserve(this.container),G.unobserve(this.container),this.stopInterval(),this.clearError(),null!=this.graph.element&&U().purge(this.graph.element)}setupInterval(){this.stopInterval(),this.refreshInterval>0&&(this.interval=setInterval(this.handleRefresh.bind(this),1e3*this.refreshInterval))}stopInterval(){null!=this.interval&&(clearInterval(this.interval),this.interval=null)}setError(t){const e=this.container.querySelector(".card"),r=e.querySelector(".error-icon");null==this.error&&(e.classList.add("border-danger"),r.classList.remove("d-none"));const n=`${(new Date).toISOString()}: ${t}`;let i=q().getInstance(r);null==i?i=new(q())(r,{title:n}):i.setContent({".tooltip-inner":n}),this.error=t}clearError(){if(null!=this.error){const t=this.container.querySelector(".card");t.classList.remove("border-danger");const e=t.querySelector(".error-icon");e.classList.add("d-none");q().getInstance(e).dispose(),this.error=null}}async getMetric(){const t=this.container.querySelector(".card .loading-icon");t.classList.remove("d-none");try{const[t,e]=this.rangeFactory(),r=this.estimateOptimalStep(t,e),n="b"===this.metric.flag?"bit_and":this.aggregator;return await async function(t,e,r,n,i){const a=new URLSearchParams({from:l(e),to:l(r),step:n,aggregator:i}),o=await fetch(`/storage/metrics/${t}?${a.toString()}`);if(!o.ok)throw new Error(`Unexpected API response (${o.status}): ${o.statusText}`);const s=await o.json();return{from:c(s.from),to:c(s.to),step:s.step,samples:N(s.samples,s.step)}}(this.metric.id,t,e,r,n)}finally{t.classList.add("d-none")}}estimateOptimalStep(t,e){const r=(l(e)-l(t))/this.step,n=this.container.clientWidth,i=Math.floor(.9*n);if(i<=0)throw new Error("Failed to estimate the optimal step");return r<=i?this.step:Math.ceil(r/i)*this.step}processMetric(t){this.graph.x=[],this.graph.y=[],t.samples.forEach((t=>{this.graph.x.push(t[0]),this.graph.y.push("b"===this.metric.flag?BigInt(`0x${t[1]}`).toString(2).split("").filter((t=>"1"===t)).length:t[1])})),this.graph.step=t.step,this.graph.range=[t.from,new Date(t.to.getTime()-1e3*t.step)];const e=this.container.querySelector(".card .step-factor");if(this.graph.step!==this.step){const t=Math.round(this.graph.step/this.step);e.innerHTML=` ${t}x`}else e.innerHTML=""}renderGraph(){const t=null!=this.graph.zoomRange?this.graph.zoomRange:this.graph.range,e=[{x:this.graph.x,y:this.graph.y,type:"scatter",mode:this.estimatePlotlyDataMode(...t,this.graph.step),marker:{size:4},hovertemplate:"X: %{x|%Y-%m-%d %H:%M:%S}
Y: %{y:,.1f}",connectgaps:!1,line:{shape:"linear",width:2}}],r={autosize:!0,title:{text:this.metric.name,font:{size:14},subtitle:{text:this.metric.description}},margin:{l:60,r:10,b:40,t:40,pad:5},xaxis:{fixedrange:!1,griddash:"dash",range:Array.from(t),autorange:!1},yaxis:{fixedrange:!0,griddash:"dash",rangemode:"normal",title:(()=>{if("c"===this.metric.flag)return"d"===this.metric.format?"seconds":"B"===this.metric.format?"Bps":"eps";if("g"===this.metric.flag){if("d"===this.metric.format)return"seconds";if("B"===this.metric.format)return"bytes"}return""})()}},n={responsive:!0,displaylogo:!1,modeBarButtonsToRemove:["zoom2d","pan2d","select2d","lasso2d","autoScale2d"],toImageButtonOptions:{filename:`${varnishmon.storage.hostname} - ${this.metric.name}`,format:"png"},scrollZoom:!1},i=this.container.querySelector(".graph");return U().newPlot(i,e,r,n),i.on("plotly_relayout",this.handleGraphRelayout.bind(this)),i}updateGraph(t){const e=null!=this.graph.zoomRange?this.graph.zoomRange:this.graph.range,r={mode:this.estimatePlotlyDataMode(...e,this.graph.step)};t||(r.x=[this.graph.x],r.y=[this.graph.y]);const n={xaxis:{range:Array.from(e)}};U().update(this.graph.element,r,n)}estimatePlotlyDataMode(t,e,r){const n=(l(e)-l(t))/r,i=this.container.clientWidth;return n>Math.floor(.9*i/6)?"lines":"lines+markers"}};var Z=["onChange","onClose","onDayCreate","onDestroy","onKeyDown","onMonthChange","onOpen","onParseConfig","onReady","onValueUpdate","onYearChange","onPreCalendarPosition"],Y={_disable:[],allowInput:!1,allowInvalidPreload:!1,altFormat:"F j, Y",altInput:!1,altInputClass:"form-control input",animate:"object"==typeof window&&-1===window.navigator.userAgent.indexOf("MSIE"),ariaDateFormat:"F j, Y",autoFillDefaultTime:!0,clickOpens:!0,closeOnSelect:!0,conjunction:", ",dateFormat:"Y-m-d",defaultHour:12,defaultMinute:0,defaultSeconds:0,disable:[],disableMobile:!1,enableSeconds:!1,enableTime:!1,errorHandler:function(t){return"undefined"!=typeof console&&console.warn(t)},getWeek:function(t){var e=new Date(t.getTime());e.setHours(0,0,0,0),e.setDate(e.getDate()+3-(e.getDay()+6)%7);var r=new Date(e.getFullYear(),0,4);return 1+Math.round(((e.getTime()-r.getTime())/864e5-3+(r.getDay()+6)%7)/7)},hourIncrement:1,ignoredFocusElements:[],inline:!1,locale:"default",minuteIncrement:5,mode:"single",monthSelectorType:"dropdown",nextArrow:"",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},X={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(t){var e=t%100;if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1};const $=X;var J=function(t,e){return void 0===e&&(e=2),("000"+t).slice(-1*e)},K=function(t){return!0===t?1:0};function Q(t,e){var r;return function(){var n=this,i=arguments;clearTimeout(r),r=setTimeout((function(){return t.apply(n,i)}),e)}}var tt=function(t){return t instanceof Array?t:[t]};function et(t,e,r){if(!0===r)return t.classList.add(e);t.classList.remove(e)}function rt(t,e,r){var n=window.document.createElement(t);return e=e||"",r=r||"",n.className=e,void 0!==r&&(n.textContent=r),n}function nt(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function it(t,e){return e(t)?t:t.parentNode?it(t.parentNode,e):void 0}function at(t,e){var r=rt("div","numInputWrapper"),n=rt("input","numInput "+t),i=rt("span","arrowUp"),a=rt("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?n.type="number":(n.type="text",n.pattern="\\d*"),void 0!==e)for(var o in e)n.setAttribute(o,e[o]);return r.appendChild(n),r.appendChild(i),r.appendChild(a),r}function ot(t){try{return"function"==typeof t.composedPath?t.composedPath()[0]:t.target}catch(e){return t.target}}var st=function(){},lt=function(t,e,r){return r.months[e?"shorthand":"longhand"][t]},ct={D:st,F:function(t,e,r){t.setMonth(r.months.longhand.indexOf(e))},G:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},H:function(t,e){t.setHours(parseFloat(e))},J:function(t,e){t.setDate(parseFloat(e))},K:function(t,e,r){t.setHours(t.getHours()%12+12*K(new RegExp(r.amPM[1],"i").test(e)))},M:function(t,e,r){t.setMonth(r.months.shorthand.indexOf(e))},S:function(t,e){t.setSeconds(parseFloat(e))},U:function(t,e){return new Date(1e3*parseFloat(e))},W:function(t,e,r){var n=parseInt(e),i=new Date(t.getFullYear(),0,2+7*(n-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+r.firstDayOfWeek),i},Y:function(t,e){t.setFullYear(parseFloat(e))},Z:function(t,e){return new Date(e)},d:function(t,e){t.setDate(parseFloat(e))},h:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},i:function(t,e){t.setMinutes(parseFloat(e))},j:function(t,e){t.setDate(parseFloat(e))},l:st,m:function(t,e){t.setMonth(parseFloat(e)-1)},n:function(t,e){t.setMonth(parseFloat(e)-1)},s:function(t,e){t.setSeconds(parseFloat(e))},u:function(t,e){return new Date(parseFloat(e))},w:st,y:function(t,e){t.setFullYear(2e3+parseFloat(e))}},ut={D:"",F:"",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},ht={Z:function(t){return t.toISOString()},D:function(t,e,r){return e.weekdays.shorthand[ht.w(t,e,r)]},F:function(t,e,r){return lt(ht.n(t,e,r)-1,!1,e)},G:function(t,e,r){return J(ht.h(t,e,r))},H:function(t){return J(t.getHours())},J:function(t,e){return void 0!==e.ordinal?t.getDate()+e.ordinal(t.getDate()):t.getDate()},K:function(t,e){return e.amPM[K(t.getHours()>11)]},M:function(t,e){return lt(t.getMonth(),!0,e)},S:function(t){return J(t.getSeconds())},U:function(t){return t.getTime()/1e3},W:function(t,e,r){return r.getWeek(t)},Y:function(t){return J(t.getFullYear(),4)},d:function(t){return J(t.getDate())},h:function(t){return t.getHours()%12?t.getHours()%12:12},i:function(t){return J(t.getMinutes())},j:function(t){return t.getDate()},l:function(t,e){return e.weekdays.longhand[t.getDay()]},m:function(t){return J(t.getMonth()+1)},n:function(t){return t.getMonth()+1},s:function(t){return t.getSeconds()},u:function(t){return t.getTime()},w:function(t){return t.getDay()},y:function(t){return String(t.getFullYear()).substring(2)}},ft=function(t){var e=t.config,r=void 0===e?Y:e,n=t.l10n,i=void 0===n?X:n,a=t.isMobile,o=void 0!==a&&a;return function(t,e,n){var a=n||i;return void 0===r.formatDate||o?e.split("").map((function(e,n,i){return ht[e]&&"\\"!==i[n-1]?ht[e](t,a,r):"\\"!==e?e:""})).join(""):r.formatDate(t,e,a)}},pt=function(t){var e=t.config,r=void 0===e?Y:e,n=t.l10n,i=void 0===n?X:n;return function(t,e,n,a){if(0===t||t){var o,s=a||i,l=t;if(t instanceof Date)o=new Date(t.getTime());else if("string"!=typeof t&&void 0!==t.toFixed)o=new Date(t);else if("string"==typeof t){var c=e||(r||Y).dateFormat,u=String(t).trim();if("today"===u)o=new Date,n=!0;else if(r&&r.parseDate)o=r.parseDate(t,c);else if(/Z$/.test(u)||/GMT$/.test(u))o=new Date(t);else{for(var h=void 0,f=[],p=0,d=0,m="";p=0?new Date:new Date(r.config.minDate.getTime()),n=yt(r.config);e.setHours(n.hours,n.minutes,n.seconds,e.getMilliseconds()),r.selectedDates=[e],r.latestSelectedDateObj=e}void 0!==t&&"blur"!==t.type&&function(t){t.preventDefault();var e="keydown"===t.type,n=ot(t),i=n;void 0!==r.amPM&&n===r.amPM&&(r.amPM.textContent=r.l10n.amPM[K(r.amPM.textContent===r.l10n.amPM[0])]);var a=parseFloat(i.getAttribute("min")),o=parseFloat(i.getAttribute("max")),s=parseFloat(i.getAttribute("step")),l=parseInt(i.value,10),c=t.delta||(e?38===t.which?1:-1:0),u=l+s*c;if(void 0!==i.value&&2===i.value.length){var h=i===r.hourElement,f=i===r.minuteElement;uo&&(u=i===r.hourElement?u-o-K(!r.amPM):a,f&&m(void 0,1,r.hourElement)),r.amPM&&h&&(1===s?u+l===23:Math.abs(u-l)>s)&&(r.amPM.textContent=r.l10n.amPM[K(r.amPM.textContent===r.l10n.amPM[0])]),i.value=J(u)}}(t);var i=r._input.value;s(),Tt(),r._input.value!==i&&r._debouncedChange()}function s(){if(void 0!==r.hourElement&&void 0!==r.minuteElement){var t,e,n=(parseInt(r.hourElement.value.slice(-2),10)||0)%24,i=(parseInt(r.minuteElement.value,10)||0)%60,a=void 0!==r.secondElement?(parseInt(r.secondElement.value,10)||0)%60:0;void 0!==r.amPM&&(t=n,e=r.amPM.textContent,n=t%12+12*K(e===r.l10n.amPM[1]));var o=void 0!==r.config.minTime||r.config.minDate&&r.minDateHasTime&&r.latestSelectedDateObj&&0===dt(r.latestSelectedDateObj,r.config.minDate,!0),s=void 0!==r.config.maxTime||r.config.maxDate&&r.maxDateHasTime&&r.latestSelectedDateObj&&0===dt(r.latestSelectedDateObj,r.config.maxDate,!0);if(void 0!==r.config.maxTime&&void 0!==r.config.minTime&&r.config.minTime>r.config.maxTime){var l=mt(r.config.minTime.getHours(),r.config.minTime.getMinutes(),r.config.minTime.getSeconds()),u=mt(r.config.maxTime.getHours(),r.config.maxTime.getMinutes(),r.config.maxTime.getSeconds()),h=mt(n,i,a);if(h>u&&h=12)]),void 0!==r.secondElement&&(r.secondElement.value=J(n)))}function u(t){var e=ot(t),r=parseInt(e.value)+(t.delta||0);(r/1e3>1||"Enter"===t.key&&!/[^\d]/.test(r.toString()))&&L(r)}function h(t,e,n,i){return e instanceof Array?e.forEach((function(e){return h(t,e,n,i)})):t instanceof Array?t.forEach((function(t){return h(t,e,n,i)})):(t.addEventListener(e,n,i),void r._handlers.push({remove:function(){return t.removeEventListener(e,n,i)}}))}function f(){st("onChange")}function p(t,e){var n=void 0!==t?r.parseDate(t):r.latestSelectedDateObj||(r.config.minDate&&r.config.minDate>r.now?r.config.minDate:r.config.maxDate&&r.config.maxDate=0&&dt(t,r.selectedDates[1])<=0)}(e)&&!ht(e)&&o.classList.add("inRange"),r.weekNumbers&&1===r.config.showMonths&&"prevMonthDay"!==t&&i%7==6&&r.weekNumbers.insertAdjacentHTML("beforeend",""+r.config.getWeek(e)+""),st("onDayCreate",o),o}function y(t){t.focus(),"range"===r.config.mode&&O(t)}function v(t){for(var e=t>0?0:r.config.showMonths-1,n=t>0?r.config.showMonths:-1,i=e;i!=n;i+=t)for(var a=r.daysContainer.children[i],o=t>0?0:a.children.length-1,s=t>0?a.children.length:-1,l=o;l!=s;l+=t){var c=a.children[l];if(-1===c.className.indexOf("hidden")&&I(c.dateObj))return c}}function x(t,e){var i=n(),a=P(i||document.body),o=void 0!==t?t:a?i:void 0!==r.selectedDateElem&&P(r.selectedDateElem)?r.selectedDateElem:void 0!==r.todayDateElem&&P(r.todayDateElem)?r.todayDateElem:v(e>0?1:-1);void 0===o?r._input.focus():a?function(t,e){for(var n=-1===t.className.indexOf("Month")?t.dateObj.getMonth():r.currentMonth,i=e>0?r.config.showMonths:-1,a=e>0?1:-1,o=n-r.currentMonth;o!=i;o+=a)for(var s=r.daysContainer.children[o],l=n-r.currentMonth===o?t.$i+e:e<0?s.children.length-1:0,c=s.children.length,u=l;u>=0&&u0?c:-1);u+=a){var h=s.children[u];if(-1===h.className.indexOf("hidden")&&I(h.dateObj)&&Math.abs(t.$i-u)>=Math.abs(e))return y(h)}r.changeMonth(a),x(v(a),0)}(o,e):y(o)}function _(t,e){for(var n=(new Date(t,e,1).getDay()-r.l10n.firstDayOfWeek+7)%7,i=r.utils.getDaysInMonth((e-1+12)%12,t),a=r.utils.getDaysInMonth(e,t),o=window.document.createDocumentFragment(),s=r.config.showMonths>1,l=s?"prevMonthDay hidden":"prevMonthDay",c=s?"nextMonthDay hidden":"nextMonthDay",u=i+1-n,h=0;u<=i;u++,h++)o.appendChild(g("flatpickr-day "+l,new Date(t,e-1,u),0,h));for(u=1;u<=a;u++,h++)o.appendChild(g("flatpickr-day",new Date(t,e,u),0,h));for(var f=a+1;f<=42-n&&(1===r.config.showMonths||h%7!=0);f++,h++)o.appendChild(g("flatpickr-day "+c,new Date(t,e+1,f%a),0,h));var p=rt("div","dayContainer");return p.appendChild(o),p}function b(){if(void 0!==r.daysContainer){nt(r.daysContainer),r.weekNumbers&&nt(r.weekNumbers);for(var t=document.createDocumentFragment(),e=0;e1||"dropdown"!==r.config.monthSelectorType)){var t=function(t){return!(void 0!==r.config.minDate&&r.currentYear===r.config.minDate.getFullYear()&&tr.config.maxDate.getMonth())};r.monthsDropdownContainer.tabIndex=-1,r.monthsDropdownContainer.innerHTML="";for(var e=0;e<12;e++)if(t(e)){var n=rt("option","flatpickr-monthDropdown-month");n.value=new Date(r.currentYear,e).getMonth().toString(),n.textContent=lt(e,r.config.shorthandCurrentMonth,r.l10n),n.tabIndex=-1,r.currentMonth===e&&(n.selected=!0),r.monthsDropdownContainer.appendChild(n)}}}function T(){var t,e=rt("div","flatpickr-month"),n=window.document.createDocumentFragment();r.config.showMonths>1||"static"===r.config.monthSelectorType?t=rt("span","cur-month"):(r.monthsDropdownContainer=rt("select","flatpickr-monthDropdown-months"),r.monthsDropdownContainer.setAttribute("aria-label",r.l10n.monthAriaLabel),h(r.monthsDropdownContainer,"change",(function(t){var e=ot(t),n=parseInt(e.value,10);r.changeMonth(n-r.currentMonth),st("onMonthChange")})),w(),t=r.monthsDropdownContainer);var i=at("cur-year",{tabindex:"-1"}),a=i.getElementsByTagName("input")[0];a.setAttribute("aria-label",r.l10n.yearAriaLabel),r.config.minDate&&a.setAttribute("min",r.config.minDate.getFullYear().toString()),r.config.maxDate&&(a.setAttribute("max",r.config.maxDate.getFullYear().toString()),a.disabled=!!r.config.minDate&&r.config.minDate.getFullYear()===r.config.maxDate.getFullYear());var o=rt("div","flatpickr-current-month");return o.appendChild(t),o.appendChild(i),n.appendChild(o),e.appendChild(n),{container:e,yearElement:a,monthElement:t}}function k(){nt(r.monthNav),r.monthNav.appendChild(r.prevMonthNav),r.config.showMonths&&(r.yearElements=[],r.monthElements=[]);for(var t=r.config.showMonths;t--;){var e=T();r.yearElements.push(e.yearElement),r.monthElements.push(e.monthElement),r.monthNav.appendChild(e.container)}r.monthNav.appendChild(r.nextMonthNav)}function A(){r.weekdayContainer?nt(r.weekdayContainer):r.weekdayContainer=rt("div","flatpickr-weekdays");for(var t=r.config.showMonths;t--;){var e=rt("div","flatpickr-weekdaycontainer");r.weekdayContainer.appendChild(e)}return M(),r.weekdayContainer}function M(){if(r.weekdayContainer){var t=r.l10n.firstDayOfWeek,e=xt(r.l10n.weekdays.shorthand);t>0&&t\n "+e.join("")+"\n \n "}}function S(t,e){void 0===e&&(e=!0);var n=e?t:t-r.currentMonth;n<0&&!0===r._hidePrevMonthArrow||n>0&&!0===r._hideNextMonthArrow||(r.currentMonth+=n,(r.currentMonth<0||r.currentMonth>11)&&(r.currentYear+=r.currentMonth>11?1:-1,r.currentMonth=(r.currentMonth+12)%12,st("onYearChange"),w()),b(),st("onMonthChange"),_t())}function E(t){return r.calendarContainer.contains(t)}function C(t){if(r.isOpen&&!r.config.inline){var e=ot(t),n=E(e),i=!(e===r.input||e===r.altInput||r.element.contains(e)||t.path&&t.path.indexOf&&(~t.path.indexOf(r.input)||~t.path.indexOf(r.altInput)))&&!n&&!E(t.relatedTarget),a=!r.config.ignoredFocusElements.some((function(t){return t.contains(e)}));i&&a&&(r.config.allowInput&&r.setDate(r._input.value,!1,r.config.altInput?r.config.altFormat:r.config.dateFormat),void 0!==r.timeContainer&&void 0!==r.minuteElement&&void 0!==r.hourElement&&""!==r.input.value&&void 0!==r.input.value&&o(),r.close(),r.config&&"range"===r.config.mode&&1===r.selectedDates.length&&r.clear(!1))}}function L(t){if(!(!t||r.config.minDate&&tr.config.maxDate.getFullYear())){var e=t,n=r.currentYear!==e;r.currentYear=e||r.currentYear,r.config.maxDate&&r.currentYear===r.config.maxDate.getFullYear()?r.currentMonth=Math.min(r.config.maxDate.getMonth(),r.currentMonth):r.config.minDate&&r.currentYear===r.config.minDate.getFullYear()&&(r.currentMonth=Math.max(r.config.minDate.getMonth(),r.currentMonth)),n&&(r.redraw(),st("onYearChange"),w())}}function I(t,e){var n;void 0===e&&(e=!0);var i=r.parseDate(t,void 0,e);if(r.config.minDate&&i&&dt(i,r.config.minDate,void 0!==e?e:!r.minDateHasTime)<0||r.config.maxDate&&i&&dt(i,r.config.maxDate,void 0!==e?e:!r.maxDateHasTime)>0)return!1;if(!r.config.enable&&0===r.config.disable.length)return!0;if(void 0===i)return!1;for(var a=!!r.config.enable,o=null!==(n=r.config.enable)&&void 0!==n?n:r.config.disable,s=0,l=void 0;s=l.from.getTime()&&i.getTime()<=l.to.getTime())return a}return!a}function P(t){return void 0!==r.daysContainer&&(-1===t.className.indexOf("hidden")&&-1===t.className.indexOf("flatpickr-disabled")&&r.daysContainer.contains(t))}function z(t){var e=t.target===r._input,n=r._input.value.trimEnd()!==bt();!e||!n||t.relatedTarget&&E(t.relatedTarget)||r.setDate(r._input.value,!0,t.target===r.altInput?r.config.altFormat:r.config.dateFormat)}function D(e){var i=ot(e),a=r.config.wrap?t.contains(i):i===r._input,l=r.config.allowInput,c=r.isOpen&&(!l||!a),u=r.config.inline&&a&&!l;if(13===e.keyCode&&a){if(l)return r.setDate(r._input.value,!0,i===r.altInput?r.config.altFormat:r.config.dateFormat),r.close(),i.blur();r.open()}else if(E(i)||c||u){var h=!!r.timeContainer&&r.timeContainer.contains(i);switch(e.keyCode){case 13:h?(e.preventDefault(),o(),V()):q(e);break;case 27:e.preventDefault(),V();break;case 8:case 46:a&&!r.config.allowInput&&(e.preventDefault(),r.clear());break;case 37:case 39:if(h||a)r.hourElement&&r.hourElement.focus();else{e.preventDefault();var f=n();if(void 0!==r.daysContainer&&(!1===l||f&&P(f))){var p=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),S(p),x(v(1),0)):x(void 0,p)}}break;case 38:case 40:e.preventDefault();var d=40===e.keyCode?1:-1;r.daysContainer&&void 0!==i.$i||i===r.input||i===r.altInput?e.ctrlKey?(e.stopPropagation(),L(r.currentYear-d),x(v(1),0)):h||x(void 0,7*d):i===r.currentYearElement?L(r.currentYear-d):r.config.enableTime&&(!h&&r.hourElement&&r.hourElement.focus(),o(e),r._debouncedChange());break;case 9:if(h){var m=[r.hourElement,r.minuteElement,r.secondElement,r.amPM].concat(r.pluginElements).filter((function(t){return t})),g=m.indexOf(i);if(-1!==g){var y=m[g+(e.shiftKey?-1:1)];e.preventDefault(),(y||r._input).focus()}}else!r.config.noCalendar&&r.daysContainer&&r.daysContainer.contains(i)&&e.shiftKey&&(e.preventDefault(),r._input.focus())}}if(void 0!==r.amPM&&i===r.amPM)switch(e.key){case r.l10n.amPM[0].charAt(0):case r.l10n.amPM[0].charAt(0).toLowerCase():r.amPM.textContent=r.l10n.amPM[0],s(),Tt();break;case r.l10n.amPM[1].charAt(0):case r.l10n.amPM[1].charAt(0).toLowerCase():r.amPM.textContent=r.l10n.amPM[1],s(),Tt()}(a||E(i))&&st("onKeyDown",e)}function O(t,e){if(void 0===e&&(e="flatpickr-day"),1===r.selectedDates.length&&(!t||t.classList.contains(e)&&!t.classList.contains("flatpickr-disabled"))){for(var n=t?t.dateObj.getTime():r.days.firstElementChild.dateObj.getTime(),i=r.parseDate(r.selectedDates[0],void 0,!0).getTime(),a=Math.min(n,r.selectedDates[0].getTime()),o=Math.max(n,r.selectedDates[0].getTime()),s=!1,l=0,c=0,u=a;ua&&ul)?l=u:u>i&&(!c||u ."+e)).forEach((function(e){var a,o,u,h=e.dateObj.getTime(),f=l>0&&h0&&h>c;if(f)return e.classList.add("notAllowed"),void["inRange","startRange","endRange"].forEach((function(t){e.classList.remove(t)}));s&&!f||(["startRange","inRange","endRange","notAllowed"].forEach((function(t){e.classList.remove(t)})),void 0!==t&&(t.classList.add(n<=r.selectedDates[0].getTime()?"startRange":"endRange"),in&&h===i&&e.classList.add("endRange"),h>=l&&(0===c||h<=c)&&(o=i,u=n,(a=h)>Math.min(o,u)&&a0||n.getMinutes()>0||n.getSeconds()>0),r.selectedDates&&(r.selectedDates=r.selectedDates.filter((function(t){return I(t)})),r.selectedDates.length||"min"!==t||l(n),Tt()),r.daysContainer&&(U(),void 0!==n?r.currentYearElement[t]=n.getFullYear().toString():r.currentYearElement.removeAttribute(t),r.currentYearElement.disabled=!!i&&void 0!==n&&i.getFullYear()===n.getFullYear())}}function B(){return r.config.wrap?t.querySelector("[data-input]"):t}function N(){"object"!=typeof r.config.locale&&void 0===wt.l10ns[r.config.locale]&&r.config.errorHandler(new Error("flatpickr: invalid locale "+r.config.locale)),r.l10n=vt(vt({},wt.l10ns.default),"object"==typeof r.config.locale?r.config.locale:"default"!==r.config.locale?wt.l10ns[r.config.locale]:void 0),ut.D="("+r.l10n.weekdays.shorthand.join("|")+")",ut.l="("+r.l10n.weekdays.longhand.join("|")+")",ut.M="("+r.l10n.months.shorthand.join("|")+")",ut.F="("+r.l10n.months.longhand.join("|")+")",ut.K="("+r.l10n.amPM[0]+"|"+r.l10n.amPM[1]+"|"+r.l10n.amPM[0].toLowerCase()+"|"+r.l10n.amPM[1].toLowerCase()+")",void 0===vt(vt({},e),JSON.parse(JSON.stringify(t.dataset||{}))).time_24hr&&void 0===wt.defaultConfig.time_24hr&&(r.config.time_24hr=r.l10n.time_24hr),r.formatDate=ft(r),r.parseDate=pt({config:r.config,l10n:r.l10n})}function j(t){if("function"!=typeof r.config.position){if(void 0!==r.calendarContainer){st("onPreCalendarPosition");var e=t||r._positionElement,n=Array.prototype.reduce.call(r.calendarContainer.children,(function(t,e){return t+e.offsetHeight}),0),i=r.calendarContainer.offsetWidth,a=r.config.position.split(" "),o=a[0],s=a.length>1?a[1]:null,l=e.getBoundingClientRect(),c=window.innerHeight-l.bottom,u="above"===o||"below"!==o&&cn,h=window.pageYOffset+l.top+(u?-n-2:e.offsetHeight+2);if(et(r.calendarContainer,"arrowTop",!u),et(r.calendarContainer,"arrowBottom",u),!r.config.inline){var f=window.pageXOffset+l.left,p=!1,d=!1;"center"===s?(f-=(i-l.width)/2,p=!0):"right"===s&&(f-=i-l.width,d=!0),et(r.calendarContainer,"arrowLeft",!p&&!d),et(r.calendarContainer,"arrowCenter",p),et(r.calendarContainer,"arrowRight",d);var m=window.document.body.offsetWidth-(window.pageXOffset+l.right),g=f+i>window.document.body.offsetWidth,y=m+i>window.document.body.offsetWidth;if(et(r.calendarContainer,"rightMost",g),!r.config.static)if(r.calendarContainer.style.top=h+"px",g)if(y){var v=function(){for(var t=null,e=0;er.currentMonth+r.config.showMonths-1)&&"range"!==r.config.mode;if(r.selectedDateElem=n,"single"===r.config.mode)r.selectedDates=[i];else if("multiple"===r.config.mode){var o=ht(i);o?r.selectedDates.splice(parseInt(o),1):r.selectedDates.push(i)}else"range"===r.config.mode&&(2===r.selectedDates.length&&r.clear(!1,!1),r.latestSelectedDateObj=i,r.selectedDates.push(i),0!==dt(i,r.selectedDates[0],!0)&&r.selectedDates.sort((function(t,e){return t.getTime()-e.getTime()})));if(s(),a){var l=r.currentYear!==i.getFullYear();r.currentYear=i.getFullYear(),r.currentMonth=i.getMonth(),l&&(st("onYearChange"),w()),st("onMonthChange")}if(_t(),b(),Tt(),a||"range"===r.config.mode||1!==r.config.showMonths?void 0!==r.selectedDateElem&&void 0===r.hourElement&&r.selectedDateElem&&r.selectedDateElem.focus():y(n),void 0!==r.hourElement&&void 0!==r.hourElement&&r.hourElement.focus(),r.config.closeOnSelect){var c="single"===r.config.mode&&!r.config.enableTime,u="range"===r.config.mode&&2===r.selectedDates.length&&!r.config.enableTime;(c||u)&&V()}f()}}r.parseDate=pt({config:r.config,l10n:r.l10n}),r._handlers=[],r.pluginElements=[],r.loadedPlugins=[],r._bind=h,r._setHoursFromDate=l,r._positionCalendar=j,r.changeMonth=S,r.changeYear=L,r.clear=function(t,e){void 0===t&&(t=!0);void 0===e&&(e=!0);r.input.value="",void 0!==r.altInput&&(r.altInput.value="");void 0!==r.mobileInput&&(r.mobileInput.value="");r.selectedDates=[],r.latestSelectedDateObj=void 0,!0===e&&(r.currentYear=r._initialDate.getFullYear(),r.currentMonth=r._initialDate.getMonth());if(!0===r.config.enableTime){var n=yt(r.config);c(n.hours,n.minutes,n.seconds)}r.redraw(),t&&st("onChange")},r.close=function(){r.isOpen=!1,r.isMobile||(void 0!==r.calendarContainer&&r.calendarContainer.classList.remove("open"),void 0!==r._input&&r._input.classList.remove("active"));st("onClose")},r.onMouseOver=O,r._createElement=rt,r.createDay=g,r.destroy=function(){void 0!==r.config&&st("onDestroy");for(var t=r._handlers.length;t--;)r._handlers[t].remove();if(r._handlers=[],r.mobileInput)r.mobileInput.parentNode&&r.mobileInput.parentNode.removeChild(r.mobileInput),r.mobileInput=void 0;else if(r.calendarContainer&&r.calendarContainer.parentNode)if(r.config.static&&r.calendarContainer.parentNode){var e=r.calendarContainer.parentNode;if(e.lastChild&&e.removeChild(e.lastChild),e.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}}else r.calendarContainer.parentNode.removeChild(r.calendarContainer);r.altInput&&(r.input.type="text",r.altInput.parentNode&&r.altInput.parentNode.removeChild(r.altInput),delete r.altInput);r.input&&(r.input.type=r.input._type,r.input.classList.remove("flatpickr-input"),r.input.removeAttribute("readonly"));["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach((function(t){try{delete r[t]}catch(t){}}))},r.isEnabled=I,r.jumpToDate=p,r.updateValue=Tt,r.open=function(t,e){void 0===e&&(e=r._positionElement);if(!0===r.isMobile){if(t){t.preventDefault();var n=ot(t);n&&n.blur()}return void 0!==r.mobileInput&&(r.mobileInput.focus(),r.mobileInput.click()),void st("onOpen")}if(r._input.disabled||r.config.inline)return;var i=r.isOpen;r.isOpen=!0,i||(r.calendarContainer.classList.add("open"),r._input.classList.add("active"),st("onOpen"),j(e));!0===r.config.enableTime&&!0===r.config.noCalendar&&(!1!==r.config.allowInput||void 0!==t&&r.timeContainer.contains(t.relatedTarget)||setTimeout((function(){return r.hourElement.select()}),50))},r.redraw=U,r.set=function(t,e){if(null!==t&&"object"==typeof t)for(var n in Object.assign(r.config,t),t)void 0!==H[n]&&H[n].forEach((function(t){return t()}));else r.config[t]=e,void 0!==H[t]?H[t].forEach((function(t){return t()})):Z.indexOf(t)>-1&&(r.config[t]=tt(e));r.redraw(),Tt(!0)},r.setDate=function(t,e,n){void 0===e&&(e=!1);void 0===n&&(n=r.config.dateFormat);if(0!==t&&!t||t instanceof Array&&0===t.length)return r.clear(e);G(t,n),r.latestSelectedDateObj=r.selectedDates[r.selectedDates.length-1],r.redraw(),p(void 0,e),l(),0===r.selectedDates.length&&r.clear(!1);Tt(e),e&&st("onChange")},r.toggle=function(t){if(!0===r.isOpen)return r.close();r.open(t)};var H={locale:[N,M],showMonths:[k,a,A],minDate:[p],maxDate:[p],positionElement:[X],clickOpens:[function(){!0===r.config.clickOpens?(h(r._input,"focus",r.open),h(r._input,"click",r.open)):(r._input.removeEventListener("focus",r.open),r._input.removeEventListener("click",r.open))}]};function G(t,e){var n=[];if(t instanceof Array)n=t.map((function(t){return r.parseDate(t,e)}));else if(t instanceof Date||"number"==typeof t)n=[r.parseDate(t,e)];else if("string"==typeof t)switch(r.config.mode){case"single":case"time":n=[r.parseDate(t,e)];break;case"multiple":n=t.split(r.config.conjunction).map((function(t){return r.parseDate(t,e)}));break;case"range":n=t.split(r.l10n.rangeSeparator).map((function(t){return r.parseDate(t,e)}))}else r.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(t)));r.selectedDates=r.config.allowInvalidPreload?n:n.filter((function(t){return t instanceof Date&&I(t,!1)})),"range"===r.config.mode&&r.selectedDates.sort((function(t,e){return t.getTime()-e.getTime()}))}function W(t){return t.slice().map((function(t){return"string"==typeof t||"number"==typeof t||t instanceof Date?r.parseDate(t,void 0,!0):t&&"object"==typeof t&&t.from&&t.to?{from:r.parseDate(t.from,void 0),to:r.parseDate(t.to,void 0)}:t})).filter((function(t){return t}))}function X(){r._positionElement=r.config.positionElement||r._input}function st(t,e){if(void 0!==r.config){var n=r.config[t];if(void 0!==n&&n.length>0)for(var i=0;n[i]&&i1||"static"===r.config.monthSelectorType?r.monthElements[e].textContent=lt(n.getMonth(),r.config.shorthandCurrentMonth,r.l10n)+" ":r.monthsDropdownContainer.value=n.getMonth().toString(),t.value=n.getFullYear().toString()})),r._hidePrevMonthArrow=void 0!==r.config.minDate&&(r.currentYear===r.config.minDate.getFullYear()?r.currentMonth<=r.config.minDate.getMonth():r.currentYearr.config.maxDate.getMonth():r.currentYear>r.config.maxDate.getFullYear()))}function bt(t){var e=t||(r.config.altInput?r.config.altFormat:r.config.dateFormat);return r.selectedDates.map((function(t){return r.formatDate(t,e)})).filter((function(t,e,n){return"range"!==r.config.mode||r.config.enableTime||n.indexOf(t)===e})).join("range"!==r.config.mode?r.config.conjunction:r.l10n.rangeSeparator)}function Tt(t){void 0===t&&(t=!0),void 0!==r.mobileInput&&r.mobileFormatStr&&(r.mobileInput.value=void 0!==r.latestSelectedDateObj?r.formatDate(r.latestSelectedDateObj,r.mobileFormatStr):""),r.input.value=bt(r.config.dateFormat),void 0!==r.altInput&&(r.altInput.value=bt(r.config.altFormat)),!1!==t&&st("onValueUpdate")}function kt(t){var e=ot(t),n=r.prevMonthNav.contains(e),i=r.nextMonthNav.contains(e);n||i?S(n?-1:1):r.yearElements.indexOf(e)>=0?e.select():e.classList.contains("arrowUp")?r.changeYear(r.currentYear+1):e.classList.contains("arrowDown")&&r.changeYear(r.currentYear-1)}return function(){r.element=r.input=t,r.isOpen=!1,function(){var n=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],a=vt(vt({},JSON.parse(JSON.stringify(t.dataset||{}))),e),o={};r.config.parseDate=a.parseDate,r.config.formatDate=a.formatDate,Object.defineProperty(r.config,"enable",{get:function(){return r.config._enable},set:function(t){r.config._enable=W(t)}}),Object.defineProperty(r.config,"disable",{get:function(){return r.config._disable},set:function(t){r.config._disable=W(t)}});var s="time"===a.mode;if(!a.dateFormat&&(a.enableTime||s)){var l=wt.defaultConfig.dateFormat||Y.dateFormat;o.dateFormat=a.noCalendar||s?"H:i"+(a.enableSeconds?":S":""):l+" H:i"+(a.enableSeconds?":S":"")}if(a.altInput&&(a.enableTime||s)&&!a.altFormat){var c=wt.defaultConfig.altFormat||Y.altFormat;o.altFormat=a.noCalendar||s?"h:i"+(a.enableSeconds?":S K":" K"):c+" h:i"+(a.enableSeconds?":S":"")+" K"}Object.defineProperty(r.config,"minDate",{get:function(){return r.config._minDate},set:F("min")}),Object.defineProperty(r.config,"maxDate",{get:function(){return r.config._maxDate},set:F("max")});var u=function(t){return function(e){r.config["min"===t?"_minTime":"_maxTime"]=r.parseDate(e,"H:i:S")}};Object.defineProperty(r.config,"minTime",{get:function(){return r.config._minTime},set:u("min")}),Object.defineProperty(r.config,"maxTime",{get:function(){return r.config._maxTime},set:u("max")}),"time"===a.mode&&(r.config.noCalendar=!0,r.config.enableTime=!0);Object.assign(r.config,o,a);for(var h=0;h-1?r.config[p]=tt(f[p]).map(i).concat(r.config[p]):void 0===a[p]&&(r.config[p]=f[p])}a.altInputClass||(r.config.altInputClass=B().className+" "+r.config.altInputClass);st("onParseConfig")}(),N(),function(){if(r.input=B(),!r.input)return void r.config.errorHandler(new Error("Invalid input element specified"));r.input._type=r.input.type,r.input.type="text",r.input.classList.add("flatpickr-input"),r._input=r.input,r.config.altInput&&(r.altInput=rt(r.input.nodeName,r.config.altInputClass),r._input=r.altInput,r.altInput.placeholder=r.input.placeholder,r.altInput.disabled=r.input.disabled,r.altInput.required=r.input.required,r.altInput.tabIndex=r.input.tabIndex,r.altInput.type="text",r.input.setAttribute("type","hidden"),!r.config.static&&r.input.parentNode&&r.input.parentNode.insertBefore(r.altInput,r.input.nextSibling));r.config.allowInput||r._input.setAttribute("readonly","readonly");X()}(),function(){r.selectedDates=[],r.now=r.parseDate(r.config.now)||new Date;var t=r.config.defaultDate||("INPUT"!==r.input.nodeName&&"TEXTAREA"!==r.input.nodeName||!r.input.placeholder||r.input.value!==r.input.placeholder?r.input.value:null);t&&G(t,r.config.dateFormat);r._initialDate=r.selectedDates.length>0?r.selectedDates[0]:r.config.minDate&&r.config.minDate.getTime()>r.now.getTime()?r.config.minDate:r.config.maxDate&&r.config.maxDate.getTime()0&&(r.latestSelectedDateObj=r.selectedDates[0]);void 0!==r.config.minTime&&(r.config.minTime=r.parseDate(r.config.minTime,"H:i"));void 0!==r.config.maxTime&&(r.config.maxTime=r.parseDate(r.config.maxTime,"H:i"));r.minDateHasTime=!!r.config.minDate&&(r.config.minDate.getHours()>0||r.config.minDate.getMinutes()>0||r.config.minDate.getSeconds()>0),r.maxDateHasTime=!!r.config.maxDate&&(r.config.maxDate.getHours()>0||r.config.maxDate.getMinutes()>0||r.config.maxDate.getSeconds()>0)}(),r.utils={getDaysInMonth:function(t,e){return void 0===t&&(t=r.currentMonth),void 0===e&&(e=r.currentYear),1===t&&(e%4==0&&e%100!=0||e%400==0)?29:r.l10n.daysInMonth[t]}},r.isMobile||function(){var t=window.document.createDocumentFragment();if(r.calendarContainer=rt("div","flatpickr-calendar"),r.calendarContainer.tabIndex=-1,!r.config.noCalendar){if(t.appendChild((r.monthNav=rt("div","flatpickr-months"),r.yearElements=[],r.monthElements=[],r.prevMonthNav=rt("span","flatpickr-prev-month"),r.prevMonthNav.innerHTML=r.config.prevArrow,r.nextMonthNav=rt("span","flatpickr-next-month"),r.nextMonthNav.innerHTML=r.config.nextArrow,k(),Object.defineProperty(r,"_hidePrevMonthArrow",{get:function(){return r.__hidePrevMonthArrow},set:function(t){r.__hidePrevMonthArrow!==t&&(et(r.prevMonthNav,"flatpickr-disabled",t),r.__hidePrevMonthArrow=t)}}),Object.defineProperty(r,"_hideNextMonthArrow",{get:function(){return r.__hideNextMonthArrow},set:function(t){r.__hideNextMonthArrow!==t&&(et(r.nextMonthNav,"flatpickr-disabled",t),r.__hideNextMonthArrow=t)}}),r.currentYearElement=r.yearElements[0],_t(),r.monthNav)),r.innerContainer=rt("div","flatpickr-innerContainer"),r.config.weekNumbers){var e=function(){r.calendarContainer.classList.add("hasWeeks");var t=rt("div","flatpickr-weekwrapper");t.appendChild(rt("span","flatpickr-weekday",r.l10n.weekAbbreviation));var e=rt("div","flatpickr-weeks");return t.appendChild(e),{weekWrapper:t,weekNumbers:e}}(),n=e.weekWrapper,i=e.weekNumbers;r.innerContainer.appendChild(n),r.weekNumbers=i,r.weekWrapper=n}r.rContainer=rt("div","flatpickr-rContainer"),r.rContainer.appendChild(A()),r.daysContainer||(r.daysContainer=rt("div","flatpickr-days"),r.daysContainer.tabIndex=-1),b(),r.rContainer.appendChild(r.daysContainer),r.innerContainer.appendChild(r.rContainer),t.appendChild(r.innerContainer)}r.config.enableTime&&t.appendChild(function(){r.calendarContainer.classList.add("hasTime"),r.config.noCalendar&&r.calendarContainer.classList.add("noCalendar");var t=yt(r.config);r.timeContainer=rt("div","flatpickr-time"),r.timeContainer.tabIndex=-1;var e=rt("span","flatpickr-time-separator",":"),n=at("flatpickr-hour",{"aria-label":r.l10n.hourAriaLabel});r.hourElement=n.getElementsByTagName("input")[0];var i=at("flatpickr-minute",{"aria-label":r.l10n.minuteAriaLabel});r.minuteElement=i.getElementsByTagName("input")[0],r.hourElement.tabIndex=r.minuteElement.tabIndex=-1,r.hourElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getHours():r.config.time_24hr?t.hours:function(t){switch(t%24){case 0:case 12:return 12;default:return t%12}}(t.hours)),r.minuteElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getMinutes():t.minutes),r.hourElement.setAttribute("step",r.config.hourIncrement.toString()),r.minuteElement.setAttribute("step",r.config.minuteIncrement.toString()),r.hourElement.setAttribute("min",r.config.time_24hr?"0":"1"),r.hourElement.setAttribute("max",r.config.time_24hr?"23":"12"),r.hourElement.setAttribute("maxlength","2"),r.minuteElement.setAttribute("min","0"),r.minuteElement.setAttribute("max","59"),r.minuteElement.setAttribute("maxlength","2"),r.timeContainer.appendChild(n),r.timeContainer.appendChild(e),r.timeContainer.appendChild(i),r.config.time_24hr&&r.timeContainer.classList.add("time24hr");if(r.config.enableSeconds){r.timeContainer.classList.add("hasSeconds");var a=at("flatpickr-second");r.secondElement=a.getElementsByTagName("input")[0],r.secondElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getSeconds():t.seconds),r.secondElement.setAttribute("step",r.minuteElement.getAttribute("step")),r.secondElement.setAttribute("min","0"),r.secondElement.setAttribute("max","59"),r.secondElement.setAttribute("maxlength","2"),r.timeContainer.appendChild(rt("span","flatpickr-time-separator",":")),r.timeContainer.appendChild(a)}r.config.time_24hr||(r.amPM=rt("span","flatpickr-am-pm",r.l10n.amPM[K((r.latestSelectedDateObj?r.hourElement.value:r.config.defaultHour)>11)]),r.amPM.title=r.l10n.toggleTitle,r.amPM.tabIndex=-1,r.timeContainer.appendChild(r.amPM));return r.timeContainer}());et(r.calendarContainer,"rangeMode","range"===r.config.mode),et(r.calendarContainer,"animate",!0===r.config.animate),et(r.calendarContainer,"multiMonth",r.config.showMonths>1),r.calendarContainer.appendChild(t);var a=void 0!==r.config.appendTo&&void 0!==r.config.appendTo.nodeType;if((r.config.inline||r.config.static)&&(r.calendarContainer.classList.add(r.config.inline?"inline":"static"),r.config.inline&&(!a&&r.element.parentNode?r.element.parentNode.insertBefore(r.calendarContainer,r._input.nextSibling):void 0!==r.config.appendTo&&r.config.appendTo.appendChild(r.calendarContainer)),r.config.static)){var o=rt("div","flatpickr-wrapper");r.element.parentNode&&r.element.parentNode.insertBefore(o,r.element),o.appendChild(r.element),r.altInput&&o.appendChild(r.altInput),o.appendChild(r.calendarContainer)}r.config.static||r.config.inline||(void 0!==r.config.appendTo?r.config.appendTo:window.document.body).appendChild(r.calendarContainer)}(),function(){r.config.wrap&&["open","close","toggle","clear"].forEach((function(t){Array.prototype.forEach.call(r.element.querySelectorAll("[data-"+t+"]"),(function(e){return h(e,"click",r[t])}))}));if(r.isMobile)return void function(){var t=r.config.enableTime?r.config.noCalendar?"time":"datetime-local":"date";r.mobileInput=rt("input",r.input.className+" flatpickr-mobile"),r.mobileInput.tabIndex=1,r.mobileInput.type=t,r.mobileInput.disabled=r.input.disabled,r.mobileInput.required=r.input.required,r.mobileInput.placeholder=r.input.placeholder,r.mobileFormatStr="datetime-local"===t?"Y-m-d\\TH:i:S":"date"===t?"Y-m-d":"H:i:S",r.selectedDates.length>0&&(r.mobileInput.defaultValue=r.mobileInput.value=r.formatDate(r.selectedDates[0],r.mobileFormatStr));r.config.minDate&&(r.mobileInput.min=r.formatDate(r.config.minDate,"Y-m-d"));r.config.maxDate&&(r.mobileInput.max=r.formatDate(r.config.maxDate,"Y-m-d"));r.input.getAttribute("step")&&(r.mobileInput.step=String(r.input.getAttribute("step")));r.input.type="hidden",void 0!==r.altInput&&(r.altInput.type="hidden");try{r.input.parentNode&&r.input.parentNode.insertBefore(r.mobileInput,r.input.nextSibling)}catch(t){}h(r.mobileInput,"change",(function(t){r.setDate(ot(t).value,!1,r.mobileFormatStr),st("onChange"),st("onClose")}))}();var t=Q(R,50);r._debouncedChange=Q(f,300),r.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&h(r.daysContainer,"mouseover",(function(t){"range"===r.config.mode&&O(ot(t))}));h(r._input,"keydown",D),void 0!==r.calendarContainer&&h(r.calendarContainer,"keydown",D);r.config.inline||r.config.static||h(window,"resize",t);void 0!==window.ontouchstart?h(window.document,"touchstart",C):h(window.document,"mousedown",C);h(window.document,"focus",C,{capture:!0}),!0===r.config.clickOpens&&(h(r._input,"focus",r.open),h(r._input,"click",r.open));void 0!==r.daysContainer&&(h(r.monthNav,"click",kt),h(r.monthNav,["keyup","increment"],u),h(r.daysContainer,"click",q));if(void 0!==r.timeContainer&&void 0!==r.minuteElement&&void 0!==r.hourElement){var e=function(t){return ot(t).select()};h(r.timeContainer,["increment"],o),h(r.timeContainer,"blur",o,{capture:!0}),h(r.timeContainer,"click",d),h([r.hourElement,r.minuteElement],["focus","click"],e),void 0!==r.secondElement&&h(r.secondElement,"focus",(function(){return r.secondElement&&r.secondElement.select()})),void 0!==r.amPM&&h(r.amPM,"click",(function(t){o(t)}))}r.config.allowInput&&h(r._input,"blur",z)}(),(r.selectedDates.length||r.config.noCalendar)&&(r.config.enableTime&&l(r.config.noCalendar?r.latestSelectedDateObj:void 0),Tt(!1)),a();var n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!r.isMobile&&n&&j(),st("onReady")}(),r}function bt(t,e){for(var r=Array.prototype.slice.call(t).filter((function(t){return t instanceof HTMLElement})),n=[],i=0;it}if(null!=this.expression){const t=this.expression;return()=>this.parseExpression(t)}return null}parseExpression(t){const e=new Date;if(e.setMilliseconds(0),"now"===t.toLowerCase())return e;const r=t.match(/^\s*now\s*(-|\+)\s*(\d+)([dhms])\s*$/i);if(r){const[,t,n,i]=r;let a;switch(i.toLowerCase()){case"d":a=60*n*60*24;break;case"h":a=60*n*60;break;case"m":a=60*n;break;case"s":a=n;break;default:return null}return"-"===t&&(a=-a),c(l(e)+a)}return null}}class At{constructor(t,e){this.fromPicker=new kt(t),this.toPicker=new kt(e)}setDates(t,e){this.fromPicker.setDate(t),this.toPicker.setDate(e)}getDates(){return[this.fromPicker.getDate(),this.toPicker.getDate()]}getRawDates(){return[this.fromPicker.getRawDate(),this.toPicker.getRawDate()]}getDatesFactory(){const t=this.fromPicker.getDateFactory(),e=this.toPicker.getDateFactory();return()=>[t(),e()]}hasValidDates(){const t=this.fromPicker.getDate(),e=this.toPicker.getDate();return null!=t&&null!=e&&t<=e}}function Mt(){function t(t,e,r){e.forEach((e=>{const r=document.createElement("option");Array.isArray(e)&&2===e.length?(r.value=e[0],r.text=e[1]):(r.value=e,r.text=e),t.appendChild(r)})),t.value=r}const e=document.getElementById("range").timeRangePicker;try{e.setDates(...m())}catch{e.setDates(...m(!0))}const r=document.getElementById("refresh-interval");t(r,x,function(){try{let t=localStorage.getItem(v);if(null!=t&&(t=parseInt(t,10),_(t)))return t}catch(t){console.error(`Failed to read '${v}' from local storage!`,t)}return varnishmon.config.scraper.enabled?-1:0}()),r.addEventListener("change",(t=>{!function(t){if(_(t))try{localStorage.setItem(v,t)}catch(t){console.error(`Failed to write '${v}' to local storage!`,t)}else console.error("Invalid refresh interval value!",t)}(parseInt(t.target.value,10))}));const n=document.getElementById("filter");n.value=function(){try{let t=localStorage.getItem(b);if(null!=t)return t}catch(t){console.error(`Failed to read '${b}' from local storage!`,t)}return""}(),n.addEventListener("change",(t=>{!function(t){try{localStorage.setItem(b,t)}catch(t){console.error(`Failed to write '${b}' to local storage!`,t)}}(t.target.value)}));const i=document.getElementById("verbosity");t(i,A,function(){try{let t=localStorage.getItem(k);if(null!=t&&M(t))return t}catch(t){console.error(`Failed to read '${k}' from local storage!`,t)}return"normal"}()),i.addEventListener("change",(t=>{!function(t){if(M(t))try{localStorage.setItem(k,t)}catch(t){console.error(`Failed to write '${k}' to local storage!`,t)}else console.error("Invalid verbosity value!",t)}(t.target.value)}));const a=document.getElementById("columns");t(a,E,function(){try{let t=localStorage.getItem(S);if(null!=t&&(t=parseInt(t,10),C(t)))return t}catch(t){console.error(`Failed to read '${S}' from local storage!`,t)}return 3}()),a.addEventListener("change",(t=>{!function(t){if(C(t))try{localStorage.setItem(S,t)}catch(t){console.error(`Failed to write '${S}' to local storage!`,t)}else console.error("Invalid columns value!",t)}(parseInt(t.target.value,10))}));const o=document.getElementById("aggregator");t(o,I,function(){try{let t=localStorage.getItem(L);if(null!=t&&P(t))return t}catch(t){console.error(`Failed to read '${L}' from local storage!`,t)}return"avg"}()),o.addEventListener("change",(t=>{!function(t){if(P(t))try{localStorage.setItem(L,t)}catch(t){console.error(`Failed to write '${L}' to local storage!`,t)}else console.error("Invalid aggregator value!",t)}(t.target.value)}));const s=document.getElementById("step");s.min=varnishmon.config.scraper.period,s.value=function(){try{let t=localStorage.getItem(z);if(null!=t&&(t=parseInt(t,10),D(t)))return t}catch(t){console.error(`Failed to read '${z}' from local storage!`,t)}return varnishmon.config.scraper.period}(),s.addEventListener("change",(t=>{const e=parseInt(t.target.value,10);e>=varnishmon.config.scraper.period?function(t){if(D(t))try{localStorage.setItem(z,t)}catch(t){console.error(`Failed to write '${z}' to local storage!`,t)}else console.error("Invalid columns value!",t)}(e):(t.stopPropagation(),s.value=varnishmon.config.scraper.period,u("error",`Step must be at least ${varnishmon.config.scraper.period} seconds, which is the metrics scraping period`))}))}function St(){let t=parseInt(document.getElementById("refresh-interval").value,10);return t<0&&(t=varnishmon.config.scraper.period),t}function Et(){let t=parseInt(document.getElementById("step").value,10);return t{"Enter"===t.key&&document.getElementById("apply-time-range").click()})),document.getElementById("range-to").addEventListener("keydown",(t=>{"Enter"===t.key&&document.getElementById("apply-time-range").click()})),document.getElementById("apply-time-range").addEventListener("click",(t=>{const e=document.getElementById("range");if(!e.timeRangePicker.hasValidDates())return t.stopPropagation(),void u("error","The selected time range is invalid. ISO 8601 and relative expressions like 'now-1h', 'now', 'now-1d', etc. are allowed.");!function(t,e){y(f,t),y(p,e)}(...e.timeRangePicker.getRawDates()),e.initialRange=null,Lt()})),document.getElementById("refresh-interval").addEventListener("change",(()=>{let t=St();document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setRefreshInterval(t)}))})),document.getElementById("refresh").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((t=>{t.chart.refresh()}))})),document.getElementById("filter").addEventListener("input",s(It,500)),document.getElementById("verbosity").addEventListener("change",It),document.getElementById("columns").addEventListener("change",It),document.getElementById("filter").addEventListener("change",(t=>{const e=t.target.value;if(e){const t=T(),r=t.indexOf(e);0!==r&&(-1!==r&&t.splice(r,1),t.unshift(e),t.length>10&&t.pop(),function(t){try{localStorage.setItem(w,JSON.stringify(t))}catch(t){console.error(`Failed to write '${w}' to local storage!`,t)}}(t)),Pt()}})),document.getElementById("aggregator").addEventListener("change",(t=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setAggregator(t.target.value)}))})),document.getElementById("step").addEventListener("change",(()=>{const t=Et();document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setStep(t)}))})),document.getElementById("reset").addEventListener("click",(()=>{!function(){for(let t=localStorage.length-1;t>=0;t--)try{const e=localStorage.key(t);e.startsWith(h)&&localStorage.removeItem(e)}catch(t){console.error("Failed to remove item from local storage!",t)}}(),location.reload()})),document.getElementById("collapse-all").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".cluster").forEach((t=>{e().getInstance(t.querySelector(".accordion-collapse")).hide(),t.querySelector(".accordion-button").classList.add("collapsed")}))})),document.getElementById("expand-all").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".cluster").forEach((t=>{e().getInstance(t.querySelector(".accordion-collapse")).show(),t.querySelector(".accordion-button").classList.remove("collapsed")}))}))}async function Lt(){const t=document.getElementById("clusters");t.querySelectorAll(".chart").forEach((t=>{t.chart.destroy()})),t.innerHTML="",t.appendChild(document.getElementById("spinner-template").content.cloneNode(!0).firstElementChild);const r=document.getElementById("range").timeRangePicker.getDatesFactory(),n=St(),i=document.getElementById("aggregator").value,a=Et();let o;try{const[t,e]=r();o=await async function(t,e,r){const n=new URLSearchParams({from:l(t),to:l(e),step:r}),i=await fetch(`/storage/metrics?${n.toString()}`);if(!i.ok)throw new Error(`Unexpected API response (${i.status}): ${i.statusText}`);const a=await i.json();return{from:c(a.from),to:c(a.to),step:a.step,clusters:B(a.metrics)}}(t,e,a)}catch(e){return t.innerHTML="",t.appendChild(document.getElementById("metrics-meditation-template").content.cloneNode(!0).firstElementChild),void u("error",`Failed to fetch metrics: ${e}`)}const s=o.clusters.length;u("info",`Fetched ${o.clusters.reduce(((t,e)=>t+e.metrics.length),0)} metrics organized in ${s} clusters`);const h=document.getElementById("cluster-template"),f=document.getElementById("chart-template");t.innerHTML="",o.clusters.forEach((o=>{const s=h.content.cloneNode(!0).firstElementChild;s.querySelector(".cluster-name").textContent=o.name,t.appendChild(s);const l=new(e())(s.querySelector(".accordion-collapse"));s.querySelector(".accordion-button").addEventListener("click",(t=>{t.currentTarget.classList.toggle("collapsed"),l.toggle()}));const c=s.querySelector(".charts");o.metrics.forEach((t=>{const e=f.content.cloneNode(!0).firstElementChild,o=new W(e,t,r,n,i,a);o.addEventListener("zoom",(t=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart!==t.target&&e.chart.setZoomRange(t.range)}));const e=document.getElementById("range");null!=t.range?(null==e.initialRange&&(e.initialRange=e.timeRangePicker.getRawDates()),e.timeRangePicker.setDates(...t.range)):null!=e.initialRange&&(e.timeRangePicker.setDates(...e.initialRange),e.initialRange=null)})),e.chart=o,c.appendChild(e)}))})),It()}function It(){const t=document.getElementById("clusters");t.querySelectorAll(".chart").forEach((t=>{t.chart.redraw(document.getElementById("filter").value,document.getElementById("verbosity").value,parseInt(document.getElementById("columns").value,10))})),t.querySelectorAll(".cluster").forEach((t=>{0===t.querySelectorAll(".chart:not(.d-none)").length?t.classList.add("d-none"):t.classList.remove("d-none")}));const e=t.querySelectorAll(".cluster").length,r=t.querySelectorAll(".cluster:not(.d-none)").length,n=t.querySelectorAll(".chart").length,i=t.querySelectorAll(".chart:not(.d-none)").length;document.getElementById("filter-stats").textContent=`${i} metrics found (${n-i} hidden), organized in ${r} clusters (${e-r} hidden)`}function Pt(){const t=document.getElementById("filterHistoryList");t.innerHTML="",T().forEach((e=>{const r=document.createElement("li");r.classList.add("dropdown-item"),r.textContent=e,r.addEventListener("click",(()=>{const t=document.getElementById("filter");t.value=e,t.dispatchEvent(new Event("change")),It()})),t.appendChild(r)}))}document.addEventListener("DOMContentLoaded",(async()=>{!function(){const t=new MutationObserver(((e,r)=>{for(const r of e)"childList"===r.type&&r.addedNodes.forEach((e=>{if(e.classList&&e.classList.contains("plotly-notifier")){e.style.display="none",t.disconnect(),e.querySelectorAll(".notifier-note").forEach((t=>{u("info",t.querySelector("span").innerText)}));const r=new MutationObserver(((t,e)=>{for(const e of t)"childList"===e.type&&e.addedNodes.forEach((t=>{t.classList&&t.classList.contains("notifier-note")&&u("info",t.querySelector("span").innerText)}))}));r.observe(e,{childList:!0})}}))}));t.observe(document.body,{childList:!0})}(),document.getElementById("range").timeRangePicker=new At(document.getElementById("range-from"),document.getElementById("range-to")),Mt(),Ct(),new(i())(document.getElementById("filterHistoryList")),Pt(),Lt()}))})()})(); \ No newline at end of file +read:function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,h=r?i-1:0,f=r?-1:1,p=t[e+h];for(h+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+h],h+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+h],h+=f,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},write:function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*m}},gf=vf,yf=mf;function vf(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}vf.Varint=0,vf.Fixed64=1,vf.Bytes=2,vf.Fixed32=5;var xf=4294967296,_f=1/xf,bf=12,wf="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function Tf(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return Af(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return Af(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return Af(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function kf(t){return t.type===vf.Bytes?t.readVarint()+t.pos:t.pos+1}function Af(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Mf(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),Sf(r,n,e),Ef(n,e)}function Sf(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,t>>>=7,r.buf[r.pos]=127&t}function Ef(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)))))}function Cf(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 Lf(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Uf(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Vf(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(a=t[i+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===u?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),i+=u}return n}function qf(t,e,r){return wf.decode(t.subarray(e,r))}function Hf(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+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}vf.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Nf(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Uf(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Nf(this.buf,this.pos)+Nf(this.buf,this.pos+4)*xf;return this.pos+=8,t},readSFixed64:function(){var t=Nf(this.buf,this.pos)+Uf(this.buf,this.pos+4)*xf;return this.pos+=8,t},readFloat:function(){var t=yf.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=yf.read(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:Tf(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>=bf&&wf?qf(this.buf,e,t):Vf(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!==vf.Bytes)return t.push(this.readVarint(e));var r=kf(this);for(t=t||[];this.pos127;);else if(e===vf.Bytes)this.pos=this.readVarint()+this.pos;else if(e===vf.Fixed32)this.pos+=4;else{if(e!==vf.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?Mf(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=Hf(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Cf(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),yf.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),yf.write(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&&Cf(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,vf.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Lf,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,If,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Df,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Pf,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,zf,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Of,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Rf,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Ff,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Bf,e)},writeBytesField:function(t,e){this.writeTag(t,vf.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,vf.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,vf.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,vf.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,vf.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,vf.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,vf.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,vf.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,vf.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,vf.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Gf=r(gf);const Wf=3;function Zf(t,e,r){1===t&&r.readMessage(Yf,e)}function Yf(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:a,left:o,top:s,advance:l}=r.readMessage(Xf,{});e.push({id:t,bitmap:new Zc({width:i+2*Wf,height:a+2*Wf},n),metrics:{width:i,height:a,left:o,top:s,advance:l}})}}function Xf(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint())}function $f(t){return new Gf(t).readFields(Zf,[])}const Jf=Wf;function Kf(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,a=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,a=Math.max(a,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&&hp[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 lp;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(sp.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=op?null:++this.imageSectionID:(this.imageSectionID=ap,this.imageSectionID)}}function cp(t,e){const r=[],n=t.text;let i=0;for(const n of e)r.push(t.substring(i,n)),i=n;return i=0;let c=0;for(let r=0;r0&&n>b&&(b=n)}else{const t=n[m.fontStack],e=t&&t[y];if(e&&e.rect)w=e.rect,x=e.metrics;else{const t=r[m.fontStack],e=t&&t[y];if(!e)continue;x=e.metrics}v=(a-m.scale)*df}A?(e.verticalizable=!0,_.push({glyph:y,imageName:T,x:p,y:d+v,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:x,rect:w}),p+=k*m.scale+u):(_.push({glyph:y,imageName:T,x:p,y:d+v,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:x,rect:w}),p+=x.advance*m.scale+u)}if(0!==_.length){const t=p-u;m=Math.max(t,m),Tp(_,0,_.length-1,y,b)}p=0;const w=o*a+b;x.lineOffset=Math.max(b,l),d+=w,g=Math.max(w,g),++v}const x=d-np,{horizontalAlign:_,verticalAlign:b}=bp(s);kp(e.positionedLines,y,_,b,m,g,o,x,a.length),e.top+=-b*x,e.bottom=e.top+x,e.left+=-_*m,e.right=e.left+m}function Tp(t,e,r,n,i){if(!n&&!i)return;const a=t[r],o=a.metrics.advance*a.scale,s=(t[r].x+o)*n;for(let n=e;n<=r;n++)t[n].x-=s,t[n].y+=i}function kp(t,e,r,n,i,a,o,s,l){const c=(e-r)*i;let u=0;u=a!==o?-s*n-np:(-n*l+.5)*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=u}function Ap(t,e,r){const{horizontalAlign:n,verticalAlign:i}=bp(r),a=e[0],o=e[1],s=a-t.displaySize[0]*n,l=s+t.displaySize[0],c=o-t.displaySize[1]*i;return{image:t,top:c,bottom:c+t.displaySize[1],left:s,right:l}}function Mp(t){var e,r;let n=t.left,i=t.top,a=t.right-n,o=t.bottom-i;const s=t.image.content[2]-t.image.content[0],l=t.image.content[3]-t.image.content[1],c=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",u=null!==(r=t.image.textFitHeight)&&void 0!==r?r:"stretchOrShrink",h=s/l;if("proportional"===u){if("stretchOnly"===c&&a/oh){const t=Math.ceil(a/h);i*=t/o,o=t}return{x1:n,y1:i,x2:n+a,y2:i+o}}function Sp(t,e,r,n,i,a){const o=t.image;let s;if(o.content){const t=o.content,e=o.pixelRatio||1;s=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e]}const l=e.left*a,c=e.right*a;let u,h,f,p;"width"===r||"both"===r?(p=i[0]+l-n[3],h=i[0]+c+n[1]):(p=i[0]+(l+c-o.displaySize[0])/2,h=p+o.displaySize[0]);const d=e.top*a,m=e.bottom*a;return"height"===r||"both"===r?(u=i[1]+d-n[0],f=i[1]+m+n[2]):(u=i[1]+(d+m-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:h,bottom:f,left:p,collisionPadding:s}}const Ep=255,Cp=128,Lp=Ep*Cp;function Ip(t,e){const{expression:r}=e;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new So(t+1))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=yc([]),this.placementViewportMatrix=yc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ip(this.zoom,r["text-size"]),this.iconSizeData=Ip(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),a=n.get("symbol-z-order");this.canOverlap="never"!==Dp(n,"text-overlap","text-allow-overlap")||"never"!==Dp(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!i.isConstant();const o="viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey;this.sortFeaturesByY=o&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ai[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new jp(new Pl(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new jp(new Pl(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ss,this.lineVertexArray=new Es,this.symbolInstances=new Ms,this.textAnchorOffsets=new Ls}calculateGlyphDependencies(t,e,r,n,i){for(let a=0;a0)&&("constant"!==o.value.kind||o.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const f=r.iconDependencies,p=r.glyphDependencies,d=r.availableImages,m=new So(this.zoom);for(const{feature:r,id:s,index:l,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Ul(r,e);if(!i._featureFilter.filter(m,y,n))continue;let v,x;if(e||(y.geometry=jl(r)),c){const t=i.getValueAndResolveTokens("text-field",y,n,d),e=Oe.factory(t),r=this.hasRTLText=this.hasRTLText||Np(e);(!r||"unavailable"===Mo.getRTLTextPluginStatus()||r&&Mo.isParsed())&&(v=uf(e,i,y))}if(u){const t=i.getValueAndResolveTokens("icon-image",y,n,d);x=t instanceof Ne?t:Ne.fromString(t)}if(!v&&!x)continue;const _=this.sortFeaturesByKey?h.evaluate(y,{},n):void 0,b={id:s,text:v,icon:x,index:l,sourceLayerIndex:g,geometry:y.geometry,properties:r.properties,type:Op[r.type],sortKey:_};if(this.features.push(b),x&&(f[x.name]=!0),v){const e=o.evaluate(y,{},n).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ai.vertical)>=0;for(const t of v.sections)if(t.image)f[t.image.name]=!0;else{const n=fo(v.toString()),i=t.fontStack||e,a=p[i]=p[i]||{};this.calculateGlyphDependencies(t.text,a,r,this.allowVerticalPlacement,n)}}}"line"===a.get("symbol-placement")&&(this.features=hf(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])),a}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)}}}function qp(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}let Hp;no("SymbolBucket",Vp,{omit:["layers","collisionBoxArray","features","compareText"]}),Vp.MAX_GLYPHS=65535,Vp.addDynamicAttributes=Bp;const Gp=()=>Hp=Hp||new Uo({"symbol-placement":new Ro(bt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ro(bt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ro(bt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fo(bt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ro(bt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ro(bt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ro(bt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ro(bt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ro(bt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ro(bt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fo(bt.layout_symbol["icon-size"]),"icon-text-fit":new Ro(bt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ro(bt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fo(bt.layout_symbol["icon-image"]),"icon-rotate":new Fo(bt.layout_symbol["icon-rotate"]),"icon-padding":new Fo(bt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ro(bt.layout_symbol["icon-keep-upright"]),"icon-offset":new Fo(bt.layout_symbol["icon-offset"]),"icon-anchor":new Fo(bt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ro(bt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ro(bt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ro(bt.layout_symbol["text-rotation-alignment"]),"text-field":new Fo(bt.layout_symbol["text-field"]),"text-font":new Fo(bt.layout_symbol["text-font"]),"text-size":new Fo(bt.layout_symbol["text-size"]),"text-max-width":new Fo(bt.layout_symbol["text-max-width"]),"text-line-height":new Ro(bt.layout_symbol["text-line-height"]),"text-letter-spacing":new Fo(bt.layout_symbol["text-letter-spacing"]),"text-justify":new Fo(bt.layout_symbol["text-justify"]),"text-radial-offset":new Fo(bt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ro(bt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Fo(bt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Fo(bt.layout_symbol["text-anchor"]),"text-max-angle":new Ro(bt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ro(bt.layout_symbol["text-writing-mode"]),"text-rotate":new Fo(bt.layout_symbol["text-rotate"]),"text-padding":new Ro(bt.layout_symbol["text-padding"]),"text-keep-upright":new Ro(bt.layout_symbol["text-keep-upright"]),"text-transform":new Fo(bt.layout_symbol["text-transform"]),"text-offset":new Fo(bt.layout_symbol["text-offset"]),"text-allow-overlap":new Ro(bt.layout_symbol["text-allow-overlap"]),"text-overlap":new Ro(bt.layout_symbol["text-overlap"]),"text-ignore-placement":new Ro(bt.layout_symbol["text-ignore-placement"]),"text-optional":new Ro(bt.layout_symbol["text-optional"])});let Wp;const Zp=()=>Wp=Wp||new Uo({"icon-opacity":new Fo(bt.paint_symbol["icon-opacity"]),"icon-color":new Fo(bt.paint_symbol["icon-color"]),"icon-halo-color":new Fo(bt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fo(bt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fo(bt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ro(bt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ro(bt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fo(bt.paint_symbol["text-opacity"]),"text-color":new Fo(bt.paint_symbol["text-color"],{runtimeType:Gt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fo(bt.paint_symbol["text-halo-color"]),"text-halo-width":new Fo(bt.paint_symbol["text-halo-width"]),"text-halo-blur":new Fo(bt.paint_symbol["text-halo-blur"]),"text-translate":new Ro(bt.paint_symbol["text-translate"]),"text-translate-anchor":new Ro(bt.paint_symbol["text-translate-anchor"])});var Yp={get paint(){return Zp()},get layout(){return Gp()}};class Xp{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:Ut,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}no("FormatSectionOverride",Xp,{omit:["defaultValue"]});class $p extends qo{constructor(t){super(t,Yp)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["icon-rotation-alignment"]="map":this.layout._values["icon-rotation-alignment"]="viewport"),"auto"===this.layout.get("text-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="map":this.layout._values["text-rotation-alignment"]="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),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Bi(a.value)||!i?i:qp(e.properties,i)}createBucket(t){return new Vp(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Yp.paint.overridableProperties){if(!$p.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Xp(e),n=new Fi(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ji("source",n):new Ui("composite",n,e.value.zoomStops),this.paint._values[t]=new Do(e.property,i,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&$p.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Yp.paint.properties[e];let i=!1;const a=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 Oe)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{if(!i)if(e instanceof He&&Ve(e.value)===$t){const t=e.value;a(t.sections)}else e instanceof Gr?a(e.sections):e.eachChild(t)},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return i}}function Jp(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),a=i&&i.values;return[a[0]*n,a[1]*n,a[2]*n,a[3]*n]}let Kp;const Qp=()=>Kp=Kp||new Uo({"background-color":new Ro(bt.paint_background["background-color"]),"background-pattern":new No(bt.paint_background["background-pattern"]),"background-opacity":new Ro(bt.paint_background["background-opacity"])});var td={get paint(){return Qp()}};class ed extends qo{constructor(t){super(t,td)}}let rd;const nd=()=>rd=rd||new Uo({"raster-opacity":new Ro(bt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ro(bt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ro(bt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ro(bt.paint_raster["raster-brightness-max"]),"raster-saturation":new Ro(bt.paint_raster["raster-saturation"]),"raster-contrast":new Ro(bt.paint_raster["raster-contrast"]),"raster-resampling":new Ro(bt.paint_raster["raster-resampling"]),"raster-fade-duration":new Ro(bt.paint_raster["raster-fade-duration"])});var id={get paint(){return nd()}};class ad extends qo{constructor(t){super(t,id)}}function od(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e}class sd extends qo{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 ld(t){if("custom"===t.type)return new sd(t);switch(t.type){case"background":return new ed(t);case"circle":return new Fc(t);case"fill":return new Wu(t);case"fill-extrusion":return new Ah(t);case"heatmap":return new $c(t);case"hillshade":return new tu(t);case"line":return new ef(t);case"raster":return new ad(t);case"symbol":return new $p(t)}}class cd{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 ud{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new cd((()=>this.process())),this.subscription=$(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=R(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 a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:lo(t.data,a)});this.target.postMessage(o,{transfer:a})}))}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(R(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(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(co(r.error)):e.resolve(co(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=co(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i)}catch(e){this.completeTask(t,e)}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?lo(e):null,data:lo(r,n)};this.target.postMessage(i,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}}const hd=6371008.8;class fd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new fd(v(this.lng,-180,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 hd*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof fd)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new fd(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new fd(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 pd=2*Math.PI*hd;function dd(t){return pd*Math.cos(t*Math.PI/180)}function md(t){return(180+t)/360}function gd(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function yd(t,e){return t/dd(e)}function vd(t){return 360*t-180}function xd(t){const e=180-360*t;return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function _d(t,e){return t*dd(xd(e))}function bd(t){return 1/Math.cos(t*Math.PI/180)}class wd{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=fd.convert(t);return new wd(md(r.lng),gd(r.lat),yd(e,r.lat))}toLngLat(){return new fd(vd(this.x),xd(this.y))}toAltitude(){return _d(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/pd*bd(xd(this.y))}}function Td(t,e,r){var n=kd(256*t,256*(e=Math.pow(2,r)-e-1),r),i=kd(256*(t+1),256*(e+1),r);return n[0]+","+n[1]+","+i[0]+","+i[1]}function kd(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Ad{constructor(t,e,r){if(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))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=Ed(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=Td(this.x,this.y,this.z),i=Cd(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===r?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,i).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 a((t.x*e-this.x)*Rl,(t.y*e-this.y)*Rl)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Md{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Ed(t,e.z,e.z,e.x,e.y)}}class Sd{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Ad(r,+n,+i),this.key=Ed(e,t,r,n,i)}clone(){return new Sd(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 Sd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Sd(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?Ed(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ed(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 Sd(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 Sd(e,this.wrap,e,r,n),new Sd(e,this.wrap,e,r+1,n),new Sd(e,this.wrap,e,r,n+1),new Sd(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y0;a--)n=1<this.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 Yc({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,a=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:a=o-1;break;case 1:o=a+1}const s=-e*this.dim,l=-r*this.dim;for(let e=a;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 Pd{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 zd{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new eo(Rl,16,0),this.grid3D=new eo(Rl,16,0),this.featureIndexArray=new Ps,this.promoteId=e}insert(t,e,r,n,i,a){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const s=a?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&s.insert(o,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ku.VectorTile(new Gf(this.rawTileData)).layers,this.sourceLayerCoder=new Id(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},a=Rl/t.tileSize/t.scale,o=Ji(i.filter),s=t.queryGeometry,l=t.queryPadding*a,c=Od(s),u=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),h=Od(t.cameraQueryGeometry),f=this.grid3D.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l,((e,r,n,i)=>ec(t.cameraQueryGeometry,e-l,r-l,n+l,i+l)));for(const t of f)u.push(t);u.sort(Rd);const p={};let d;for(let l=0;l(f||(f=jl(e)),r.queryIntersectsFeature(s,e,n,f,this.z,t.transform,a,t.pixelPosMatrix))))}return p}loadMatchingFeature(t,e,r,n,i,a,o,s,l,c,u){const h=this.bucketLayerIDs[e];if(a&&!L(a,h))return;const f=this.sourceLayerCoder.decode(r),p=this.vtLayers[f].feature(n);if(i.needGeometry){const t=Ul(p,!0);if(!i.filter(new So(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new So(this.tileID.overscaledZ),p))return;const d=this.getId(p,f);for(let e=0;e{const o=e instanceof Oo?e.get(a):null;return o&&o.evaluate?o.evaluate(r,n,i):o}))}function Od(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);return{minX:e,minY:r,maxX:n,maxY:i}}function Rd(t,e){return e-t}function Fd(t,e,r,n,i){const o=[];for(let s=0;s=n&&u.x>=n||(s.x>=n?s=new a(n,s.y+(u.y-s.y)*((n-s.x)/(u.x-s.x)))._round():u.x>=n&&(u=new a(n,s.y+(u.y-s.y)*((n-s.x)/(u.x-s.x)))._round()),s.y>=i&&u.y>=i||(s.y>=i?s=new a(s.x+(u.x-s.x)*((i-s.y)/(u.y-s.y)),i)._round():u.y>=i&&(u=new a(s.x+(u.x-s.x)*((i-s.y)/(u.y-s.y)),i)._round()),c&&s.equals(c[c.length-1])||(c=[s],o.push(c)),c.push(u)))))}}return o}no("FeatureIndex",zd,{omit:["rawTileData","sourceLayerCoder"]});class Bd extends a{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new Bd(this.x,this.y,this.angle,this.segment)}}function Nd(t,e,r,n,i){if(void 0===e.segment||0===r)return!0;let a=e,o=e.segment+1,s=0;for(;s>-r/2;){if(o--,o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;const l=[];let c=0;for(;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=r.dist(a)}return!0}function jd(t){let e=0;for(let r=0;rc){const u=(c-l)/a,h=xr.number(n.x,i.x,u),f=xr.number(n.y,i.y,u),p=new Bd(h,f,i.angleTo(n),r);return p._round(),!o||Nd(t,p,s,o,e)?p:void 0}l+=a}}function Hd(t,e,r,n,i,a,o,s,l){const c=Ud(n,a,o),u=Vd(n,i),h=u*o,f=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&y=0&&v=0&&f+c<=u){const r=new Bd(y,v,m,e);r._round(),n&&!Nd(t,r,a,n,i)||p.push(r)}}h+=d}return s||p.length||o||(p=Gd(t,h/2,r,n,i,a,o,!0,l)),p}no("Anchor",Bd);const Wd=Qf;function Zd(t,e,r,n){const i=[],o=t.image,s=o.pixelRatio,l=o.paddedRect.w-2*Wd,c=o.paddedRect.h-2*Wd;let u={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=o.stretchX||[[0,l]],f=o.stretchY||[[0,c]],p=(t,e)=>t+e[1]-e[0],d=h.reduce(p,0),m=f.reduce(p,0),g=l-d,y=c-m;let v=0,x=d,_=0,b=m,w=0,T=g,k=0,A=y;if(o.content&&n){const e=o.content,r=e[2]-e[0],n=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(u=Mp(t)),v=Yd(h,0,e[0]),_=Yd(f,0,e[1]),x=Yd(h,e[0],e[2]),b=Yd(f,e[1],e[3]),w=e[0]-v,k=e[1]-_,T=r-x,A=n-b}const M=u.x1,S=u.y1,E=u.x2-M,C=u.y2-S,L=(t,n,i,l)=>{const c=$d(t.stretch-v,x,E,M),u=Jd(t.fixed-w,T,t.stretch,d),h=$d(n.stretch-_,b,C,S),f=Jd(n.fixed-k,A,n.stretch,m),p=$d(i.stretch-v,x,E,M),g=Jd(i.fixed-w,T,i.stretch,d),y=$d(l.stretch-_,b,C,S),L=Jd(l.fixed-k,A,l.stretch,m),I=new a(c,h),P=new a(p,h),z=new a(p,y),D=new a(c,y),O=new a(u/s,f/s),R=new a(g/s,L/s),F=e*Math.PI/180;if(F){const t=Math.sin(F),e=Math.cos(F),r=[e,-t,t,e];I._matMult(r),P._matMult(r),D._matMult(r),z._matMult(r)}const B=t.stretch+t.fixed,N=i.stretch+i.fixed,j=n.stretch+n.fixed,U=l.stretch+l.fixed;return{tl:I,tr:P,bl:D,br:z,tex:{x:o.paddedRect.x+Wd+B,y:o.paddedRect.y+Wd+j,w:N-B,h:U-j},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:O,pixelOffsetBR:R,minFontScaleX:T/s/E,minFontScaleY:A/s/C,isSDF:r}};if(n&&(o.stretchX||o.stretchY)){const t=Xd(h,g,d),e=Xd(f,y,m);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=o.image)||void 0===h?void 0:h.content)&&(o.image.textFitWidth||o.image.textFitHeight)?Mp(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};c.y1=c.y1*s-l[0],c.y2=c.y2*s+l[2],c.x1=c.x1*s-l[3],c.x2=c.x2*s+l[1];const f=o.collisionPadding;if(f&&(c.x1-=f[0]*s,c.y1-=f[1]*s,c.x2+=f[2]*s,c.y2+=f[3]*s),u){const t=new a(c.x1,c.y1),e=new a(c.x2,c.y1),r=new a(c.x1,c.y2),n=new a(c.x2,c.y2),i=u*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),c.x1=Math.min(t.x,e.x,r.x,n.x),c.x2=Math.max(t.x,e.x,r.x,n.x),c.y1=Math.min(t.y,e.y,r.y,n.y),c.y2=Math.max(t.y,e.y,r.y,n.y)}t.emplaceBack(e.x,e.y,c.x1,c.y1,c.x2,c.y2,r,n,i)}this.boxEndIndex=t.length}}class tm{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,a=e[i];if(r(n,a)>=0)break;e[t]=a,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 em(t,e=1,r=!1){let n=1/0,i=1/0,o=-1/0,s=-1/0;const l=t[0];for(let t=0;to)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const c=o-n,u=s-i,h=Math.min(c,u);let f=h/2;const p=new tm([],rm);if(0===h)return new a(n,i);for(let e=n;ed.d||!d.d)&&(d=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,m)),n.max-d.d<=e||(f=n.h/2,p.push(new nm(n.p.x-f,n.p.y-f,f,t)),p.push(new nm(n.p.x+f,n.p.y-f,f,t)),p.push(new nm(n.p.x-f,n.p.y+f,f,t)),p.push(new nm(n.p.x+f,n.p.y+f,f,t)),m+=4)}return r&&(console.log(`num probes: ${m}`),console.log(`best distance: ${d.d}`)),d.p}function rm(t,e){return e.max-t.max}function nm(t,e,r,n){this.p=new a(t,e),this.h=r,this.d=im(this.p,n),this.max=this.d+this.h*Math.SQRT2}function im(t,e){let r=!1,n=1/0;for(let i=0;it.y!=s.y>t.y&&t.x<(s.x-i.x)*(t.y-i.y)/(s.y-i.y)+i.x&&(r=!r),n=Math.min(n,Kl(t,i,s))}}return(r?1:-1)*Math.sqrt(n)}function am(t){let e=0,r=0,n=0;const i=t[0];for(let t=0,a=i.length,o=a-1;tt*df));n.startsWith("top")?i[1]-=sm:n.startsWith("bottom")&&(i[1]+=sm),e[r+1]=i}return new Be(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)*df,lm]:i.get("text-offset").evaluate(e,{},r).map((t=>t*df));const a=[];for(const t of o)a.push(t,cm(t,n));return new Be(a)}return null}function hm(e){e.bucket.createArrays();const r=512*e.bucket.overscaling;e.bucket.tilePixelRatio=Rl/r,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const n=e.bucket.layers[0],i=n.layout,a=n._unevaluatedLayout._values,o={layoutIconSize:a["icon-size"].possiblyEvaluate(new So(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new So(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new So(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.textSizeData;o.compositeTextSizes=[a["text-size"].possiblyEvaluate(new So(t),e.canonical),a["text-size"].possiblyEvaluate(new So(r),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.iconSizeData;o.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new So(t),e.canonical),a["icon-size"].possiblyEvaluate(new So(r),e.canonical)]}const s=i.get("text-line-height")*df,l="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement"),c=i.get("text-keep-upright"),u=i.get("text-size");for(const r of e.bucket.features){const a=i.get("text-font").evaluate(r,{},e.canonical).join(","),h=u.evaluate(r,{},e.canonical),f=o.layoutTextSize.evaluate(r,{},e.canonical),p=o.layoutIconSize.evaluate(r,{},e.canonical),d={horizontal:{},vertical:void 0},m=r.text;let g,y=[0,0];if(m){const o=m.toString(),u=i.get("text-letter-spacing").evaluate(r,{},e.canonical)*df,p=po(o)?u:0,g=i.get("text-anchor").evaluate(r,{},e.canonical),v=um(n,r,e.canonical);if(!v){const t=i.get("text-radial-offset").evaluate(r,{},e.canonical);y=t?cm(g,[t*df,lm]):i.get("text-offset").evaluate(r,{},e.canonical).map((t=>t*df))}let x=l?"center":i.get("text-justify").evaluate(r,{},e.canonical);const _="point"===i.get("symbol-placement")?i.get("text-max-width").evaluate(r,{},e.canonical)*df:1/0,b=()=>{e.bucket.allowVerticalPlacement&&fo(o)&&(d.vertical=up(m,e.glyphMap,e.glyphPositions,e.imagePositions,a,_,s,g,"left",p,y,t.ai.vertical,!0,f,h))};if(!l&&v){const r=new Set;if("auto"===x)for(let t=0;t{h.x<0||h.x>=Rl||h.y<0||h.y>=Rl||ym(t,h,s,r,n,i,C,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,[b,b,b,b],k,l,x,w,A,p,e,a,c,u,o)};if("line"===M)for(const i of Fd(e.geometry,0,0,Rl,Rl)){const e=Hd(i,_,T,r.vertical||d,n,m,v,t.overscaling,Rl);for(const r of e)d&&vm(t,d.text,S,r)||L(i,r)}else if("line-center"===M){for(const t of e.geometry)if(t.length>1){const e=qd(t,T,r.vertical||d,n,m,v);e&&L(t,e)}}else if("Polygon"===e.type)for(const t of Cn(e.geometry,0)){const e=em(t,16);L(t[0],new Bd(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)L(t,new Bd(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)L([e],new Bd(e.x,e.y,0))}function dm(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;rLp&&P(`${t.layerIds[0]}: Value for "text-size" is >= ${Ep}. Reduce your "text-size".`)):"composite"===g.kind&&(y=[Cp*p.compositeTextSizes[0].evaluate(o,{},d),Cp*p.compositeTextSizes[1].evaluate(o,{},d)],(y[0]>Lp||y[1]>Lp)&&P(`${t.layerIds[0]}: Value for "text-size" is >= ${Ep}. Reduce your "text-size".`)),t.addSymbols(t.text,m,y,s,a,o,c,e,l.lineStartIndex,l.lineLength,f,d);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function gm(t){for(const e in t)return t[e];return null}function ym(e,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x,_,b,w,T,k,A){const M=e.addToLineVertexArray(r,n);let S,E,C,L,I=0,z=0,D=0,O=0,R=-1,F=-1;const B={};let N=hl("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},k)+90,e=i.vertical;C=new Qd(c,r,u,h,f,e,p,d,m,t),s&&(L=new Qd(c,r,u,h,f,s,y,v,m,t))}if(a){const n=l.layout.get("icon-rotate").evaluate(b,{}),i="none"!==l.layout.get("icon-text-fit"),o=Zd(a,n,T,i),p=s?Zd(s,n,T,i):void 0;E=new Qd(c,r,u,h,f,a,y,v,!1,n),I=4*o.length;const d=e.iconSizeData;let m=null;"source"===d.kind?(m=[Cp*l.layout.get("icon-size").evaluate(b,{})],m[0]>Lp&&P(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ep}. Reduce your "icon-size".`)):"composite"===d.kind&&(m=[Cp*w.compositeIconSizes[0].evaluate(b,{},k),Cp*w.compositeIconSizes[1].evaluate(b,{},k)],(m[0]>Lp||m[1]>Lp)&&P(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ep}. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,m,_,x,b,t.ai.none,r,M.lineStartIndex,M.lineLength,-1,k),R=e.icon.placedSymbolArray.length-1,p&&(z=4*p.length,e.addSymbols(e.icon,p,m,_,x,b,t.ai.vertical,r,M.lineStartIndex,M.lineLength,-1,k),F=e.icon.placedSymbolArray.length-1)}const j=Object.keys(i.horizontal);for(const n of j){const a=i.horizontal[n];if(!S){N=hl(a.text);const t=l.layout.get("text-rotate").evaluate(b,{},k);S=new Qd(c,r,u,h,f,a,p,d,m,t)}const s=1===a.positionedLines.length;if(D+=mm(e,r,a,o,l,m,b,g,M,i.vertical?t.ai.horizontal:t.ai.horizontalOnly,s?j:[n],B,R,w,k),s)break}i.vertical&&(O+=mm(e,r,i.vertical,o,l,m,b,g,M,t.ai.vertical,["vertical"],B,F,w,k));const U=S?S.boxStartIndex:e.collisionBoxArray.length,V=S?S.boxEndIndex:e.collisionBoxArray.length,q=C?C.boxStartIndex:e.collisionBoxArray.length,H=C?C.boxEndIndex:e.collisionBoxArray.length,G=E?E.boxStartIndex:e.collisionBoxArray.length,W=E?E.boxEndIndex:e.collisionBoxArray.length,Z=L?L.boxStartIndex:e.collisionBoxArray.length,Y=L?L.boxEndIndex:e.collisionBoxArray.length;let X=-1;const $=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=$(S,X),X=$(C,X),X=$(E,X),X=$(L,X);const J=X>-1?1:0;J&&(X*=A/df),e.glyphOffsetArray.length>=Vp.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const K=um(l,b,k),[Q,tt]=dm(e.textAnchorOffsets,K);e.symbolInstances.emplaceBack(r.x,r.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,R,F,N,U,V,q,H,G,W,Z,Y,u,D,O,I,z,J,0,p,X,Q,tt)}function vm(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])>4;if(n!==_m)throw new Error(`Got v${n} data when expected v${_m}.`);const i=xm[15&r];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new wm(o,a,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=xm.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,s=(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,bm,t),this.coords=new this.ArrayType(this.data,bm+o+s,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(bm+a+o+s),this.ids=new this.IndexArrayType(this.data,bm,t),this.coords=new this.ArrayType(this.data,bm+o+s,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(_m<<4)+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 Tm(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:a,nodeSize:o}=this,s=[0,i.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let o=h;o<=u;o++){const s=a[2*o],c=a[2*o+1];s>=t&&s<=r&&c>=e&&c<=n&&l.push(i[o])}continue}const f=h+u>>1,p=a[2*f],d=a[2*f+1];p>=t&&p<=r&&d>=e&&d<=n&&l.push(i[f]),(0===c?t<=p:e<=d)&&(s.push(h),s.push(f-1),s.push(1-c)),(0===c?r>=p:n>=d)&&(s.push(f+1),s.push(u),s.push(1-c))}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:a}=this,o=[0,n.length-1,0],s=[],l=r*r;for(;o.length;){const c=o.pop()||0,u=o.pop()||0,h=o.pop()||0;if(u-h<=a){for(let r=h;r<=u;r++)Sm(i[2*r],i[2*r+1],t,e)<=l&&s.push(n[r]);continue}const f=h+u>>1,p=i[2*f],d=i[2*f+1];Sm(p,d,t,e)<=l&&s.push(n[f]),(0===c?t-r<=p:e-r<=d)&&(o.push(h),o.push(f-1),o.push(1-c)),(0===c?t+r>=p:e+r>=d)&&(o.push(f+1),o.push(u),o.push(1-c))}return s}}function Tm(t,e,r,n,i,a){if(i-n<=r)return;const o=n+i>>1;km(t,e,o,n,i,a),Tm(t,e,r,n,o-1,1-a),Tm(t,e,r,o+1,i,1-a)}function km(t,e,r,n,i,a){for(;i>n;){if(i-n>600){const o=i-n+1,s=r-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);km(t,e,r,Math.max(n,Math.floor(r-s*c/o+u)),Math.min(i,Math.floor(r+(o-s)*c/o+u)),a)}const o=e[2*r+a];let s=n,l=i;for(Am(t,e,n,r),e[2*i+a]>o&&Am(t,e,n,i);so;)l--}e[2*n+a]===o?Am(t,e,n,l):(l++,Am(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function Am(t,e,r,n){Mm(t,r,n),Mm(e,2*r,2*n),Mm(e,2*r+1,2*n+1)}function Mm(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function Sm(t,e,r,n){const i=t-r,a=e-n;return i*i+a*a}var Em;t.bf=void 0,(Em=t.bf||(t.bf={})).create="create",Em.load="load",Em.fullLoad="fullLoad";let Cm=null,Lm=[];const Im=1e3/60,Pm="loadTime",zm="fullLoadTime",Dm={mark(t){performance.mark(t)},frame(t){const e=t;if(null!=Cm){const t=e-Cm;Lm.push(t)}Cm=e},clearMetrics(){Cm=null,Lm=[],performance.clearMeasures(Pm),performance.clearMeasures(zm);for(const e in t.bf)performance.clearMarks(t.bf[e])},getPerformanceMetrics(){performance.measure(Pm,t.bf.create,t.bf.load),performance.measure(zm,t.bf.create,t.bf.fullLoad);const e=performance.getEntriesByName(Pm)[0].duration,r=performance.getEntriesByName(zm)[0].duration,n=Lm.length,i=1/(Lm.reduce(((t,e)=>t+e),0)/n/1e3),a=Lm.filter((t=>t>Im)).reduce(((t,e)=>t+(e-Im)/Im),0);return{loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:a/(n+a)*100,totalFrames:n}}};class Om{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}}t.$=Os,t.A=pc,t.B=$a,t.C=N,t.D=Ro,t.E=_t,t.F=ud,t.G=at,t.H=dc,t.I=tp,t.J=_c,t.K=bc,t.L=xc,t.M=b,t.N=fd,t.O=md,t.P=a,t.Q=gd,t.R=Yc,t.S=Sd,t.T=Lo,t.U=h,t.V=f,t.W=G,t.X=Rl,t.Y=Xo,t.Z=wd,t._=e,t.a=et,t.a$=Lc,t.a0=rl,t.a1=Ad,t.a2=Ft,t.a3=mt,t.a4=T,t.a5=ws,t.a6=Vp,t.a7=Ji,t.a8=Ul,t.a9=So,t.aA=kt,t.aB=ld,t.aC=C,t.aD=Rt,t.aE=od,t.aF=E,t.aG=M,t.aH=S,t.aI=yl,t.aJ=vl,t.aK=kl,t.aL=bl,t.aM=wl,t.aN=Pe,t.aO=_l,t.aP=xl,t.aQ=Ec,t.aR=Ic,t.aS=Ws,t.aT=lf,t.aU=Ys,t.aV=A,t.aW=Xc,t.aX=zs,t.aY=Xs,t.aZ=Js,t.a_=Cc,t.aa=Pd,t.ab=F,t.ac=x,t.ad=y,t.ae=Tc,t.af=mc,t.ag=Oc,t.ah=zp,t.aj=Pp,t.ak=Bp,t.al=D,t.am=Fd,t.an=Hl,t.ao=yc,t.ap=p,t.aq=df,t.as=Dp,t.at=vc,t.au=fm,t.av=bp,t.aw=wm,t.ax=ca,t.ay=uo,t.az=st,t.b=j,t.b0=gc,t.b1=Rc,t.b2=Dc,t.b3=v,t.b4=Md,t.b5=yd,t.b6=Mc,t.b7=wc,t.b8=m,t.b9=g,t.bA=Q,t.bB=Ni,t.bC=Mo,t.ba=J,t.bb=kc,t.bc=Ds,t.bd=hd,t.be=Dm,t.bg=ot,t.bh=nt,t.bi=it,t.bj=la,t.bk=no,t.bl=Id,t.bm=zd,t.bn=ep,t.bo=hm,t.bp=Zh,t.bq=ju,t.br=xh,t.bs=Ku,t.bt=Gf,t.bu=Om,t.bv=X,t.bw=Ld,t.bx=r,t.by=n,t.bz=gf,t.c=tt,t.d=U,t.e=_,t.f=q,t.g=rt,t.h=ft,t.i=R,t.j=xt,t.k=vt,t.l=pt,t.m=ht,t.n=$f,t.o=Zc,t.p=Kf,t.q=Uo,t.r=Xa,t.s=dt,t.t=Qa,t.u=ho,t.v=bt,t.w=P,t.x=Ya,t.y=O,t.z=xr})),r("worker",["./shared"],(function(t){class e{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const r of e){this._layerConfigs[r.id]=r;const e=this._layers[r.id]=t.aB(r);e._featureFilter=t.a7(e.filter),this.keyCache[r.id]&&delete this.keyCache[r.id]}for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=t.bj(Object.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._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 a=r.sourceLayer||"_geojsonTileLayer";let o=i[a];o||(o=i[a]=[]),o.push(e)}}}const r=1;class n{constructor(e){const n={},i=[];for(const t in e){const a=e[t],o=n[t]={};for(const t in a){const e=a[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(n),o[t]={rect:n,metrics:e.metrics}}}const{w:a,h:o}=t.p(i),s=new t.o({width:a||1,height:o||1});for(const i in e){const a=e[i];for(const e in a){const o=a[+e];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const l=n[i][e].rect;t.o.copy(o.bitmap,s,{x:0,y:0},{x:l.x+r,y:l.y+r},o.bitmap)}}this.image=s,this.positions=n}}t.bk("GlyphAtlas",n);class i{constructor(e){this.tileID=new t.S(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,r,i,o){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.a5;const s=new t.bl(Object.keys(e.layers).sort()),l=new t.bm(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:i},h=r.familiesBySource[this.source];for(const r in h){const n=e.layers[r];if(!n)continue;1===n.version&&t.w(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=s.encode(r),f=[];for(let t=0;t=r.maxzoom||"none"!==r.visibility&&(a(e,this.zoom,i),(c[r.id]=r.createBucket({index:l.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(f,u,this.tileID.canonical),l.bucketLayerIDs.push(e.map((t=>t.id))))}}const f=t.aG(u.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(f).length){const t=new AbortController;this.inFlightDependencies.push(t),p=o.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const d=Object.keys(u.iconDependencies);let m=Promise.resolve({});if(d.length){const t=new AbortController;this.inFlightDependencies.push(t),m=o.sendAsync({type:"GI",data:{icons:d,source:this.source,tileID:this.tileID,type:"icons"}},t)}const g=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(g.length){const t=new AbortController;this.inFlightDependencies.push(t),y=o.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[v,x,_]=yield Promise.all([p,m,y]),b=new n(v),w=new t.bn(x,_);for(const e in c){const r=c[e];r instanceof t.a6?(a(r.layers,this.zoom,i),t.bo({bucket:r,glyphMap:v,glyphPositions:b.positions,imageMap:x,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):r.hasPattern&&(r instanceof t.bp||r instanceof t.bq||r instanceof t.br)&&(a(r.layers,this.zoom,i),r.addFeatures(u,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(c).filter((t=>!t.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?v:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function a(e,r,n){const i=new t.a9(r);for(const t of e)t.recalculate(i,n)}class o{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 n=yield t.l(e.request,r);try{return{vectorTile:new t.bs.VectorTile(new t.bt(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires}}catch(t){const r=new Uint8Array(n.data),i=31===r[0]&&139===r[1];let a=`Unable to parse the tile at ${e.request.url}, `;throw a+=i?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.message}`,new Error(a)}}))}loadTile(e){return t._(this,void 0,void 0,(function*(){const r=e.uid,n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bu(e.request),a=new i(e);this.loading[r]=a;const o=new AbortController;a.abort=o;try{const i=yield this.loadVectorTile(e,o);if(delete this.loading[r],!i)return null;const s=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}a.vectorTile=i.vectorTile;const u=a.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[r]=a,this.fetching[r]={rawTileData:s,cacheControl:l,resourceTiming:c};try{const e=yield u;return t.e({rawTileData:s.slice(0)},e,l,c)}finally{delete this.fetching[r]}}catch(t){throw delete this.loading[r],a.status="done",this.loaded[r]=a,t}}))}reloadTile(e){return t._(this,void 0,void 0,(function*(){const r=e.uid;if(!this.loaded||!this.loaded[r])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[r];if(n.showCollisionBoxes=e.showCollisionBoxes,"parsing"===n.status){const e=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor);let i;if(this.fetching[r]){const{rawTileData:n,cacheControl:a,resourceTiming:o}=this.fetching[r];delete this.fetching[r],i=t.e({rawTileData:n.slice(0)},e,a,o)}else i=e;return i}if("done"===n.status&&n.vectorTile)return n.parse(n.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 s{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:r,encoding:n,rawImageData:i,redFactor:a,greenFactor:o,blueFactor:s,baseShift:l}=e,c=i.width+2,u=i.height+2,h=t.b(i)?new t.R({width:c,height:u},yield t.bv(i,-1,-1,c,u)):i,f=new t.bw(r,h,n,a,o,s,l);return this.loaded=this.loaded||{},this.loaded[r]=f,f}))}removeTile(t){const e=this.loaded,r=t.uid;e&&e[r]&&delete e[r]}}var l=c;function c(t,e){var r,n=t&&t.type;if("FeatureCollection"===n)for(r=0;r=Math.abs(s)?r-l+s:s-l+r,r=l}r+n>=0!=!!e&&t.reverse()}var f=t.bx(l);const p=t.bs.VectorTileFeature.prototype.toGeoJSON;let d=class{constructor(e){this._feature=e,this.extent=t.X,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const r of this._feature.geometry)e.push([new t.P(r[0],r[1])]);return e}{const e=[];for(const r of this._feature.geometry){const n=[];for(const e of r)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,r){return p.call(this,t,e,r)}},m=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.X,this.length=e.length,this._features=e}feature(t){return new d(this._features[t])}};var g={exports:{}},y=t.by,v=t.bs.VectorTileFeature,x=_;function _(t,e){this.options=e||{},this.features=t,this.length=t.length}function b(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}_.prototype.feature=function(t){return new b(this.features[t],this.options.extent)},b.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e>31}function P(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,a=0,o=r.length,s=0;st},F=Math.fround||(B=new Float32Array(1),t=>(B[0]=+t,B[0]));var B;const N=2,j=3,U=4,V=5,q=6;class H{constructor(t){this.options=Object.assign(Object.create(R),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 a=[];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 a=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,a],e),o=this.getClusters([-180,n,i,a],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],s=o.range(Z(r),Y(a),Z(i),Y(n)),l=o.data,c=[];for(const t of s){const e=this.stride*t;c.push(l[e+V]>1?G(l,e,this.clusterProps):this.points[l[e+j]])}return c}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 a=i.data;if(e*this.stride>=a.length)throw new Error(n);const o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),s=a[e*this.stride],l=a[e*this.stride+1],c=i.within(s,l,o),u=[];for(const e of c){const r=e*this.stride;a[r+U]===t&&u.push(a[r+V]>1?G(a,r,this.clusterProps):this.points[a[r+j]])}if(0===u.length)throw new Error(n);return u}getLeaves(t,e,r){e=e||10,r=r||0;const n=[];return this._appendLeaves(n,t,e,r,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],i=Math.pow(2,t),{extent:a,radius:o}=this.options,s=o/a,l=(r-s)/i,c=(r+1+s)/i,u={features:[]};return this._addTileFeatures(n.range((e-s)/i,l,(e+1+s)/i,c),n.data,e,r,i,u),0===e&&this._addTileFeatures(n.range(1-s/i,l,1,c),n.data,i,r,i,u),e===i-1&&this._addTileFeatures(n.range(0,l,s/i,c),n.data,-1,r,i,u),u.features.length?u: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 a=this.getChildren(e);for(const e of a){const a=e.properties;if(a&&a.cluster?i+a.point_count<=n?i+=a.point_count:i=this._appendLeaves(t,a.cluster_id,r,n,i):i1;let l,c,u;if(s)l=W(e,t,this.clusterProps),c=e[t],u=e[t+1];else{const r=this.points[e[t+j]];l=r.properties;const[n,i]=r.geometry.coordinates;c=Z(n),u=Y(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*i-r)),Math.round(this.options.extent*(u*i-n))]],tags:l};let f;f=s||this.options.generateId?e[t+j]:this.points[e[t+j]].id,void 0!==f&&(h.id=f),a.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:a}=this.options,o=r/(n*Math.pow(2,e)),s=t.data,l=[],c=this.stride;for(let r=0;re&&(p+=s[r+V])}if(p>f&&p>=a){let t,a=n*f,o=u*f,d=-1;const m=(r/c<<5)+(e+1)+this.points.length;for(const n of h){const l=n*c;if(s[l+N]<=e)continue;s[l+N]=e;const u=s[l+V];a+=s[l]*u,o+=s[l+1]*u,s[l+U]=m,i&&(t||(t=this._map(s,r,!0),d=this.clusterProps.length,this.clusterProps.push(t)),i(t,this._map(s,l)))}s[r+U]=m,l.push(a/p,o/p,1/0,m,-1,p),i&&l.push(d)}else{for(let t=0;t1)for(const t of h){const r=t*c;if(!(s[r+N]<=e)){s[r+N]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+V]>1){const n=this.clusterProps[t[e+q]];return r?Object.assign({},n):n}const n=this.points[t[e+j]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function G(t,e,r){return{type:"Feature",id:t[e+j],properties:W(t,e,r),geometry:{type:"Point",coordinates:[X(t[e]),$(t[e+1])]}}}function W(t,e,r){const n=t[e+V],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,a=t[e+q],o=-1===a?{}:Object.assign({},r[a]);return Object.assign(o,{cluster:!0,cluster_id:t[e+j],point_count:n,point_count_abbreviated:i})}function Z(t){return t/360+.5}function Y(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 X(t){return 360*(t-.5)}function $(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function J(t,e,r,n){let i=n;const a=e+(r-e>>1);let o,s=r-e;const l=t[e],c=t[e+1],u=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-a);tn&&(o-e>3&&J(t,e,o,n),t[o+2]=i,r-o>3&&J(t,o,r,n))}function K(t,e,r,n,i,a){let o=i-r,s=a-n;if(0!==o||0!==s){const l=((t-r)*o+(e-n)*s)/(o*o+s*s);l>1?(r=i,n=a):l>0&&(r+=o*l,n+=s*l)}return o=t-r,s=e-n,o*o+s*s}function Q(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)tt(i,r);else if("Polygon"===e)tt(i,r[0]);else if("MultiLineString"===e)for(const t of r)tt(i,t);else if("MultiPolygon"===e)for(const t of r)tt(i,t[0]);return i}function tt(t,e){for(let r=0;r0&&(o+=n?(i*l-s*a)/2:Math.sqrt(Math.pow(s-i,2)+Math.pow(l-a,2))),i=s,a=l}const s=e.length-3;e[2]=1,J(e,0,s,r),e[s+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function at(t,e,r,n){for(let i=0;i1?1:r}function lt(t,e,r,n,i,a,o,s){if(n/=e,a>=(r/=e)&&o=n)return null;const l=[];for(const e of t){const t=e.geometry;let a=e.type;const o=0===i?e.minX:e.minY,c=0===i?e.maxX:e.maxY;if(o>=r&&c=n)continue;let u=[];if("Point"===a||"MultiPoint"===a)ct(t,u,r,n,i);else if("LineString"===a)ut(t,u,r,n,i,!1,s.lineMetrics);else if("MultiLineString"===a)ft(t,u,r,n,i,!1);else if("Polygon"===a)ft(t,u,r,n,i,!0);else if("MultiPolygon"===a)for(const e of t){const t=[];ft(e,t,r,n,i,!0),t.length&&u.push(t)}if(u.length){if(s.lineMetrics&&"LineString"===a){for(const t of u)l.push(Q(e.id,a,t,e.tags));continue}"LineString"!==a&&"MultiLineString"!==a||(1===u.length?(a="LineString",u=u[0]):a="MultiLineString"),"Point"!==a&&"MultiPoint"!==a||(a=3===u.length?"Point":"MultiPoint"),l.push(Q(e.id,a,u,e.tags))}}return l.length?l:null}function ct(t,e,r,n,i){for(let a=0;a=r&&o<=n&&pt(e,t[a],t[a+1],t[a+2])}}function ut(t,e,r,n,i,a,o){let s=ht(t);const l=0===i?dt:mt;let c,u,h=t.start;for(let f=0;fr&&(u=l(s,p,d,g,y,r),o&&(s.start=h+c*u)):v>n?x=r&&(u=l(s,p,d,g,y,r),_=!0),x>n&&v<=n&&(u=l(s,p,d,g,y,n),_=!0),!a&&_&&(o&&(s.end=h+c*u),e.push(s),s=ht(t)),o&&(h+=c)}let f=t.length-3;const p=t[f],d=t[f+1],m=t[f+2],g=0===i?p:d;g>=r&&g<=n&&pt(s,p,d,m),f=s.length-3,a&&f>=3&&(s[f]!==s[0]||s[f+1]!==s[1])&&pt(s,s[0],s[1],s[2]),s.length&&e.push(s)}function ht(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function ft(t,e,r,n,i,a){for(const o of t)ut(o,e,r,n,i,a,!1)}function pt(t,e,r,n){t.push(e,r,n)}function dt(t,e,r,n,i,a){const o=(a-e)/(n-e);return pt(t,a,r+(i-r)*o,1),o}function mt(t,e,r,n,i,a){const o=(a-r)/(i-r);return pt(t,e+(n-e)*o,a,1),o}function gt(t,e){const r=e.buffer/e.extent;let n=t;const i=lt(t,1,-1-r,r,0,-1,2,e),a=lt(t,1,1-r,2+r,0,-1,2,e);return(i||a)&&(n=lt(t,1,-r,1+r,0,-1,2,e)||[],i&&(n=yt(i,1).concat(n)),a&&(n=n.concat(yt(a,-1)))),n}function yt(t,e){const r=[];for(let n=0;n0&&e.size<(i?o:n))return void(r.numPoints+=e.length/3);const s=[];for(let t=0;to)&&(r.numSimplified++,s.push(e[t],e[t+1])),r.numPoints++;i&&kt(s,a),t.push(s)}function kt(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=et(t,e);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),n=gt(n,e),n.length&&this.splitTile(n,0,0,0),r&&(n.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,r,n,i,a,o){const s=[t,e,r,n],l=this.options,c=l.debug;for(;s.length;){n=s.pop(),r=s.pop(),e=s.pop(),t=s.pop();const u=1<1&&console.time("creation"),f=this.tiles[h]=bt(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==i){if(e===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(r!==a>>t||n!==o>>t)continue}}if(f.source=null,0===t.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,d=.5-p,m=.5+p,g=1+p;let y=null,v=null,x=null,_=null,b=lt(t,u,r-p,r+m,0,f.minX,f.maxX,l),w=lt(t,u,r+d,r+g,0,f.minX,f.maxX,l);t=null,b&&(y=lt(b,u,n-p,n+m,1,f.minY,f.maxY,l),v=lt(b,u,n+d,n+g,1,f.minY,f.maxY,l),b=null),w&&(x=lt(w,u,n-p,n+m,1,f.minY,f.maxY,l),_=lt(w,u,n+d,n+g,1,f.minY,f.maxY,l),w=null),c>1&&console.timeEnd("clipping"),s.push(y||[],e+1,2*r,2*n),s.push(v||[],e+1,2*r,2*n+1),s.push(x||[],e+1,2*r+1,2*n),s.push(_||[],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:a}=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,c=t,u=e,h=r;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[St(c,u,h)];return l&&l.source?(a>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?xt(this.tiles[s],i):null):null}}function St(t,e,r){return 32*((1<0||(null===(i=r.addOrUpdateProperties)||void 0===i?void 0:i.length)>0);if((s||l)&&(e=Object.assign({},e),t.set(r.id,e),l&&(e.properties=Object.assign({},e.properties))),r.newGeometry&&(e.geometry=r.newGeometry),r.removeAllProperties)e.properties={};else if((null===(a=r.removeProperties)||void 0===a?void 0:a.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}}class Dt extends o{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(e,r){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const r=this._geoJSONIndex.getTile(t.z,t.x,t.y);if(!r)return null;const n=new m(r.features);let i=O(n);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:n,rawData:i.buffer}}))}loadData(e){return t._(this,void 0,void 0,(function*(){var r;null===(r=this._pendingRequest)||void 0===r||r.abort();const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bu(e.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest),this._geoJSONIndex=e.cluster?new H(Ot(e)).load((yield this._pendingData).features):Ct(yield this._pendingData,e.geojsonVtOptions),this.loaded={};const t={};if(n){const r=n.finish();r&&(t.resourceTiming={},t.resourceTiming[e.source]=JSON.parse(JSON.stringify(r)))}return t}catch(e){if(delete this._pendingRequest,t.bA(e))return{abandoned:!0};throw e}}))}getData(){return t._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded,r=t.uid;return e&&e[r]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,r){return t._(this,void 0,void 0,(function*(){let n=yield this.loadGeoJSON(e,r);if(delete this._pendingRequest,"object"!=typeof n)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(f(n,!0),e.filter){const r=t.bB(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 i=n.features.filter((t=>r.value.evaluate({zoom:0},t)));n={type:"FeatureCollection",features:i}}return n}))}loadGeoJSON(e,r){return t._(this,void 0,void 0,(function*(){const{promoteId:n}=e;if(e.request){const i=yield t.h(e.request,r);return this._dataUpdateable=It(i.data,n)?Pt(i.data,n):void 0,i.data}if("string"==typeof e.data)try{const t=JSON.parse(e.data);return this._dataUpdateable=It(t,n)?Pt(t,n):void 0,t}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 zt(this._dataUpdateable,e.dataDiff,n),{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)}}function Ot({superclusterOptions:e,clusterProperties:r}){if(!r||!e)return e;const n={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(r);for(const e of s){const[a,o]=r[e],s=t.bB(o),l=t.bB("string"==typeof a?[a,["accumulated"],["get",e]]:a);n[e]=s.value,i[e]=l.value}return e.map=t=>{o.properties=t;const e={};for(const t of s)e[t]=n[t].evaluate(a,o);return e},e.reduce=(t,e)=>{o.properties=e;for(const e of s)a.accumulated=t[e],t[e]=i[e].evaluate(a,o)},e}class Rt{constructor(e){this.self=e,this.actor=new t.F(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=t.bh,this.self.removeProtocol=t.bi,this.self.registerRTLTextPlugin=e=>{if(t.bC.isParsed())throw new Error("RTL text plugin already registered.");t.bC.setMethods(e)},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(t.bC.isParsed())return t.bC.getState();if("loading"!==r.pluginStatus)return t.bC.setState(r),r;const e=r.pluginURL;if(this.self.importScripts(e),t.bC.isParsed()){const r={pluginStatus:"loaded",pluginURL:e};return t.bC.setState(r),r}throw t.bC.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let r=this.layerIndexes[t];return r||(r=this.layerIndexes[t]=new e),r}_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 o(n,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][r]=new Dt(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 s),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new Rt(self)),Rt})),r("index",["exports","./shared"],(function(t,e){var r={name:"maplibre-gl",description:"BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",version:"4.5.2",main:"dist/maplibre-gl.js",style:"dist/maplibre-gl.css",license:"BSD-3-Clause",homepage:"https://maplibre.org/",funding:"https://github.com/maplibre/maplibre-gl-js?sponsor=1",bugs:{url:"https://github.com/maplibre/maplibre-gl-js/issues/"},repository:{type:"git",url:"git://github.com/maplibre/maplibre-gl-js.git"},types:"dist/maplibre-gl.d.ts",type:"module",dependencies:{"@mapbox/geojson-rewind":"^0.5.2","@mapbox/jsonlint-lines-primitives":"^2.0.2","@mapbox/point-geometry":"^0.1.0","@mapbox/tiny-sdf":"^2.0.6","@mapbox/unitbezier":"^0.0.1","@mapbox/vector-tile":"^1.3.1","@mapbox/whoots-js":"^3.1.0","@maplibre/maplibre-gl-style-spec":"^20.3.0","@types/geojson":"^7946.0.14","@types/geojson-vt":"3.2.5","@types/mapbox__point-geometry":"^0.1.4","@types/mapbox__vector-tile":"^1.3.4","@types/pbf":"^3.0.5","@types/supercluster":"^7.1.3",earcut:"^3.0.0","geojson-vt":"^4.0.2","gl-matrix":"^3.4.3","global-prefix":"^3.0.0",kdbush:"^4.0.2","murmurhash-js":"^1.0.0",pbf:"^3.3.0",potpack:"^2.0.0",quickselect:"^3.0.0",supercluster:"^8.0.1",tinyqueue:"^3.0.0","vt-pbf":"^3.1.3"},devDependencies:{autoprefixer:"^10.4.20","@mapbox/mapbox-gl-rtl-text":"^0.3.0","@mapbox/mvt-fixtures":"^3.10.0","@rollup/plugin-commonjs":"^26.0.1","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.7","@rollup/plugin-strip":"^3.0.4","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","@types/benchmark":"^2.1.5","@types/cssnano":"^5.0.0","@types/d3":"^7.4.3","@types/diff":"^5.2.1","@types/earcut":"^2.1.4","@types/eslint":"^8.56.7","@types/gl":"^6.0.5","@types/glob":"^8.1.0","@types/jest":"^29.5.12","@types/jsdom":"^21.1.7","@types/minimist":"^1.2.5","@types/murmurhash-js":"^1.0.6","@types/nise":"^1.4.5","@types/node":"^22.1.0","@types/offscreencanvas":"^2019.7.3","@types/pixelmatch":"^5.2.6","@types/pngjs":"^6.0.5","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/request":"^2.48.12","@types/shuffle-seed":"^1.1.3","@types/window-or-global":"^1.0.6","@typescript-eslint/eslint-plugin":"^7.18.0","@typescript-eslint/parser":"^7.18.0",address:"^2.0.3",benchmark:"^2.1.4",canvas:"^2.11.2",cssnano:"^7.0.4",d3:"^7.9.0","d3-queue":"^3.0.7","devtools-protocol":"^0.0.1339468",diff:"^5.2.0","dts-bundle-generator":"^9.5.1",eslint:"^8.57.0","eslint-config-mourner":"^3.0.0","eslint-plugin-html":"^8.1.1","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^28.8.0","eslint-plugin-react":"^7.35.0","eslint-plugin-tsdoc":"0.3.0",expect:"^29.7.0",glob:"^11.0.0","is-builtin-module":"^4.0.0",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0","jest-junit":"^16.0.0","jest-monocart-coverage":"^1.1.1","jest-webgl-canvas-mock":"^2.5.3",jsdom:"^24.1.1","junit-report-builder":"^5.0.0",minimist:"^1.2.8","mock-geolocation":"^1.0.11","monocart-coverage-reports":"^2.10.2",nise:"^6.0.0","npm-font-open-sans":"^1.1.0","npm-run-all":"^4.1.5","pdf-merger-js":"^5.1.2",pixelmatch:"^6.0.0",pngjs:"^7.0.0",postcss:"^8.4.41","postcss-cli":"^11.0.0","postcss-inline-svg":"^6.0.0","pretty-bytes":"^6.1.1",puppeteer:"^23.0.2",react:"^18.3.1","react-dom":"^18.3.1",rollup:"^4.20.0","rollup-plugin-sourcemaps":"^0.6.3",rw:"^1.3.3",semver:"^7.6.3","shuffle-seed":"^1.1.6","source-map-explorer":"^2.5.3",st:"^3.0.0",stylelint:"^16.8.1","stylelint-config-standard":"^36.0.1","ts-jest":"^29.2.4","ts-node":"^10.9.2",tslib:"^2.6.3",typedoc:"^0.26.5","typedoc-plugin-markdown":"^4.2.3","typedoc-plugin-missing-exports":"^3.0.0",typescript:"^5.5.4"},overrides:{"postcss-inline-svg":{"css-select":"^5.1.0","dom-serializer":"^2.0.0",htmlparser2:"^8.0.1","postcss-value-parser":"^4.2.0"}},scripts:{"generate-dist-package":"node --no-warnings --loader ts-node/esm build/generate-dist-package.js","generate-shaders":"node --no-warnings --loader ts-node/esm build/generate-shaders.ts","generate-struct-arrays":"node --no-warnings --loader ts-node/esm build/generate-struct-arrays.ts","generate-style-code":"node --no-warnings --loader ts-node/esm build/generate-style-code.ts","generate-typings":"dts-bundle-generator --export-referenced-types --umd-module-name=maplibregl -o ./dist/maplibre-gl.d.ts ./src/index.ts","generate-docs":"typedoc && node --no-warnings --loader ts-node/esm build/generate-docs.ts","generate-images":"node --no-warnings --loader ts-node/esm build/generate-doc-images.ts","build-dist":"npm run build-css && npm run generate-typings && npm run build-dev && npm run build-csp-dev && npm run build-prod && npm run build-prod-unminified && npm run build-csp","build-dev":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev","watch-dev":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch","build-prod":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production,MINIFY:true","build-prod-unminified":"rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production","build-csp":"rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:production,MINIFY:true","build-csp-dev":"rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev","build-css":"postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css","watch-css":"postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css","build-benchmarks":"npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts","watch-benchmarks":"rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch","start-server":"st --no-cache -H 0.0.0.0 --port 9966 .","start-docs":"docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",start:"run-p watch-css watch-dev start-server","start-bench":"run-p watch-css watch-benchmarks start-server",lint:"eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .","lint-css":"stylelint **/*.css --fix -f verbose",test:"run-p lint lint-css test-render jest",jest:"jest","test-build":"jest --selectProjects=build --reporters=default","test-build-ci":"jest --selectProjects=build","test-integration":"jest --selectProjects=integration --reporters=default","test-integration-ci":"jest --coverage --selectProjects=integration","test-render":"node --no-warnings --loader ts-node/esm test/integration/render/run_render_tests.ts","test-unit":"jest --selectProjects=unit --reporters=default","test-unit-ci":"jest --coverage --selectProjects unit","test-watch-roots":"jest --watch",codegen:"run-p --print-label generate-dist-package generate-style-code generate-struct-arrays generate-shaders && npm run generate-typings",benchmark:"node --no-warnings --loader ts-node/esm test/bench/run-benchmarks.ts","gl-stats":"node --no-warnings --loader ts-node/esm test/bench/gl-stats.ts",prepare:"npm run codegen",typecheck:"tsc --noEmit && tsc --project tsconfig.dist.json",tsnode:"node --experimental-loader=ts-node/esm --no-warnings"},files:["build/","dist/*","src/"],engines:{npm:">=8.1.0",node:">=16.14.0"}};let n,i;const a={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:t=>new Promise(((r,n)=>{const i=requestAnimationFrame(r);t.signal.addEventListener("abort",(()=>{cancelAnimationFrame(i),n(e.c())}))})),getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0,t.width,t.height),r},resolveURL:t=>(n||(n=document.createElement("a")),n.href=t,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==i&&(i=matchMedia("(prefers-reduced-motion: reduce)")),i.matches)}};class o{static testProp(t){if(!o.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",o.suppressClickInternal,!0)}),0)}static getScale(t){const e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,r,n){const i=r.boundingClientRect;return new e.P((n.clientX-i.left)/r.x-t.clientLeft,(n.clientY-i.top)/r.y-t.clientTop)}static mousePos(t,e){const r=o.getScale(t);return o.getPoint(t,r,e)}static touchPos(t,e){const r=[],n=o.getScale(t);for(let i=0;i{l&&p(l),l=null,h=!0},c.onerror=()=>{u=!0,l=null},c.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let r,n,i,a;t.resetRequestQueue=()=>{r=[],n=0,i=0,a={}},t.addThrottleControl=t=>{const e=i++;return a[e]=t,e},t.removeThrottleControl=t=>{delete a[t],u()};const o=()=>{for(const t of Object.keys(a))if(a[t]())return!0;return!1};t.getImage=(t,n,i=!0)=>new Promise(((a,o)=>{s.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"});const l={abortController:n,requestParameters:t,supportImageRefresh:i,state:"queued",onError:t=>{o(t)},onSuccess:t=>{a(t)}};r.push(l),u()}));const l=t=>"function"==typeof createImageBitmap?e.d(t):e.f(t),c=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:r,supportImageRefresh:i,onError:a,onSuccess:o,abortController:s}=t,c=!1===i&&!e.i(self)&&!e.g(r.url)&&(!r.headers||Object.keys(r.headers).reduce(((t,e)=>t&&"accept"===e),!0));n++;const f=c?h(r,s):e.m(r,s);try{const r=yield f;delete t.abortController,t.state="completed",r.data instanceof HTMLImageElement||e.b(r.data)?o(r):r.data&&o({data:yield l(r.data),cacheControl:r.cacheControl,expires:r.expires})}catch(e){delete t.abortController,a(e)}finally{n--,u()}})),u=()=>{const t=o()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=n;e0;e++){const t=r.shift();t.abortController.signal.aborted?e--:c(t)}},h=(t,r)=>new Promise(((n,i)=>{const a=new Image,o=t.url,s=t.credentials;s&&"include"===s?a.crossOrigin="use-credentials":(s&&"same-origin"===s||!e.s(o))&&(a.crossOrigin="anonymous"),r.signal.addEventListener("abort",(()=>{a.src="",i(e.c())})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,n({data:a})},a.onerror=()=>{a.onerror=a.onload=null,r.signal.aborted||i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},a.src=o}))}(d||(d={})),d.resetRequestQueue();class m{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function g(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function y(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*s,t[1]=i*l+o*s,t[2]=n*-s+a*l,t[3]=i*-s+o*l,t}function v(){var t=new e.A(9);return e.A!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function x(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function _(){var t=new e.A(3);return e.A!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function b(t){var r=new e.A(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r}function w(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function T(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function k(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function A(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function M(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function S(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}function E(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}var C=T;function L(){var t=new e.A(2);return e.A!=Float32Array&&(t[0]=0,t[1]=0),t}function I(t){var e=t[0],r=t[1];return e*e+r*r}function P(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t}_();var z=I;function D(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const r=[];for(const{id:n,url:i}of t){const t=`${n}${i}`;-1===r.indexOf(t)&&(r.push(t),e.push({id:n,url:i}))}}return e}function O(t,e,r){const n=t.split("?");return n[0]+=`${e}${r}`,n.join("?")}function R(t,r,n,i){return e._(this,void 0,void 0,(function*(){const a=D(t),o=n>1?"@2x":"",s={},l={};for(const{id:t,url:n}of a){const a=r.transformRequest(O(n,o,".json"),"SpriteJSON");s[t]=e.h(a,i);const c=r.transformRequest(O(n,o,".png"),"SpriteImage");l[t]=d.getImage(c,i)}return yield Promise.all([...Object.values(s),...Object.values(l)]),F(s,l)}))}function F(t,r){return e._(this,void 0,void 0,(function*(){const e={};for(const n in t){e[n]={};const i=a.getImageCanvasContext((yield r[n]).data),o=(yield t[n]).data;for(const t in o){const{width:r,height:a,x:s,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:f,content:p,textFitWidth:d,textFitHeight:m}=o[t],g={width:r,height:a,x:s,y:l,context:i};e[n][t]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:f,content:p,textFitWidth:d,textFitHeight:m,spriteData:g}}}return e}))}L();class B{constructor(t,e,r,n){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,r,n){const{width:i,height:a}=t,o=!(this.size&&this.size[0]===i&&this.size[1]===a||n),{context:s}=this,{gl:l}=s;if(this.useMipmap=Boolean(r&&r.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!r||!1!==r.premultiply)),o)this.size=[i,a],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,i,a,0,this.format,l.UNSIGNED_BYTE,t.data);else{const{x:r,y:o}=n||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,r,o,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,r,o,i,a,l.RGBA,l.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D)}bind(t,e,r){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),r!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(r=i.LINEAR),t!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,r||t),this.filter=t),e!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function N(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}const j=1;class U extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const r=this.images[t];if(r&&!r.data&&r.spriteData){const t=r.spriteData;r.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),r.spriteData=null}return r}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,r){let n=!0;const i=r.data||r.spriteData;return this._validateStretch(r.stretchX,i&&i.width)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(r.stretchY,i&&i.height)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(r.content,r)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(t,e){if(!t)return!0;let r=0;for(const n of t){if(n[0]{let n=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(n=!1);this.isLoaded()||n?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){const r={};for(const n of t){let t=this.getImage(n);t||(this.fire(new e.k("styleimagemissing",{id:n})),t=this.getImage(n)),t?r[n]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${n}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return r}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const r=this.patterns[t],n=this.getImage(t);if(!n)return null;if(r&&r.position.version===n.version)return r.position;if(r)r.position.version=n.version;else{const r={w:n.data.width+2*j,h:n.data.height+2*j,x:0,y:0},i=new e.I(r,n);this.patterns[t]={bin:r,position:i}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new B(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:r,h:n}=e.p(t),i=this.atlasImage;i.resize({width:r||1,height:n||1});for(const t in this.patterns){const{bin:r}=this.patterns[t],n=r.x+j,a=r.y+j,o=this.getImage(t).data,s=o.width,l=o.height;e.R.copy(o,i,{x:0,y:0},{x:n,y:a},{width:s,height:l}),e.R.copy(o,i,{x:0,y:l-1},{x:n,y:a-1},{width:s,height:1}),e.R.copy(o,i,{x:0,y:0},{x:n,y:a+l},{width:s,height:1}),e.R.copy(o,i,{x:s-1,y:0},{x:n-1,y:a},{width:1,height:l}),e.R.copy(o,i,{x:0,y:0},{x:n+s,y:a},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const r of t){if(this.callbackDispatchedThisFrame[r])continue;this.callbackDispatchedThisFrame[r]=!0;const t=this.getImage(r);t||e.w(`Image with ID: "${r}" was not found`),N(t)&&this.updateImage(r,t)}}}function V(t,r,n,i){return e._(this,void 0,void 0,(function*(){const a=256*r,o=a+255,s=i.transformRequest(n.replace("{fontstack}",t).replace("{range}",`${a}-${o}`),"Glyphs"),l=yield e.l(s,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${r}, ${a}-${o}`);const c={};for(const t of e.n(l.data))c[t.id]=t;return c}))}const q=1e20;class H{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:a="normal",fontStyle:o="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const s=this.size=t+4*e,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${a} ${t}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(t),o=Math.ceil(r),s=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),c=Math.min(this.size-this.buffer,o+Math.ceil(n)),u=l+2*this.buffer,h=c+2*this.buffer,f=Math.max(u*h,0),p=new Uint8ClampedArray(f),d={data:p,width:u,height:h,glyphWidth:l,glyphHeight:c,glyphTop:o,glyphLeft:s,glyphAdvance:e};if(0===l||0===c)return d;const{ctx:m,buffer:g,gridInner:y,gridOuter:v}=this;m.clearRect(g,g,l,c),m.fillText(t,g,g+o);const x=m.getImageData(g,g,l,c);v.fill(q,0,f),y.fill(0,0,f);for(let t=0;t0?t*t:0,y[n]=t<0?t*t:0}}G(v,0,0,u,h,u,this.f,this.v,this.z),G(y,g,g,l,c,u,this.f,this.v,this.z);for(let t=0;t-1);l++,a[l]=s,o[l]=c,o[l+1]=q}for(let s=0,l=0;s65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[i])return{stack:t,id:r,glyph:n};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[i]){const r=Z.loadGlyphRange(t,i,this.url,this.requestManager);e.requests[i]=r}const a=yield e.requests[i];for(const t in a)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=a[+t]);return e.ranges[i]=!0,{stack:t,id:r,glyph:a[r]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(e.u["CJK Unified Ideographs"](t)||e.u["Hangul Syllables"](t)||e.u.Hiragana(t)||e.u.Katakana(t))}_tinySDF(t,r,n){const i=this.localIdeographFontFamily;if(!i)return;if(!this._doesCharSupportLocalGlyph(n))return;const a=2;let o=t.tinySDF;if(!o){let e="400";/bold/i.test(r)?e="900":/medium/i.test(r)?e="500":/light/i.test(r)&&(e="200"),o=t.tinySDF=new Z.TinySDF({fontSize:24*a,buffer:3*a,radius:8*a,cutoff:.25,fontFamily:i,fontWeight:e})}const s=o.draw(String.fromCharCode(n)),l=27.5,c=.5;return{id:n,bitmap:new e.o({width:s.width||30*a,height:s.height||30*a},s.data),metrics:{width:s.glyphWidth/a||24,height:s.glyphHeight/a||24,left:s.glyphLeft/a+c||0,top:s.glyphTop/a-l||-8,advance:s.glyphAdvance/a||24,isDoubleResolution:!0}}}}Z.loadGlyphRange=V,Z.TinySDF=H;class Y{constructor(){this.specification=e.v.light.position}possiblyEvaluate(t,r){return e.y(t.expression.evaluate(r))}interpolate(t,r,n){return{x:e.z.number(t.x,r.x,n),y:e.z.number(t.y,r.y,n),z:e.z.number(t.z,r.z,n)}}}const X="-transition";let $;class J extends e.E{constructor(t){super(),$=$||new e.q({anchor:new e.D(e.v.light.anchor),position:new Y,color:new e.D(e.v.light.color),intensity:new e.D(e.v.light.intensity)}),this._transitionable=new e.T($),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,r={}){if(!this._validate(e.r,t,r))for(const e in t){const r=t[e];e.endsWith(X)?this._transitionable.setTransition(e.slice(0,-X.length),r):this._transitionable.setValue(e,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,r,n){return(!n||!1!==n.validate)&&e.t(this,t.call(e.x,{value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.v}))}}const K=new e.q({"sky-color":new e.D(e.v.sky["sky-color"]),"horizon-color":new e.D(e.v.sky["horizon-color"]),"fog-color":new e.D(e.v.sky["fog-color"]),"fog-ground-blend":new e.D(e.v.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.v.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.v.sky["atmosphere-blend"])}),Q="-transition";class tt extends e.E{constructor(t){super(),this._transitionable=new e.T(K),this.setSky(t),this._transitioning=this._transitionable.untransitioned()}setSky(t,r={}){if(!this._validate(e.B,t,r))for(const e in t){const r=t[e];e.endsWith(Q)?this._transitionable.setTransition(e.slice(0,-Q.length),r):this._transitionable.setValue(e,r)}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,r,n={}){return!1!==(null==n?void 0:n.validate)&&e.t(this,t.call(e.x,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.v})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class et{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const r=t.join(",")+String(e);return this.dashEntry[r]||(this.dashEntry[r]=this.addDash(t,e)),this.dashEntry[r]}getDashRanges(t,e,r){const n=[];let i=t.length%2==1?-t[t.length-1]*r:0,a=t[0]*r,o=!0;n.push({left:i,right:a,isDash:o,zeroLength:0===t[0]});let s=t[0];for(let e=1;e1&&(s=t[++o]);const l=Math.abs(i-s.left),c=Math.abs(i-s.right),u=Math.min(l,c);let h;const f=e/r*(n+1);if(s.isDash){const t=n-Math.abs(f);h=Math.sqrt(u*u+t*t)}else h=n-Math.sqrt(u*u+f*f);this.data[a+i]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1))}const e=t[0],r=t[t.length-1];e.isDash===r.isDash&&(e.left=r.left-this.width,r.right=e.right+this.width);const n=this.width*this.nextRow;let i=0,a=t[i];for(let e=0;e1&&(a=t[++i]);const r=Math.abs(e-a.left),o=Math.abs(e-a.right),s=Math.min(r,o),l=a.isDash?s:-s;this.data[n+e]=Math.max(0,Math.min(255,l+128))}}addDash(t,r){const n=r?7:0,i=2*n+1;if(this.nextRow+i>this.height)return e.w("LineAtlas out of space"),null;let a=0;for(let e=0;e{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[nt]}numActive(){return Object.keys(this.active).length}}const at=Math.floor(a.hardwareConcurrency/2);let ot,st;function lt(){return ot||(ot=new it),ot}function ct(){lt().acquire(nt)}function ut(){const t=ot;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(nt),ot=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))}it.workerCount=e.C(globalThis)?Math.max(Math.min(at,3),1):1;class ht{constructor(t,r){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=r;const n=this.workerPool.acquire(r);for(let t=0;t{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const r of this.actors)r.registerMessageHandler(t,e)}}function ft(){return st||(st=new ht(lt(),e.G),st.registerMessageHandler("GR",((t,r,n)=>e.m(r,n)))),st}function pt(t,r){const n=e.H();return e.J(n,n,[1,1,0]),e.K(n,n,[.5*t.width,.5*t.height,1]),e.L(n,n,t.calculatePosMatrix(r.toUnwrapped()))}function dt(t,e,r){if(t)for(const n of t){const t=e[n];if(t&&t.source===r&&"fill-extrusion"===t.type)return!0}else for(const t in e){const n=e[t];if(n.source===r&&"fill-extrusion"===n.type)return!0}return!1}function mt(t,e,r,n,i,a){const o=dt(i&&i.layers,e,t.id),s=a.maxPitchScaleFactor(),l=t.tilesIn(n,s,o);l.sort(vt);const c=[];for(const n of l)c.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(e,r,t._state,n.queryGeometry,n.cameraQueryGeometry,n.scale,i,a,s,pt(t.transform,n.tileID))});const u=xt(c);for(const e in u)u[e].forEach((e=>{const r=e.feature,n=t.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=n}));return u}function gt(t,e,r,n,i,a,o){const s={},l=a.queryRenderedSymbols(n),c=[];for(const t of Object.keys(l).map(Number))c.push(o[t]);c.sort(vt);for(const r of c){const n=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],e,r.bucketIndex,r.sourceLayerIndex,i.filter,i.layers,i.availableImages,t);for(const t in n){const e=s[t]=s[t]||[],i=n[t];i.sort(((t,e)=>{const n=r.featureSortOrder;if(n){const r=n.indexOf(t.featureIndex);return n.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const t of i)e.push(t)}}for(const e in s)s[e].forEach((n=>{const i=n.feature,a=t[e],o=r[a.source].getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o}));return s}function yt(t,e){const r=t.getRenderableIds().map((e=>t.getTileByID(e))),n=[],i={};for(let t=0;tt.id))),o}))}class bt{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}extend(t){const r=this._sw,n=this._ne;let i,a;if(t instanceof e.N)i=t,a=t;else{if(!(t instanceof bt)){if(Array.isArray(t)){if(4===t.length||t.every(Array.isArray)){const e=t;return this.extend(bt.convert(e))}{const r=t;return this.extend(e.N.convert(r))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.N.convert(t)):this}if(i=t._sw,a=t._ne,!i||!a)return this}return r||n?(r.lng=Math.min(i.lng,r.lng),r.lat=Math.min(i.lat,r.lat),n.lng=Math.max(a.lng,n.lng),n.lat=Math.max(a.lat,n.lat)):(this._sw=new e.N(i.lng,i.lat),this._ne=new e.N(a.lng,a.lat)),this}getCenter(){return new e.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new e.N(this.getWest(),this.getNorth())}getSouthEast(){return new e.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:r,lat:n}=e.N.convert(t),i=this._sw.lat<=n&&n<=this._ne.lat;let a=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=r&&r>=this._ne.lng),i&&a}static convert(t){return t instanceof bt?t:t?new bt(t):t}static fromLngLat(t,r=0){const n=360*r/40075017,i=n/Math.cos(Math.PI/180*t.lat);return new bt(new e.N(t.lng-i,t.lat-n),new e.N(t.lng+i,t.lat+n))}}class wt{constructor(t,e,r){this.bounds=bt.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),n={minX:Math.floor(e.O(this.bounds.getWest())*r),minY:Math.floor(e.Q(this.bounds.getNorth())*r),maxX:Math.ceil(e.O(this.bounds.getEast())*r),maxY:Math.ceil(e.Q(this.bounds.getSouth())*r)};return t.x>=n.minX&&t.x=n.minY&&t.y{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};r.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,r)=>{t.reloadPromise={resolve:e,reject:r}}))}else t.actor=this.dispatcher.getActor(),n="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:n,data:r},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class kt extends e.E{constructor(t,r,n,i){super(),this.id=t,this.dispatcher=n,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},r),e.e(this,e.M(r,["url","scheme","tileSize"]))}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield _t(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(e.e(this,t),t.bounds&&(this.tileBounds=new wt(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new e.j(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const r=yield d.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(r&&r.data){this.map._refreshExpiredTiles&&r.cacheControl&&r.expires&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const e=this.map.painter.context,n=e.gl,i=r.data;t.texture=this.map.painter.getTileTexture(i.width),t.texture?t.texture.update(i,{useMipmap:!0}):(t.texture=new B(e,i,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class At extends kt{constructor(t,r,n,i){super(t,r,n,i),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox",this.redFactor=r.redFactor,this.greenFactor=r.greenFactor,this.blueFactor=r.blueFactor,this.baseShift=r.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const r=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(r,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const r=yield d.getImage(n,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(r&&r.data){const n=r.data;this.map._refreshExpiredTiles&&r.cacheControl&&r.expires&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const i=e.b(n)&&e.U()?n:yield this.readImageNow(n),a={type:this.type,uid:t.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:a});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.V()){const r=t.width+2,n=t.height+2;try{return new e.R({width:r,height:n},yield e.W(t,-1,-1,r,n))}catch(t){}}return a.getImageData(t,1)}))}_getNeighboringTiles(t){const r=t.canonical,n=Math.pow(2,r.z),i=(r.x-1+n)%n,a=0===r.x?t.wrap-1:t.wrap,o=(r.x+1+n)%n,s=r.x+1===n?t.wrap+1:t.wrap,l={};return l[new e.S(t.overscaledZ,a,r.z,i,r.y).key]={backfilled:!1},l[new e.S(t.overscaledZ,s,r.z,o,r.y).key]={backfilled:!1},r.y>0&&(l[new e.S(t.overscaledZ,a,r.z,i,r.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&e.e(i,{resourceTiming:n}),this.fire(new e.k("data",Object.assign(Object.assign({},i),{sourceDataType:"metadata"}))),this.fire(new e.k("data",Object.assign(Object.assign({},i),{sourceDataType:"content"})))}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.k("dataabort",{dataType:"source"}));this.fire(new e.j(t))}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const n=yield this.actor.sendAsync({type:e,data:r},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(n,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var St=e.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Et extends e.E{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=e}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield d.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,this.fire(new e.j(t))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const r=t.map(e.Z.fromLngLat);this.tileID=Ct(r),this.minzoom=this.maxzoom=this.tileID.z;const n=r.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new e.$,this._boundsArray.emplaceBack(n[0].x,n[0].y,0,0),this._boundsArray.emplaceBack(n[1].x,n[1].y,e.X,0),this._boundsArray.emplaceBack(n[3].x,n[3].y,0,e.X),this._boundsArray.emplaceBack(n[2].x,n[2].y,e.X,e.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,r=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new B(t,this.image,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}function Ct(t){let r=1/0,n=1/0,i=-1/0,a=-1/0;for(const e of t)r=Math.min(r,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x),a=Math.max(a,e.y);const o=i-r,s=a-n,l=Math.max(o,s),c=Math.max(0,Math.floor(-Math.log(l)/Math.LN2)),u=Math.pow(2,c);return new e.a1(c,Math.floor((r+i)/2*u),Math.floor((n+a)/2*u))}class Lt extends Et{constructor(t,e,r,n){super(t,e,r,n),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.a3(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.j(t))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const r=this.video.seekable;tr.end(0)?this.fire(new e.j(new e.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,r=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new B(t,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class It extends Et{constructor(t,r,n,i){super(t,r,n,i),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.j(new e.a2(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const r=this.map.painter.context,n=r.gl;this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,St.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new B(r,this.canvas,n.RGBA,{premultiply:!0});let i=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Pt={},zt=(t,e,r,n)=>{const i=new(Dt(e.type))(t,e,r,n);if(i.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${i.id}`);return i},Dt=t=>{switch(t){case"geojson":return Mt;case"image":return Et;case"raster":return kt;case"raster-dem":return At;case"vector":return Tt;case"video":return Lt;case"canvas":return It}return Pt[t]},Ot=(t,e)=>{Pt[t]=e},Rt=(t,r)=>e._(void 0,void 0,void 0,(function*(){if(Dt(t))throw new Error(`A source type called "${t}" already exists.`);Ot(t,r)}));function Ft(t,e){const r={};if(!e)return r;for(const n of t){const t=n.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)r[e.id]=n}}return r}const Bt="RTLPluginLoaded";class Nt extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ft()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.k(Bt))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let jt=null;function Ut(){return jt||(jt=new Nt),jt}const Vt=3e4;class qt{constructor(t,r){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.a4(),this.uses=0,this.tileSize=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;et)e=!1;else if(r)if(this.expirationTime{this.remove(t,i)}),r)),this.data[n].push(i),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const r in this.data)for(const n of this.data[r])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Gt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,r,n){const i=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][i]=this.stateChanges[t][i]||{},e.e(this.stateChanges[t][i],n),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==i&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][i]){this.deletedStates[t][i]={};for(const e in this.state[t][i])n[e]||(this.deletedStates[t][i][e]=null)}else for(const e in n)this.deletedStates[t]&&this.deletedStates[t][i]&&null===this.deletedStates[t][i][e]&&delete this.deletedStates[t][i][e]}removeFeatureState(t,e,r){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},r&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][r]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(r in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][r]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,r){const n=String(r),i=this.state[t]||{},a=this.stateChanges[t]||{},o=e.e({},i[n],a[n]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][r];if(null===e)return{};for(const t in e)delete o[t]}return o}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,r){const n={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const r={};for(const n in this.stateChanges[t])this.state[t][n]||(this.state[t][n]={}),e.e(this.state[t][n],this.stateChanges[t][n]),r[n]=this.state[t][n];n[t]=r}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const r={};if(null===this.deletedStates[t])for(const e in this.state[t])r[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const r of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][r];r[e]=this.state[t][e]}n[t]=n[t]||{},e.e(n[t],r)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const e in t)t[e].setFeatureState(n,r)}}class Wt extends e.E{constructor(t,e,r){super(),this.id=t,this.dispatcher=r,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=zt(t,e,r,this),this._tiles={},this._cache=new Ht(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Gt,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,r,n){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,r,n)}catch(r){t.state="errored",404!==r.status?this._source.fire(new e.j(r,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const r=this._tiles[e];r.upload(t),r.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Zt).map((t=>t.key))}getRenderableIds(t){const r=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&r.push(this._tiles[e]);return t?r.sort(((t,r)=>{const n=t.tileID,i=r.tileID,a=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new e.P(i.canonical.x,i.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-i.overscaledZ||o.y-a.y||o.x-a.x})).map((t=>t.tileID.key)):r.map((t=>t.tileID)).sort(Zt).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,r){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=r),yield this._loadTile(e,t,r))}))}_tileLoaded(t,r,n){t.timeAdded=a.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,r,n){for(const i in this._tiles){let a=this._tiles[i];if(n[i]||!a.hasData()||a.tileID.overscaledZ<=e||a.tileID.overscaledZ>r)continue;let o=a.tileID;for(;a&&a.tileID.overscaledZ>e+1;){const t=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[t.key],a&&a.hasData()&&(o=t)}let s=o;for(;s.overscaledZ>e;)if(s=s.scaledTo(s.overscaledZ-1),t[s.key]){n[o.key]=o;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=e?r:null}for(let r=t.overscaledZ-1;r>=e;r--){const e=t.scaledTo(r),n=this._getLoadedTile(e);if(n)return n}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const r=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),n=null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,i=Math.floor(r*n),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._cache.setMaxSize(a)}handleWrapJump(t){const e=(t-(void 0===this._prevLng?t:this._prevLng))/360,r=Math.round(e);if(this._prevLng=t,r){const t={};for(const e in this._tiles){const n=this._tiles[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+r),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles){const e=this._tiles[t];this._setTileReloadTimer(t,e)}}}_updateCoveredAndRetainedTiles(t,e,r,n,i,o){const s={},l={},c=Object.keys(t),u=a.now();for(const r of c){const n=t[r],i=this._tiles[r];if(!i||0!==i.fadeEndTime&&i.fadeEndTime<=u)continue;const a=this.findLoadedParent(n,e),o=this.findLoadedSibling(n),c=a||o||null;c&&(this._addTile(c.tileID),s[c.tileID.key]=c.tileID),l[r]=n}this._retainLoadedChildren(l,n,r,t);for(const e in s)t[e]||(this._coveredTiles[e]=!0,t[e]=s[e]);if(o){const e={},r={};for(const t of i)this._tiles[t.key].hasData()?e[t.key]=t:r[t.key]=t;for(const n in r){const i=r[n].children(this._source.maxzoom);this._tiles[i[0].key]&&this._tiles[i[1].key]&&this._tiles[i[2].key]&&this._tiles[i[3].key]&&(e[i[0].key]=t[i[0].key]=i[0],e[i[1].key]=t[i[1].key]=i[1],e[i[2].key]=t[i[2].key]=i[2],e[i[3].key]=t[i[3].key]=i[3],delete r[n])}for(const n in r){const i=r[n],a=this.findLoadedParent(i,this._source.minzoom),o=this.findLoadedSibling(i),s=a||o||null;if(s){e[s.tileID.key]=t[s.tileID.key]=s.tileID;for(const t in e)e[t].isChildOf(s.tileID)&&delete e[t]}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0)}}update(t,r){if(!this._sourceLoaded||this._paused)return;let n;this.transform=t,this.terrain=r,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.S(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const i=t.coveringZoomLevel(this._source),a=Math.max(i-Wt.maxOverzooming,this._source.minzoom),o=Math.max(i+Wt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of n)if(e.canonical.z>this._source.minzoom){const r=e.scaledTo(e.canonical.z-1);t[r.key]=r;const n=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[n.key]=n}n=n.concat(Object.values(t))}const s=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,s&&this.fire(new e.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(n,i);Yt(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,o,i,n,r);for(const t in l)this._tiles[t].clearFadeHold();const c=e.ac(this._tiles,l);for(const t of c){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var r;const n={},i={},a=Math.max(e-Wt.maxOverzooming,this._source.minzoom),o=Math.max(e+Wt.maxUnderzooming,this._source.minzoom),s={};for(const r of t){const t=this._addTile(r);n[r.key]=r,t.hasData()||ethis._source.maxzoom){const t=o.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){n[t.key]=t;continue}}else{const t=o.children(this._source.maxzoom);if(n[t[0].key]&&n[t[1].key]&&n[t[2].key]&&n[t[3].key])continue}let s=t.wasRequested();for(let e=o.overscaledZ-1;e>=a;--e){const a=o.scaledTo(e);if(i[a.key])break;if(i[a.key]=!0,t=this.getTile(a),!t&&s&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(r=this.map)||void 0===r?void 0:r.cancelPendingTileRequestsWhileZooming)||s)&&(n[a.key]=a),s=t.wasRequested(),e)break}}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let r,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){r=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(r=this._getLoadedTile(t),r)break;n=t}for(const t of e)this._loadedParentTiles[t]=r}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,r=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=r}}_addTile(t){let r=this._tiles[t.key];if(r)return r;r=this._cache.getAndRemove(t),r&&(this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,r)));const n=r;return r||(r=new qt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(r,t.key,r.state)),r.uses++,this._tiles[t.key]=r,n||this._source.fire(new e.k("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),r))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,r,n){const i=[],a=this.transform;if(!a)return i;const o=n?a.getCameraQueryGeometry(t):t,s=t.map((t=>a.pointCoordinate(t,this.terrain))),l=o.map((t=>a.pointCoordinate(t,this.terrain))),c=this.getIds();let u=1/0,h=1/0,f=-1/0,p=-1/0;for(const t of l)u=Math.min(u,t.x),h=Math.min(h,t.y),f=Math.max(f,t.x),p=Math.max(p,t.y);for(let t=0;t=0&&g[1].y+m>=0){const t=s.map((t=>o.getTilePoint(t))),e=l.map((t=>o.getTilePoint(t)));i.push({tile:n,tileID:o,queryGeometry:t,cameraQueryGeometry:e,scale:d})}}return i}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type)){const t=a.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return!0}return!1}setFeatureState(t,e,r){t=t||"_geojsonTileLayer",this._state.updateState(t,e,r)}removeFeatureState(t,e,r){t=t||"_geojsonTileLayer",this._state.removeFeatureState(t,e,r)}getFeatureState(t,e){return t=t||"_geojsonTileLayer",this._state.getState(t,e)}setDependencies(t,e,r){const n=this._tiles[t];n&&n.setDependencies(e,r)}reloadTilesForDependencies(t,e){for(const r in this._tiles)this._tiles[r].hasDependency(t,e)&&this._reloadTile(r,"reloading");this._cache.filter((r=>!r.hasDependency(t,e)))}}function Zt(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Yt(t){return"raster"===t||"image"===t||"video"===t}Wt.maxOverzooming=10,Wt.maxUnderzooming=3;class Xt{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(i-o)/s:0;return this.points[a].mult(1-l).add(this.points[r].mult(l))}}function $t(t,e){let r=!0;return"always"===t||"never"!==t&&"never"!==e||(r=!1),r}class Jt{constructor(t,e,r){const n=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(e/r);for(let t=0;tthis.width||n<0||e>this.height)return[];const s=[];if(t<=0&&e<=0&&this.width<=r&&this.height<=n){if(i)return[{key:null,x1:t,y1:e,x2:r,y2:n}];for(let t=0;t0}hitTestCircle(t,e,r,n,i){const a=t-r,o=t+r,s=e-r,l=e+r;if(o<0||a>this.width||l<0||s>this.height)return!1;const c=[],u={hitTest:!0,overlapMode:n,circle:{x:t,y:e,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(a,s,o,l,this._queryCellCircle,c,u,i),c.length>0}_queryCell(t,e,r,n,i,a,o,s){const{seenUids:l,hitTest:c,overlapMode:u}=o,h=this.boxCells[i];if(null!==h){const i=this.bboxes;for(const o of h)if(!l.box[o]){l.box[o]=!0;const h=4*o,f=this.boxKeys[o];if(t<=i[h+2]&&e<=i[h+3]&&r>=i[h+0]&&n>=i[h+1]&&(!s||s(f))&&(!c||!$t(u,f.overlapMode))&&(a.push({key:f,x1:i[h],y1:i[h+1],x2:i[h+2],y2:i[h+3]}),c))return!0}}const f=this.circleCells[i];if(null!==f){const i=this.circles;for(const o of f)if(!l.circle[o]){l.circle[o]=!0;const h=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(i[h],i[h+1],i[h+2],t,e,r,n)&&(!s||s(f))&&(!c||!$t(u,f.overlapMode))){const t=i[h],e=i[h+1],r=i[h+2];if(a.push({key:f,x1:t-r,y1:e-r,x2:t+r,y2:e+r}),c)return!0}}}return!1}_queryCellCircle(t,e,r,n,i,a,o,s){const{circle:l,seenUids:c,overlapMode:u}=o,h=this.boxCells[i];if(null!==h){const t=this.bboxes;for(const e of h)if(!c.box[e]){c.box[e]=!0;const r=4*e,n=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[r+0],t[r+1],t[r+2],t[r+3])&&(!s||s(n))&&!$t(u,n.overlapMode))return a.push(!0),!0}}const f=this.circleCells[i];if(null!==f){const t=this.circles;for(const e of f)if(!c.circle[e]){c.circle[e]=!0;const r=3*e,n=this.circleKeys[e];if(this._circlesCollide(t[r],t[r+1],t[r+2],l.x,l.y,l.radius)&&(!s||s(n))&&!$t(u,n.overlapMode))return a.push(!0),!0}}}_forEachCell(t,e,r,n,i,a,o,s){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(r),h=this._convertToYCellCoord(n);for(let f=l;f<=u;f++)for(let l=c;l<=h;l++){const c=this.xCellCount*l+f;if(i.call(this,t,e,r,n,c,a,o,s))return}}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,r,n,i,a){const o=n-t,s=i-e,l=r+a;return l*l>o*o+s*s}_circleAndRectCollide(t,e,r,n,i,a,o){const s=(a-n)/2,l=Math.abs(t-(n+s));if(l>s+r)return!1;const c=(o-i)/2,u=Math.abs(e-(i+c));if(u>c+r)return!1;if(l<=s||u<=c)return!0;const h=l-s,f=u-c;return h*h+f*f<=r*r}}function Kt(t,r,n,i,a){const o=e.H();return r?(e.K(o,o,[1/a,1/a,1]),n||e.ae(o,o,i.angle)):e.L(o,i.labelPlaneMatrix,t),o}function Qt(t,r,n,i,a){if(r){const r=e.af(t);return e.K(r,r,[a,a,1]),n||e.ae(r,r,-i.angle),r}return i.glCoordMatrix}function te(t,r,n){let i;n?(i=[t.x,t.y,n(t.x,t.y),1],e.ag(i,i,r)):(i=[t.x,t.y,0,1],ye(i,i,r));const a=i[3];return{point:new e.P(i[0]/a,i[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function ee(t,e){return.5+t/e*.5}function re(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function ne(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m){const g=i?t.textSizeData:t.iconSizeData,y=e.ah(g,n.transform.zoom),v=[256/n.width*2+1,256/n.height*2+1],x=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;x.clear();const _=t.lineVertexArray,b=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=n.transform.width/n.transform.height;let T=!1;for(let i=0;iMath.abs(n.x-r.x)*i?{useVertical:!0}:(t===e.ai.vertical?r.yn.x)?{needsFlipping:!0}:null}function oe(t,r,n,i,a,o,s,l,c,u,h){const f=n/24,p=r.lineOffsetX*f,d=r.lineOffsetY*f;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,n=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=ie(f,l,p,d,i,r,h,t);if(!c)return{notEnoughRoom:!0};const g=te(c.first.point,s,t.getElevation).point,y=te(c.last.point,s,t.getElevation).point;if(a&&!i){const t=ae(r.writingMode,g,y,u);if(t)return t}m=[c.first];for(let a=r.glyphStartIndex+1;a0?s.point:se(t.tileAnchorPoint,a,n,1,o,t),c=ae(r.writingMode,n,l,u);if(c)return c}const n=de(f*l.getoffsetX(r.glyphStartIndex),p,d,i,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,h);if(!n||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[n]}for(const t of m)e.ak(c,t.point,t.angle);return{}}function se(t,e,r,n,i,a){return ce(t,e,r,n,i,a)}function le(t,e,r,n,i){return ce(t,e,r,n,void 0,i)}function ce(t,e,r,n,i,a){const o=t.add(t.sub(e)._unit()),s=void 0!==i?te(o,i,a.getElevation).point:he(o.x,o.y,a).point,l=r.sub(s);return r.add(l._mult(n/l.mag()))}function ue(t,r,n){const i=r.projectionCache;if(i.projections[t])return i.projections[t];const a=new e.P(r.lineVertexArray.getx(t),r.lineVertexArray.gety(t)),o=he(a.x,a.y,r);if(o.signedDistanceFromCamera>0)return i.projections[t]=o.point,i.anyProjectionOccluded=i.anyProjectionOccluded||o.isOccluded,o.point;const s=t-n.direction,l=0===n.distanceFromAnchor?r.tileAnchorPoint:new e.P(r.lineVertexArray.getx(s),r.lineVertexArray.gety(s)),c=n.absOffsetX-n.distanceFromAnchor+1;return le(l,a,n.previousVertex,c,r)}function he(t,r,n){const i=t+n.translation[0],a=r+n.translation[1];let o;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(o=n.projection.projectTileCoordinates(i,a,n.unwrappedTileID,n.getElevation),o.point.x=(.5*o.point.x+.5)*n.width,o.point.y=(.5*-o.point.y+.5)*n.height):(o=te(new e.P(i,a),n.labelPlaneMatrix,n.getElevation),o.isOccluded=!1),o}function fe(t,e,r){return t._unit()._perp()._mult(e*r)}function pe(t,r,n,i,a,o,s,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const u=n.add(r);if(t+c.direction=a)return l.projectionCache.offsets[t]=u,u;const h=ue(t+c.direction,l,c),f=fe(h.sub(n),s,c.direction),p=n.add(f),d=h.add(f);return l.projectionCache.offsets[t]=e.al(o,u,p,d)||u,l.projectionCache.offsets[t]}function de(t,e,r,n,i,a,o,s,l){const c=n?t-e:t+e;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let f,p=u>0?a+i:a+i+1;s.projectionCache.cachedAnchorPoint?f=s.projectionCache.cachedAnchorPoint:(f=he(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=f);let d,m,g=f,y=f,v=0,x=0;const _=Math.abs(c),b=[];let w;for(;v+x<=_;){if(p+=u,p=o)return null;v+=x,y=g,m=d;const t={absOffsetX:_,direction:u,distanceFromAnchor:v,previousVertex:y};if(g=ue(p,s,t),0===r)b.push(y),w=g.sub(y);else{let e;const n=g.sub(y);e=0===n.mag()?fe(ue(p+u,s,t).sub(g),r,u):fe(n,r,u),m||(m=y.add(e)),d=pe(p,e,g,a,o,m,r,s,t),b.push(m),w=d.sub(m)}x=w.mag()}const T=(_-v)/x,k=w._mult(T)._add(m||y),A=h+Math.atan2(g.y-y.y,g.x-y.x);return b.push(k),{point:k,angle:l?A:0,path:b}}const me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ge(t,e){for(let r=0;r=1;t--)l.push(o.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const t=l[0].clone(),r=l[0].clone();for(let e=1;e=n.x&&r.x<=i.x&&t.y>=n.y&&r.y<=i.y?[l]:r.xi.x||r.yi.y?[]:e.am([l],n.x,n.y,i.x,i.y)}for(const e of m){a.reset(e,.25*r);let n=0;n=a.length<=.5*r?1:Math.ceil(a.paddedLength/h)+1;for(let e=0;ete(t,r,e.getElevation)))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let n=1/0,i=1/0,a=-1/0,o=-1/0;for(const s of t){const t=new e.P(s.x+ve,s.y+ve);n=Math.min(n,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y),r.push(t)}const s=this.grid.query(n,i,a,o).concat(this.ignoredGrid.query(n,i,a,o)),l={},c={};for(const t of s){const n=t.key;if(void 0===l[n.bucketInstanceId]&&(l[n.bucketInstanceId]={}),l[n.bucketInstanceId][n.featureIndex])continue;const i=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.an(r,i)&&(l[n.bucketInstanceId][n.featureIndex]=!0,void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]=[]),c[n.bucketInstanceId].push(n.featureIndex))}return c}insertCollisionBox(t,e,r,n,i,a){const o={bucketInstanceId:n,featureIndex:i,collisionGroupID:a,overlapMode:e};(r?this.ignoredGrid:this.grid).insert(o,t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,r,n,i,a){const o=r?this.ignoredGrid:this.grid,s={bucketInstanceId:n,featureIndex:i,collisionGroupID:a,overlapMode:e};for(let e=0;e=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(t,e,r,n){return r>=0&&t=0&&ethis.projectAndGetPerspectiveRatio(n,t.x,t.y,i,c)));A=t.some((t=>!t.isOccluded)),k=t.map((t=>t.point))}else A=!0;return{box:e.ap(k),allPointsOccluded:!A}}}function _e(t,r,n){return r*(e.X/(t.tileSize*Math.pow(2,n-t.tileID.overscaledZ)))}class be{constructor(t,e,r,n){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):n&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class we{constructor(t,e,r,n,i){this.text=new be(t?t.text:null,e,r,i),this.icon=new be(t?t.icon:null,e,n,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Te{constructor(t,e,r){this.text=t,this.icon=e,this.skipFade=r}}class ke{constructor(){this.invProjMatrix=e.H(),this.viewportMatrix=e.H(),this.circles=[]}}class Ae{constructor(t,e,r,n,i){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=r,this.bucketIndex=n,this.tileID=i}}class Me{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function Se(t,r,n,i,a){const{horizontalAlign:o,verticalAlign:s}=e.av(t),l=-(o-.5)*r,c=-(s-.5)*n;return new e.P(l+i[0]*a,c+i[1]*a)}class Ee{constructor(t,e,r,n,i,a){this.transform=t.clone(),this.terrain=r,this.collisionIndex=new xe(this.transform,e),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new Me(i),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(r,n)=>e.getElevation(t,r,n):null}getBucketParts(t,r,n,i){const a=n.getBucket(r),o=n.latestFeatureIndex;if(!a||!o||r.id!==a.layerIds[0])return;const s=n.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/e.X,f=n.tileID.toUnwrapped(),p=this.transform.calculatePosMatrix(f),d="map"===l.get("text-pitch-alignment"),m="map"===l.get("text-rotation-alignment"),g=_e(n,1,this.transform.zoom),y=this.collisionIndex.mapProjection.translatePosition(this.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),v=this.collisionIndex.mapProjection.translatePosition(this.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),x=Kt(p,d,m,this.transform,g);let _=null;if(d){const t=Qt(p,d,m,this.transform,g);_=e.L([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[a.bucketInstanceId]=new Ae(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,n.tileID);const b={bucket:a,layout:l,translationText:y,translationIcon:v,posMatrix:p,unwrappedTileID:f,textLabelPlaneMatrix:x,labelToScreenMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:e.ah(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(const e of a.sortKeyRanges){const{sortKey:r,symbolInstanceStart:n,symbolInstanceEnd:i}=e;t.push({sortKey:r,symbolInstanceStart:n,symbolInstanceEnd:i,parameters:b})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:b})}attemptAnchorPlacement(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m,g,y,v,x){const _=e.ar[t.textAnchor],b=[t.textOffset0,t.textOffset1],w=Se(_,n,i,b,a),T=this.collisionIndex.placeCollisionBox(r,f,l,c,u,s,o,g,h.predicate,x,w);if((!v||this.collisionIndex.placeCollisionBox(v,f,l,c,u,s,o,y,h.predicate,x,w).placeable)&&T.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:i,anchor:_,textBoxScale:a,prevAnchor:t},this.markUsedJustification(d,_,p,m),d.allowVerticalPlacement&&(this.markUsedOrientation(d,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,r,n){const{bucket:i,layout:a,translationText:o,translationIcon:s,posMatrix:l,unwrappedTileID:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,textPixelRatio:f,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:m,collisionGroup:g}=t.parameters,y=a.get("text-optional"),v=a.get("icon-optional"),x=e.as(a,"text-overlap","text-allow-overlap"),_="always"===x,b=e.as(a,"icon-overlap","icon-allow-overlap"),w="always"===b,T="map"===a.get("text-rotation-alignment"),k="map"===a.get("text-pitch-alignment"),A="none"!==a.get("icon-text-fit"),M="viewport-y"===a.get("symbol-z-order"),S=_&&(w||!i.hasIconData()||v),E=w&&(_||!i.hasTextData()||y);!i.collisionArrays&&d&&i.deserializeCollisionBoxes(d);const C=this.retainedQueryData[i.bucketInstanceId].tileID,L=this._getTerrainElevationFunc(C),I=(t,d,w)=>{var M,C;if(r[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new Te(!1,!1,!1));let I=!1,P=!1,z=!0,D=null,O={box:null,placeable:!1,offscreen:null},R={box:null,placeable:!1,offscreen:null},F=null,B=null,N=null,j=0,U=0,V=0;d.textFeatureIndex?j=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=t.featureIndex),d.verticalTextFeatureIndex&&(U=d.verticalTextFeatureIndex);const q=d.textBox;if(q){const r=r=>{let n=e.ai.horizontal;if(i.allowVerticalPlacement&&!r&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,n=e,this.markUsedOrientation(i,n,t))}return n},a=(r,n)=>{if(i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of i.writingModes)if(t===e.ai.vertical?(O=n(),R=O):O=r(),O&&O.placeable)break}else O=r()},u=t.textAnchorOffsetStartIndex,h=t.textAnchorOffsetEndIndex;if(h===u){const n=(e,r)=>{const n=this.collisionIndex.placeCollisionBox(e,x,f,l,c,k,T,o,g.predicate,L);return n&&n.placeable&&(this.markUsedOrientation(i,r,t),this.placedOrientations[t.crossTileID]=r),n};a((()=>n(q,e.ai.horizontal)),(()=>{const r=d.verticalTextBox;return i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&r?n(r,e.ai.vertical):{box:null,offscreen:null}})),r(O&&O.placeable)}else{let p=e.ar[null===(C=null===(M=this.prevPlacement)||void 0===M?void 0:M.variableOffsets[t.crossTileID])||void 0===C?void 0:C.anchor];const m=(r,a,d)=>{const m=r.x2-r.x1,y=r.y2-r.y1,v=t.textBoxScale,_=A&&"never"===b?a:null;let w=null,M="never"===x?1:2,S="never";p&&M++;for(let e=0;em(q,d.iconBox,e.ai.horizontal)),(()=>{const r=d.verticalTextBox,n=O&&O.placeable;return i.allowVerticalPlacement&&!n&&t.numVerticalGlyphVertices>0&&r?m(r,d.verticalIconBox,e.ai.vertical):{box:null,occluded:!0,offscreen:null}})),O&&(I=O.placeable,z=O.offscreen);const y=r(O&&O.placeable);if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(i,e.anchor,t,y))}}}if(F=O,I=F&&F.placeable,z=F&&F.offscreen,t.useRuntimeCollisionCircles){const r=i.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),s=e.aj(i.textSizeData,m,r),f=a.get("text-padding"),p=t.collisionCircleDiameter;B=this.collisionIndex.placeCollisionCircles(x,r,i.lineVertexArray,i.glyphOffsetArray,s,l,c,u,h,n,k,g.predicate,p,f,o,L),B.circles.length&&B.collisionDetected&&!n&&e.w("Collisions detected, but collision boxes are not shown"),I=_||B.circles.length>0&&!B.collisionDetected,z=z&&B.offscreen}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,b,f,l,c,k,T,s,g.predicate,L,A&&D?D:void 0);R&&R.placeable&&d.verticalIconBox?(N=t(d.verticalIconBox),P=N.placeable):(N=t(d.iconBox),P=N.placeable),z=z&&N.offscreen}const H=y||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=v||0===t.numIconVertices;H||G?G?H||(P=P&&I):I=P&&I:P=I=P&&I;const W=I&&F.placeable,Z=P&&N.placeable;if(W&&(R&&R.placeable&&U?this.collisionIndex.insertCollisionBox(F.box,x,a.get("text-ignore-placement"),i.bucketInstanceId,U,g.ID):this.collisionIndex.insertCollisionBox(F.box,x,a.get("text-ignore-placement"),i.bucketInstanceId,j,g.ID)),Z&&this.collisionIndex.insertCollisionBox(N.box,b,a.get("icon-ignore-placement"),i.bucketInstanceId,V,g.ID),B&&I&&this.collisionIndex.insertCollisionCircles(B.circles,x,a.get("text-ignore-placement"),i.bucketInstanceId,j,g.ID),n&&this.storeCollisionData(i.bucketInstanceId,w,d,F,N,B),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===i.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new Te(I||S,P||E,z||i.justReloaded),r[t.crossTileID]=!0};if(M){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=i.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const r=e[t];I(i.symbolInstances.get(r),i.collisionArrays[r],r)}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:n.crossTileID)}markUsedOrientation(t,r,n){const i=r===e.ai.horizontal||r===e.ai.horizontalOnly?r:0,a=r===e.ai.vertical?r:0,o=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const e of o)t.text.placedSymbolArray.get(e).placedOrientation=i;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let r=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const n=e?e.symbolFadeChange(t):1,i=e?e.opacities:{},a=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],a=i[t];a?(this.opacities[t]=new we(a,n,e.text,e.icon),r=r||e.text!==a.text.placed||e.icon!==a.icon.placed):(this.opacities[t]=new we(null,n,e.text,e.icon,e.skipFade),r=r||e.text||e.icon)}for(const t in i){const e=i[t];if(!this.opacities[t]){const i=new we(e,n,!1,!1);i.isHidden()||(this.opacities[t]=i,r=r||e.text.placed||e.icon.placed)}}for(const t in a)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=a[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const r={};for(const n of e){const e=n.getBucket(t);e&&n.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,n.tileID,r,n.collisionBoxArray)}}updateBucketOpacities(t,r,n,i){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const a=t.layers[0],o=a.layout,s=new we(null,0,!1,!1,!0),l=o.get("text-allow-overlap"),c=o.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===o.get("text-rotation-alignment"),f="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),d=new we(null,0,l&&(c||!t.hasIconData()||o.get("icon-optional")),c&&(l||!t.hasTextData()||o.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const m=(t,e,r)=>{for(let n=0;n0||o>0,x=i.numIconVertices>0,_=this.placedOrientations[i.crossTileID],b=_===e.ai.vertical,w=_===e.ai.horizontal||_===e.ai.horizontalOnly;if(v){const e=Fe(y.text),r=b?Be:e;m(t.text,a,r);const n=w?Be:e;m(t.text,o,n);const s=y.text.isHidden();[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=s||b?1:0)})),i.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=s||w?1:0);const l=this.variableOffsets[i.crossTileID];l&&this.markUsedJustification(t,l.anchor,i,_);const c=this.placedOrientations[i.crossTileID];c&&(this.markUsedJustification(t,"left",i,c),this.markUsedOrientation(t,c,i))}if(x){const e=Fe(y.icon),r=!(p&&i.verticalPlacedIconSymbolIndex&&b);if(i.placedIconSymbolIndex>=0){const n=r?e:Be;m(t.icon,i.numIconVertices,n),t.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=y.icon.isHidden()}if(i.verticalPlacedIconSymbolIndex>=0){const n=r?Be:e;m(t.icon,i.numVerticalIconVertices,n),t.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden()}}const T=g&&g.has(r)?g.get(r):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.P(0,0);if(n.textBox||n.verticalTextBox){let e=!0;if(u){const t=this.variableOffsets[l];t?(r=Se(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),h&&r._rotate(f?this.transform.angle:-this.transform.angle)):e=!1}if(n.textBox||n.verticalTextBox){let i;n.textBox&&(i=b),n.verticalTextBox&&(i=w),Ce(t.textCollisionBox.collisionVertexArray,y.text.placed,!e||i,T.text,r.x,r.y)}}if(n.iconBox||n.verticalIconBox){const e=Boolean(!w&&n.verticalIconBox);let i;n.iconBox&&(i=e),n.verticalIconBox&&(i=!e),Ce(t.iconCollisionBox.collisionVertexArray,y.icon.placed,i,T.icon,p?r.x:0,p?r.y:0)}}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ce(t,e,r,n,i,a){n&&0!==n.length||(n=[0,0,0,0]);const o=n[0]-ve,s=n[1]-ve,l=n[2]-ve,c=n[3]-ve;t.emplaceBack(e?1:0,r?1:0,i||0,a||0,o,s),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,l,s),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,l,c),t.emplaceBack(e?1:0,r?1:0,i||0,a||0,o,c)}const Le=Math.pow(2,25),Ie=Math.pow(2,24),Pe=Math.pow(2,17),ze=Math.pow(2,16),De=Math.pow(2,9),Oe=Math.pow(2,8),Re=Math.pow(2,1);function Fe(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*Le+e*Ie+r*Pe+e*ze+r*De+e*Oe+r*Re+e}const Be=0;function Ne(){return{isOccluded:(t,e,r)=>!1,getPitchedTextCorrection:(t,e,r)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(t,e,r,n){throw new Error("Not implemented.")},translatePosition:(t,e,r,n)=>je(t,e,r,n),getCircleRadiusCorrection:t=>1}}function je(t,e,r,n,i=!1){if(!r[0]&&!r[1])return[0,0];const a=i?"map"===n?t.angle:0:"viewport"===n?-t.angle:0;if(a){const t=Math.sin(a),e=Math.cos(a);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e]}return[i?r[0]:_e(e,r[0],t.zoom),i?r[1]:_e(e,r[1],t.zoom)]}class Ue{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,r,n,i){const a=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&a.now()-n>2;for(;this._currentPlacementIndex>=0;){const n=e[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=a)&&(!n.maxzoom||n.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new Ue(n)),this._inProgressLayer.continuePlacement(r[n.source],this.placement,this._showCollisionBoxes,n,i))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const qe=512/e.X/2,He=128;class Ge{constructor(t,r,n){this.tileID=t,this.bucketInstanceId=n,this._symbolsByKey={};const i=new Map;for(let t=0;t({x:Math.floor(t.anchorX*qe),y:Math.floor(t.anchorY*qe)}))),crossTileIDs:r.map((t=>t.crossTileID))};if(n.positions.length>He){const t=new e.aw(n.positions.length,16,Uint16Array);for(const{x:e,y:r}of n.positions)t.add(e,r);t.finish(),delete n.positions,n.index=t}this._symbolsByKey[t]=n}}getScaledCoordinates(t,r){const{x:n,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:l}=r.canonical,c=l-a,u=qe/Math.pow(2,c),h=(o*e.X+t.anchorX)*u,f=(s*e.X+t.anchorY)*u,p=n*e.X*qe,d=i*e.X*qe;return{x:Math.floor(h-p),y:Math.floor(f-d)}}findMatches(t,e,r){const n=this.tileID.canonical.zt))}}class We{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ze{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const r=this.indexes[t],n={};for(const t in r){const i=r[t];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),n[i.tileID.key]=i}this.indexes[t]=n}this.lng=t}addBucket(t,e,r){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(const r in i){const a=i[r];a.tileID.isChildOf(t)&&a.findMatches(e.symbolInstances,t,n)}else{const a=i[t.scaledTo(Number(r)).key];a&&a.findMatches(e.symbolInstances,t,n)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Xe=(t,r)=>e.t(t,r&&r.filter((t=>"source.canvas"!==t.identifier))),$e=e.ax();class Je extends e.E{constructor(t,r={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload()}},this.map=t,this.dispatcher=new ht(lt(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new U,this.imageManager.setEventedParent(this),this.glyphManager=new Z(t._requestManager,r.localIdeographFontFamily),this.lineAtlas=new et(256,512),this.crossTileSymbolIndex=new Ye,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.az()),Ut().on(Bt,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const r=e.getSource();if(r&&r.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===r.id&&this._validateLayer(e)}}))}loadURL(t,r={},n){this.fire(new e.k("dataloading",{dataType:"style"})),r.validate="boolean"!=typeof r.validate||r.validate;const i=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;e.h(i,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,r,n)})).catch((t=>{this._loadStyleRequest=null,t&&!a.signal.aborted&&this.fire(new e.j(t))}))}loadJSON(t,r={},n){this.fire(new e.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,r.validate=!1!==r.validate,this._load(t,r,n)})).catch((()=>{}))}loadEmpty(){this.fire(new e.k("dataloading",{dataType:"style"})),this._load($e,{validate:!1})}_load(t,r,n){var i;const a=r.transformStyle?r.transformStyle(n,t):t;if(!r.validate||!Xe(this,e.x(a))){this._loaded=!0,this.stylesheet=a;for(const t in a.sources)this.addSource(t,a.sources[t],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new J(this.stylesheet.light),this.sky=new tt(this.stylesheet.sky),this.map.setTerrain(null!==(i=this.stylesheet.terrain)&&void 0!==i?i:null),this.fire(new e.k("data",{dataType:"style"})),this.fire(new e.k("style.load"))}}_createLayers(){const t=e.aA(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const r of t){const t=e.aB(r);t.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=t}}_loadSprite(t,r=!1,n=void 0){let i;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,R(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const n=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of n)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const n in t[e]){const i="default"===e?n:`${e}:${n}`;this._spritesImagesIds[e].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,t[e][n],!1):this.imageManager.addImage(i,t[e][n]),r&&(this._changedImages[i]=!0)}}})).catch((t=>{this._spriteRequest=null,i=t,this.fire(new e.j(i))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),r&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"})),n&&n(i)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}_validateLayer(t){const r=this.sourceCaches[t.source];if(!r)return;const n=t.sourceLayer;if(!n)return;const i=r.getSource();("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.j(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const e=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e);const r=[];for(const n of t)e[n]&&r.push(e[n]);return r}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const r of e){const e=this._layers[r];"custom"!==e.type&&(t[r]=e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.sky&&this.sky.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const r=this._changed;if(r){const e=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(e.length||r.length)&&this._updateWorkerLayers(e,r);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const n={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];n[t]=e.used,e.used=!1}for(const e of this._order){const r=this._layers[e];r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)&&r.source&&(this.sourceCaches[r.source].used=!0)}for(const t in n){const r=this.sourceCaches[t];!!n[t]!=!!r.used&&r.fire(new e.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.z=t.zoom,r&&this.fire(new e.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,r={}){var n;this._checkLoaded();const i=this.serialize();if(t=r.transformStyle?r.transformStyle(i,t):t,(null===(n=r.validate)||void 0===n||n)&&Xe(this,e.x(t)))return!1;(t=e.aC(t)).layers=e.aA(t.layers);const a=e.aD(i,t),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const t of o.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],r=[];for(const n of t)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,n.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,n.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,n.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,n.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,n.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,n.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,n.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,n.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,n.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,n.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,n.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,n.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,n.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,n.args)));break;case"setTransition":e.push((()=>{}));break;default:r.push(n.command)}return{operations:e,unimplemented:r}}addImage(t,r){if(this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,r),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,r,n={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(e.x.source,`sources.${t}`,r,null,n))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const i=this.sourceCaches[t]=new Wt(t,r,this.dispatcher);i.style=this,i.setEventedParent(this,(()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:t}))),i.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const r in this._layers)if(this._layers[r].source===t)return this.fire(new e.j(new Error(`Source "${t}" cannot be removed while layer "${r}" is using it.`)));const r=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],r.fire(new e.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),r.setEventedParent(null),r.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const r=this.sourceCaches[t].getSource();if("geojson"!==r.type)throw new Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,r,n={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.j(new Error(`Layer "${i}" already exists on this map.`)));let a;if("custom"===t.type){if(Xe(this,e.aE(t)))return;a=e.aB(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(i,t.source),t=e.aC(t),t=e.e(t,{source:i})),this._validate(e.x.layer,`layers.${i}`,t,{arrayIndex:-1},n))return;a=e.aB(t),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}const o=r?this._order.indexOf(r):this._order.length;if(r&&-1===o)this.fire(new e.j(new Error(`Cannot add layer "${i}" before non-existing layer "${r}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&"custom"!==a.type){const t=this._removedLayers[i];delete this._removedLayers[i],t.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(t,r){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===r)return;const n=this._order.indexOf(t);this._order.splice(n,1);const i=r?this._order.indexOf(r):this._order.length;r&&-1===i?this.fire(new e.j(new Error(`Cannot move layer "${t}" before non-existing layer "${r}".`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const r=this._layers[t];if(!r)return void this.fire(new e.j(new Error(`Cannot remove non-existing layer "${t}".`)));r.setEventedParent(null);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=r,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],r.onRemove&&r.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,r,n){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===r&&i.maxzoom===n||(null!=r&&(i.minzoom=r),null!=n&&(i.maxzoom=n),this._updateLayer(i)):this.fire(new e.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,r,n={}){this._checkLoaded();const i=this.getLayer(t);if(i){if(!e.aF(i.filter,r))return null==r?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(e.x.filter,`layers.${i.id}.filter`,r,null,n)||(i.filter=e.aC(r),this._updateLayer(i)))}else this.fire(new e.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.aC(this.getLayer(t).filter)}setLayoutProperty(t,r,n,i={}){this._checkLoaded();const a=this.getLayer(t);a?e.aF(a.getLayoutProperty(r),n)||(a.setLayoutProperty(r,n,i),this._updateLayer(a)):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,r){const n=this.getLayer(t);if(n)return n.getLayoutProperty(r);this.fire(new e.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,r,n,i={}){this._checkLoaded();const a=this.getLayer(t);a?e.aF(a.getPaintProperty(r),n)||(a.setPaintProperty(r,n,i)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,r){this._checkLoaded();const n=t.source,i=t.sourceLayer,a=this.sourceCaches[n];if(void 0===a)return void this.fire(new e.j(new Error(`The source '${n}' does not exist in the map's style.`)));const o=a.getSource().type;"geojson"===o&&i?this.fire(new e.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||i?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),a.setFeatureState(i,t.id,r)):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,r){this._checkLoaded();const n=t.source,i=this.sourceCaches[n];if(void 0===i)return void this.fire(new e.j(new Error(`The source '${n}' does not exist in the map's style.`)));const a=i.getSource().type,o="vector"===a?t.sourceLayer:void 0;"vector"!==a||o?r&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.j(new Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(o,t.id,r):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const r=t.source,n=t.sourceLayer,i=this.sourceCaches[r];if(void 0!==i)return"vector"!==i.getSource().type||n?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),i.getFeatureState(n,t.id)):void this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.j(new Error(`The source '${r}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.aG(this.sourceCaches,(t=>t.serialize())),r=this._serializeByIds(this._order),n=this.map.getTerrain()||void 0,i=this.stylesheet;return e.aH({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,sources:t,layers:r,terrain:n},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,r={},n=[];for(let i=this._order.length-1;i>=0;i--){const a=this._order[i];if(e(a)){r[a]=i;for(const e of t){const t=e[a];if(t)for(const e of t)n.push(e)}}}n.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const i=[];for(let a=this._order.length-1;a>=0;a--){const o=this._order[a];if(e(o))for(let t=n.length-1;t>=0;t--){const e=n[t].feature;if(r[e.layer.id]t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(r,l[r.source],t.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((i=i||this._layerOrderChanged||0===r)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.now(),t.zoom))&&(this.pauseablePlacement=new Ve(t,this.map.terrain,this._order,i,e,r,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,r){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(r.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[r.source];return e&&e.setDependencies(r.tileID.key,r.type,r.icons),t}))}getGlyphs(t,r){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(r.stacks),e=this.sourceCaches[r.source];return e&&e.setDependencies(r.tileID.key,r.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,r={}){this._checkLoaded(),t&&this._validate(e.x.glyphs,"glyphs",t,null,r)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,r,n={},i){this._checkLoaded();const a=[{id:t,url:r}],o=[...D(this.stylesheet.sprite),...a];this._validate(e.x.sprite,"sprite",o,null,n)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(t){this._checkLoaded();const r=D(this.stylesheet.sprite);if(r.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;r.splice(r.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=r.length>0?r:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}else this.fire(new e.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return D(this.stylesheet.sprite)}setSprite(t,r={},n){this._checkLoaded(),t&&this._validate(e.x.sprite,"sprite",t,null,r)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,n):(this._unloadSprite(),n&&n(null)))}}var Ke=e.Y([{name:"a_pos",type:"Int16",components:2}]),Qe="uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",tr="attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}",er="uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",rr="uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",nr="varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ir="uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}",ar="void main() {gl_FragColor=vec4(1.0);}",or="attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}",sr="uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",lr="uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}",cr="uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}",ur="uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}",hr="varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}",fr="attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}",pr="varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",dr="attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}",mr="uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",gr="attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}",yr="#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",vr="attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}",xr="varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",_r="attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}",br="uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",wr="uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}",Tr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",kr="uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}",Ar="varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Mr="uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}",Sr="uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Er="uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}",Cr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Lr="uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}",Ir="uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Pr="uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}",zr="uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Dr="\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}",Or="uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Rr="\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}",Fr="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Br="\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}",Nr="uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",jr="\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}",Ur="uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Vr="uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}",qr="uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Hr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}",Gr="#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Wr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}",Zr="#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Yr="attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}",Xr="varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",$r="precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",Jr="uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}",Kr="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}",Qr="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}",tn="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}",en="uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}",rn="attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}";const nn={prelude:an("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:an(Qe,tr),backgroundPattern:an(er,rr),circle:an(nr,ir),clippingMask:an(ar,or),heatmap:an(sr,lr),heatmapTexture:an(cr,ur),collisionBox:an(hr,fr),collisionCircle:an(pr,dr),debug:an(mr,gr),fill:an(yr,vr),fillOutline:an(xr,_r),fillOutlinePattern:an(br,wr),fillPattern:an(Tr,kr),fillExtrusion:an(Ar,Mr),fillExtrusionPattern:an(Sr,Er),hillshadePrepare:an(Cr,Lr),hillshade:an(Ir,Pr),line:an(zr,Dr),lineGradient:an(Or,Rr),linePattern:an(Fr,Br),lineSDF:an(Nr,jr),raster:an(Ur,Vr),symbolIcon:an(qr,Hr),symbolSDF:an(Gr,Wr),symbolTextAndIcon:an(Zr,Yr),terrain:an(Jr,tn),terrainDepth:an(Xr,Kr),terrainCoords:an($r,Qr),sky:an(en,rn)};function an(t,e){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=e.match(/attribute ([\w]+) ([\w]+)/g),i=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return t=t.replace(r,((t,e,r,n,i)=>(s[i]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nvarying ${r} ${n} ${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = u_${i};\n#endif\n`))),e=e.replace(r,((t,e,r,n,i)=>{const a="float"===n?"vec2":"vec4",o=i.match(/color/)?"color":a;return s[i]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nattribute ${r} ${a} a_${i};\nvarying ${r} ${n} ${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nattribute ${r} ${a} a_${i};\n#else\nuniform ${r} ${n} u_${i};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = a_${i};\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${r} ${n} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${r} ${n} ${i} = u_${i};\n#endif\n`})),{fragmentSource:t,vertexSource:e,staticAttributes:n,staticUniforms:o}}class on{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,r,n,i,a,o,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!c&&t({u_depth:new e.aI(t,r.u_depth),u_terrain:new e.aI(t,r.u_terrain),u_terrain_dim:new e.aJ(t,r.u_terrain_dim),u_terrain_matrix:new e.aK(t,r.u_terrain_matrix),u_terrain_unpack:new e.aL(t,r.u_terrain_unpack),u_terrain_exaggeration:new e.aJ(t,r.u_terrain_exaggeration)}),ln=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texture:new e.aI(t,r.u_texture),u_ele_delta:new e.aJ(t,r.u_ele_delta),u_fog_matrix:new e.aK(t,r.u_fog_matrix),u_fog_color:new e.aM(t,r.u_fog_color),u_fog_ground_blend:new e.aJ(t,r.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.aJ(t,r.u_fog_ground_blend_opacity),u_horizon_color:new e.aM(t,r.u_horizon_color),u_horizon_fog_blend:new e.aJ(t,r.u_horizon_fog_blend)}),cn=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ele_delta:new e.aJ(t,r.u_ele_delta)}),un=(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texture:new e.aI(t,r.u_texture),u_terrain_coords_id:new e.aJ(t,r.u_terrain_coords_id),u_ele_delta:new e.aJ(t,r.u_ele_delta)}),hn=(t,r,n,i,a)=>({u_matrix:t,u_texture:0,u_ele_delta:r,u_fog_matrix:n,u_fog_color:i?i.properties.get("fog-color"):e.aN.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:i?i.calculateFogBlendOpacity(a):0,u_horizon_color:i?i.properties.get("horizon-color"):e.aN.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1}),fn=(t,e)=>({u_matrix:t,u_ele_delta:e}),pn=(t,e,r)=>({u_matrix:t,u_terrain_coords_id:e/255,u_texture:0,u_ele_delta:r});function dn(t){const e=[];for(let r=0;r>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}function yn(t,e,r,n){const i=r.imageManager.getPattern(t.from.toString()),a=r.imageManager.getPattern(t.to.toString()),{width:o,height:s}=r.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,r.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[o,s],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/_e(n,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}const vn=(t,e,r,n)=>{const i=e.style.light,a=i.properties.get("position"),o=[a.x,a.y,a.z],s=v();"viewport"===i.properties.get("anchor")&&x(s,-e.transform.angle),E(o,o,s);const l=i.properties.get("color");return{u_matrix:t,u_lightpos:o,u_lightintensity:i.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+r,u_opacity:n}},xn=(t,r,n,i,a,o,s)=>e.e(vn(t,r,n,i),gn(o,r,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8}),_n=t=>({u_matrix:t}),bn=(t,r,n,i)=>e.e(_n(t),gn(n,r,i)),wn=(t,e)=>({u_matrix:t,u_world:e}),Tn=(t,r,n,i,a)=>e.e(bn(t,r,n,i),{u_world:a}),kn=(t,e,r,n)=>{const i=t.transform;let a,o;if("map"===n.paint.get("circle-pitch-alignment")){const t=_e(r,1,i.zoom);a=!0,o=[t,t]}else a=!1,o=i.pixelsToGLUnits;return{u_camera_to_center_distance:i.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,r,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:o}},An=(t,e)=>({u_matrix:e,u_pixel_extrude_scale:[1/t.width,1/t.height]}),Mn=(t,e,r)=>({u_matrix:t,u_inv_matrix:e,u_camera_to_center_distance:r.cameraToCenterDistance,u_viewport_size:[r.width,r.height]}),Sn=(t,e,r=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:r}),En=t=>({u_matrix:t}),Cn=(t,e,r,n)=>({u_matrix:t,u_extrude_scale:_e(e,1,r),u_intensity:n}),Ln=(t,r,n,i)=>{const a=e.H();e.aQ(a,0,t.width,t.height,0,0,1);const o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:n,u_color_ramp:i,u_opacity:r.paint.get("heatmap-opacity")}},In=(t,e,r,n)=>{const i=r.paint.get("hillshade-shadow-color"),a=r.paint.get("hillshade-highlight-color"),o=r.paint.get("hillshade-accent-color");let s=r.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===r.paint.get("hillshade-illumination-anchor")&&(s-=t.transform.angle);const l=!t.options.moving;return{u_matrix:n?n.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:zn(t,e.tileID),u_light:[r.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:a,u_accent:o}},Pn=(t,r)=>{const n=r.stride,i=e.H();return e.aQ(i,0,e.X,-e.X,0,0,1),e.J(i,i,[0,-e.X,0]),{u_matrix:i,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:r.getUnpackVector()}};function zn(t,r){const n=Math.pow(2,r.canonical.z),i=r.canonical.y;return[new e.Z(0,i/n).toLngLat().lat,new e.Z(0,(i+1)/n).toLngLat().lat]}const Dn=(t,e,r,n)=>{const i=t.transform;return{u_matrix:Nn(t,e,r,n),u_ratio:1/_e(e,1,i.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/i.pixelsToGLUnits[0],1/i.pixelsToGLUnits[1]]}},On=(t,r,n,i,a)=>e.e(Dn(t,r,n,a),{u_image:0,u_image_height:i}),Rn=(t,e,r,n,i)=>{const a=t.transform,o=Bn(e,a);return{u_matrix:Nn(t,e,r,i),u_texsize:e.imageAtlasTexture.size,u_ratio:1/_e(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Fn=(t,r,n,i,a,o)=>{const s=t.transform,l=t.lineAtlas,c=Bn(r,s),u="round"===n.layout.get("line-cap"),h=l.getDash(i.from,u),f=l.getDash(i.to,u),p=h.width*a.fromScale,d=f.width*a.toScale;return e.e(Dn(t,r,n,o),{u_patternscale_a:[c/p,-h.height/2],u_patternscale_b:[c/d,-f.height/2],u_sdfgamma:l.width/(256*Math.min(p,d)*t.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:f.y,u_mix:a.t})};function Bn(t,e){return 1/_e(t,1,e.tileZoom)}function Nn(t,e,r,n){return t.translatePosMatrix(n?n.posMatrix:e.tileID.posMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const jn=(t,e,r,n,i)=>({u_matrix:t,u_tl_parent:e,u_scale_parent:r,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:qn(i.paint.get("raster-saturation")),u_contrast_factor:Vn(i.paint.get("raster-contrast")),u_spin_weights:Un(i.paint.get("raster-hue-rotate"))});function Un(t){t*=Math.PI/180;const e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}function Vn(t){return t>0?1/(1-t):1+t}function qn(t){return t>0?1-1/(1.001-t):-t}const Hn=(t,e,r,n,i,a,o,s,l,c,u,h,f,p)=>{const d=o.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+r,u_aspect_ratio:d.width/d.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:l,u_coord_matrix:c,u_is_text:+h,u_pitch_with_map:+n,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:f,u_texture:0,u_translation:u,u_pitched_scale:p}},Gn=(t,r,n,i,a,o,s,l,c,u,h,f,p,d,m)=>{const g=s.transform;return e.e(Hn(t,r,n,i,a,o,s,l,c,u,h,f,p,m),{u_gamma_scale:i?Math.cos(g._pitch)*g.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+d})},Wn=(t,r,n,i,a,o,s,l,c,u,h,f,p,d)=>e.e(Gn(t,r,n,i,a,o,s,l,c,u,h,!0,f,!0,d),{u_texsize_icon:p,u_texture_icon:1}),Zn=(t,e,r)=>({u_matrix:t,u_opacity:e,u_color:r}),Yn=(t,r,n,i,a,o)=>e.e(yn(i,o,n,a),{u_matrix:t,u_opacity:r}),Xn=(t,e,r)=>({u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:(e.height/2+e.getHorizon())*r,u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*r}),$n={fillExtrusion:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_lightpos:new e.aO(t,r.u_lightpos),u_lightintensity:new e.aJ(t,r.u_lightintensity),u_lightcolor:new e.aO(t,r.u_lightcolor),u_vertical_gradient:new e.aJ(t,r.u_vertical_gradient),u_opacity:new e.aJ(t,r.u_opacity)}),fillExtrusionPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_lightpos:new e.aO(t,r.u_lightpos),u_lightintensity:new e.aJ(t,r.u_lightintensity),u_lightcolor:new e.aO(t,r.u_lightcolor),u_vertical_gradient:new e.aJ(t,r.u_vertical_gradient),u_height_factor:new e.aJ(t,r.u_height_factor),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade),u_opacity:new e.aJ(t,r.u_opacity)}),fill:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix)}),fillPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),fillOutline:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world)}),fillOutlinePattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world),u_image:new e.aI(t,r.u_image),u_texsize:new e.aP(t,r.u_texsize),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),circle:(t,r)=>({u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_scale_with_map:new e.aI(t,r.u_scale_with_map),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_extrude_scale:new e.aP(t,r.u_extrude_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_matrix:new e.aK(t,r.u_matrix)}),collisionBox:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_pixel_extrude_scale:new e.aP(t,r.u_pixel_extrude_scale)}),collisionCircle:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_inv_matrix:new e.aK(t,r.u_inv_matrix),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_viewport_size:new e.aP(t,r.u_viewport_size)}),debug:(t,r)=>({u_color:new e.aM(t,r.u_color),u_matrix:new e.aK(t,r.u_matrix),u_overlay:new e.aI(t,r.u_overlay),u_overlay_scale:new e.aJ(t,r.u_overlay_scale)}),clippingMask:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix)}),heatmap:(t,r)=>({u_extrude_scale:new e.aJ(t,r.u_extrude_scale),u_intensity:new e.aJ(t,r.u_intensity),u_matrix:new e.aK(t,r.u_matrix)}),heatmapTexture:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_world:new e.aP(t,r.u_world),u_image:new e.aI(t,r.u_image),u_color_ramp:new e.aI(t,r.u_color_ramp),u_opacity:new e.aJ(t,r.u_opacity)}),hillshade:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_latrange:new e.aP(t,r.u_latrange),u_light:new e.aP(t,r.u_light),u_shadow:new e.aM(t,r.u_shadow),u_highlight:new e.aM(t,r.u_highlight),u_accent:new e.aM(t,r.u_accent)}),hillshadePrepare:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_image:new e.aI(t,r.u_image),u_dimension:new e.aP(t,r.u_dimension),u_zoom:new e.aJ(t,r.u_zoom),u_unpack:new e.aL(t,r.u_unpack)}),line:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels)}),lineGradient:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_image:new e.aI(t,r.u_image),u_image_height:new e.aJ(t,r.u_image_height)}),linePattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_texsize:new e.aP(t,r.u_texsize),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_image:new e.aI(t,r.u_image),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_scale:new e.aO(t,r.u_scale),u_fade:new e.aJ(t,r.u_fade)}),lineSDF:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_ratio:new e.aJ(t,r.u_ratio),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.aP(t,r.u_units_to_pixels),u_patternscale_a:new e.aP(t,r.u_patternscale_a),u_patternscale_b:new e.aP(t,r.u_patternscale_b),u_sdfgamma:new e.aJ(t,r.u_sdfgamma),u_image:new e.aI(t,r.u_image),u_tex_y_a:new e.aJ(t,r.u_tex_y_a),u_tex_y_b:new e.aJ(t,r.u_tex_y_b),u_mix:new e.aJ(t,r.u_mix)}),raster:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_tl_parent:new e.aP(t,r.u_tl_parent),u_scale_parent:new e.aJ(t,r.u_scale_parent),u_buffer_scale:new e.aJ(t,r.u_buffer_scale),u_fade_t:new e.aJ(t,r.u_fade_t),u_opacity:new e.aJ(t,r.u_opacity),u_image0:new e.aI(t,r.u_image0),u_image1:new e.aI(t,r.u_image1),u_brightness_low:new e.aJ(t,r.u_brightness_low),u_brightness_high:new e.aJ(t,r.u_brightness_high),u_saturation_factor:new e.aJ(t,r.u_saturation_factor),u_contrast_factor:new e.aJ(t,r.u_contrast_factor),u_spin_weights:new e.aO(t,r.u_spin_weights)}),symbolIcon:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texture:new e.aI(t,r.u_texture),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),symbolSDF:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texture:new e.aI(t,r.u_texture),u_gamma_scale:new e.aJ(t,r.u_gamma_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_is_halo:new e.aI(t,r.u_is_halo),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),symbolTextAndIcon:(t,r)=>({u_is_size_zoom_constant:new e.aI(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aI(t,r.u_is_size_feature_constant),u_size_t:new e.aJ(t,r.u_size_t),u_size:new e.aJ(t,r.u_size),u_camera_to_center_distance:new e.aJ(t,r.u_camera_to_center_distance),u_pitch:new e.aJ(t,r.u_pitch),u_rotate_symbol:new e.aI(t,r.u_rotate_symbol),u_aspect_ratio:new e.aJ(t,r.u_aspect_ratio),u_fade_change:new e.aJ(t,r.u_fade_change),u_matrix:new e.aK(t,r.u_matrix),u_label_plane_matrix:new e.aK(t,r.u_label_plane_matrix),u_coord_matrix:new e.aK(t,r.u_coord_matrix),u_is_text:new e.aI(t,r.u_is_text),u_pitch_with_map:new e.aI(t,r.u_pitch_with_map),u_is_along_line:new e.aI(t,r.u_is_along_line),u_is_variable_anchor:new e.aI(t,r.u_is_variable_anchor),u_texsize:new e.aP(t,r.u_texsize),u_texsize_icon:new e.aP(t,r.u_texsize_icon),u_texture:new e.aI(t,r.u_texture),u_texture_icon:new e.aI(t,r.u_texture_icon),u_gamma_scale:new e.aJ(t,r.u_gamma_scale),u_device_pixel_ratio:new e.aJ(t,r.u_device_pixel_ratio),u_is_halo:new e.aI(t,r.u_is_halo),u_translation:new e.aP(t,r.u_translation),u_pitched_scale:new e.aJ(t,r.u_pitched_scale)}),background:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_opacity:new e.aJ(t,r.u_opacity),u_color:new e.aM(t,r.u_color)}),backgroundPattern:(t,r)=>({u_matrix:new e.aK(t,r.u_matrix),u_opacity:new e.aJ(t,r.u_opacity),u_image:new e.aI(t,r.u_image),u_pattern_tl_a:new e.aP(t,r.u_pattern_tl_a),u_pattern_br_a:new e.aP(t,r.u_pattern_br_a),u_pattern_tl_b:new e.aP(t,r.u_pattern_tl_b),u_pattern_br_b:new e.aP(t,r.u_pattern_br_b),u_texsize:new e.aP(t,r.u_texsize),u_mix:new e.aJ(t,r.u_mix),u_pattern_size_a:new e.aP(t,r.u_pattern_size_a),u_pattern_size_b:new e.aP(t,r.u_pattern_size_b),u_scale_a:new e.aJ(t,r.u_scale_a),u_scale_b:new e.aJ(t,r.u_scale_b),u_pixel_coord_upper:new e.aP(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.aP(t,r.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aJ(t,r.u_tile_units_to_pixels)}),terrain:ln,terrainDepth:cn,terrainCoords:un,sky:(t,r)=>({u_sky_color:new e.aM(t,r.u_sky_color),u_horizon_color:new e.aM(t,r.u_horizon_color),u_horizon:new e.aJ(t,r.u_horizon),u_sky_horizon_blend:new e.aJ(t,r.u_sky_horizon_blend)})};class Jn{constructor(t,e,r){this.context=t;const n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){const t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}}const Kn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qn{constructor(t,e,r,n){this.length=e.length,this.attributes=r,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;const i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let r=0;r0){const r=e.H();e.aR(r,d.placementInvProjMatrix,t.transform.glCoordMatrix),e.aR(r,r,d.placementViewportMatrix),c.push({circleArray:g,circleOffset:h,transform:p.posMatrix,invTransform:r,coord:p}),u+=g.length/4,h=u}m&&l.draw(o,s.LINES,Gi.disabled,Yi.disabled,t.colorModeForRenderPass(),Ji.disabled,An(t.transform,p.posMatrix),t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!a||!c.length)return;const f=t.useProgram("collisionCircle"),p=new e.aS;p.resize(4*u),p._trim();let d=0;for(const t of c)for(let e=0;er.style.map.terrain.getElevation(a,t,e):null,i=h.translatePosition(u,t,s,l);oa(o,f,p,c,u,y,a.posMatrix,e,m,v,h,i,a.toUnwrapped(),n)}}}function aa(t,r,n,i,a,o){const s=r.tileAnchorPoint.add(new e.P(r.translation[0],r.translation[1]));if(r.pitchWithMap){let t=i.mult(o);return n||(t=t.rotate(-a)),te(s.add(t),r.labelPlaneMatrix,r.getElevation).point}if(n){const e=he(r.tileAnchorPoint.x+1,r.tileAnchorPoint.y,r).point.sub(t),n=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(i.rotate(n))}return t.add(i)}function oa(t,r,n,i,a,o,s,l,c,u,h,f,p,d){const m=t.text.placedSymbolArray,g=t.text.dynamicLayoutVertexArray,y=t.icon.dynamicLayoutVertexArray,v={};g.clear();for(let y=0;y=0&&(v[x.associatedIconIndex]={shiftedAnchor:L,angle:I})}else ge(x.numGlyphs,g)}if(u){y.clear();const r=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(l,e,r):null,r="map"===n.layout.get("text-rotation-alignment");ne(c,l.posMatrix,t,a,j,V,v,u,r,g,l.toUnwrapped(),m.width,m.height,q,e)}const W=l.posMatrix,Z=a&&A||G,Y=x||Z?ea:j,X=U,$=p&&0!==n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let J;J=p?c.iconsInText?Wn(k.kind,L,_,v,x,Z,t,W,Y,X,q,P,R,S):Gn(k.kind,L,_,v,x,Z,t,W,Y,X,q,a,P,!0,S):Hn(k.kind,L,_,v,x,Z,t,W,Y,X,q,a,P,S);const K={program:C,buffers:h,uniformValues:J,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:D,atlasInterpolationIcon:O,isSDF:p,hasHalo:$};if(w&&c.canOverlap){T=!0;const t=h.segments.get();for(const r of t)M.push({segments:new e.a0([r]),sortKey:r.sortKey,state:K,terrainData:I})}else M.push({segments:h.segments,sortKey:0,state:K,terrainData:I})}T&&M.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of M){const r=e.state;if(p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),r.isSDF){const i=r.uniformValues;r.hasHalo&&(i.u_is_halo=1,ca(r.buffers,e.segments,n,t,r.program,k,h,f,i,e.terrainData)),i.u_is_halo=0}ca(r.buffers,e.segments,n,t,r.program,k,h,f,r.uniformValues,e.terrainData)}}function ca(t,e,r,n,i,a,o,s,l,c){const u=n.context,h=u.gl;i.draw(u,h.TRIANGLES,a,o,s,Ji.disabled,l,c,r.id,t.layoutVertexBuffer,t.indexBuffer,e,r.paint,n.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ua(t,r,n,i){if("translucent"!==t.renderPass)return;const a=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),s=n.paint.get("circle-stroke-opacity"),l=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=t.context,u=c.gl,h=t.depthModeForSublayer(0,Gi.ReadOnly),f=Yi.disabled,p=t.colorModeForRenderPass(),d=[];for(let a=0;at.sortKey-e.sortKey));for(const e of d){const{programConfiguration:r,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:l}=e.state,d=e.segments;i.draw(c,u.TRIANGLES,h,f,p,Ji.disabled,s,l,n.id,a,o,d,n.paint,t.transform.zoom,r)}}function ha(t,r,n,i){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const a=t.context,o=a.gl,s=Yi.disabled,l=new Vi([o.ONE,o.ONE],e.aN.transparent,[!0,!0,!0,!0]);fa(a,t,n),a.clear({color:e.aN.transparent});for(let e=0;e20&&a.texParameterf(a.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax);const _=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n),b=_?n:null,w=b?b.posMatrix:t.transform.calculatePosMatrix(n.toUnwrapped(),f),T=jn(w,v||[0,0],y||1,g,r);o instanceof Et?s.draw(i,a.TRIANGLES,u,Yi.disabled,l,Ji.disabled,T,_,r.id,o.boundsBuffer,t.quadTriangleIndexBuffer,o.boundsSegments):s.draw(i,a.TRIANGLES,u,c[n.overscaledZ],l,Ji.disabled,T,_,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}}function Aa(t,r,n,i,o,s){const l=i.paint.get("raster-fade-duration");if(!s&&l>0){const i=a.now(),s=(i-t.timeAdded)/l,c=r?(i-r.timeAdded)/l:-1,u=n.getSource(),h=o.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),f=!r||Math.abs(r.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),p=f&&t.refreshedUponExpiration?1:e.ad(f?s:1-c,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}function Ma(t,e,r,n){const i=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const o=t.context,s=o.gl,l=t.transform,c=l.tileSize,u=r.paint.get("background-pattern");if(t.isPatternMissing(u))return;const h=!u&&1===i.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==h)return;const f=Yi.disabled,p=t.depthModeForSublayer(0,"opaque"===h?Gi.ReadWrite:Gi.ReadOnly),d=t.colorModeForRenderPass(),m=t.useProgram(u?"backgroundPattern":"background"),g=n||l.coveringTiles({tileSize:c,terrain:t.style.map.terrain});u&&(o.activeTexture.set(s.TEXTURE0),t.imageManager.bind(t.context));const y=r.getCrossfadeParameters();for(const e of g){const l=n?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),h=u?Yn(l,a,t,u,{tileID:e,tileSize:c},y):Zn(l,a,i),g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);m.draw(o,s.TRIANGLES,p,f,d,Ji.disabled,h,g,r.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}}const Sa=new e.aN(1,0,0,1),Ea=new e.aN(0,1,0,1),Ca=new e.aN(0,0,1,1),La=new e.aN(1,0,1,1),Ia=new e.aN(0,1,1,1);function Pa(t){const e=t.transform.padding,r=3;Da(t,t.transform.height-(e.top||0),r,Sa),Da(t,e.bottom||0,r,Ea),Oa(t,e.left||0,r,Ca),Oa(t,t.transform.width-(e.right||0),r,La);const n=t.transform.centerPoint;za(t,n.x,t.transform.height-n.y,Ia)}function za(t,e,r,n){const i=20,a=2;Ra(t,e-a/2,r-i/2,a,i,n),Ra(t,e-i/2,r-a/2,i,a,n)}function Da(t,e,r,n){Ra(t,0,e+r/2,t.transform.width,r,n)}function Oa(t,e,r,n){Ra(t,e-r/2,0,r,t.transform.height,n)}function Ra(t,e,r,n,i,a){const o=t.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio,i*t.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Fa(t,e,r){for(let n=0;n ${n.overscaledZ}`),Na(t,`${v} ${m}kB`),s.draw(i,a.TRIANGLES,l,c,Vi.alphaBlended,Ji.disabled,Sn(o,e.aN.transparent,y),null,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(i,a.LINE_STRIP,l,c,u,Ji.disabled,Sn(o,e.aN.red),f,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Na(t,e){t.initDebugOverlayCanvas();const r=t.debugOverlayCanvas,n=t.context.gl,i=t.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,r.width,r.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(e,5,5),i.strokeText(e,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}function ja(t,e){let r=null;const n=Object.values(t._layers).flatMap((r=>r.source&&!r.isHidden(e)?[t.sourceCaches[r.source]]:[])),i=n.filter((t=>"vector"===t.getSource().type)),a=n.filter((t=>"vector"!==t.getSource().type)),o=t=>{(!r||r.getSource().maxzoomo(t))),r||a.forEach((t=>o(t))),r}function Ua(t,e,r){const n=t.context,i=r.implementation;if("offscreen"===t.renderPass){const e=i.prerender;e&&(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),e.call(i,n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(Yi.disabled);const e="3d"===i.renderingMode?new Gi(t.context.gl.LEQUAL,Gi.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Gi.ReadOnly);n.setDepthMode(e),i.render(n.gl,t.transform.customLayerMatrix(),{farZ:t.transform.farZ,nearZ:t.transform.nearZ,fov:t.transform._fov,modelViewProjectionMatrix:t.transform.modelViewProjectionMatrix,projectionMatrix:t.transform.projectionMatrix}),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}}function Va(t,r){const n=t.context,i=n.gl,a=Vi.unblended,o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=r.getTerrainMesh(),l=r.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");n.bindFramebuffer.set(r.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aN.transparent,depth:1});for(const e of l){const l=r.getTerrainData(e.tileID),u=t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),h=fn(u,r.getMeshFrameDelta(t.transform.zoom));c.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,h,l,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}function qa(t,r){const n=t.context,i=n.gl,a=Vi.unblended,o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=r.getTerrainMesh(),l=r.getCoordsTexture(),c=r.sourceCache.getRenderableTiles(),u=t.useProgram("terrainCoords");n.bindFramebuffer.set(r.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aN.transparent,depth:1}),r.coordsIndex=[];for(const e of c){const c=r.getTerrainData(e.tileID);n.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,l.texture);const h=t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),f=pn(h,255-r.coordsIndex.length,r.getMeshFrameDelta(t.transform.zoom));u.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,f,c,"terrain",s.vertexBuffer,s.indexBuffer,s.segments),r.coordsIndex.push(e.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}function Ha(t,e,r){const n=t.context,i=n.gl,a=t.colorModeForRenderPass(),o=new Gi(i.LEQUAL,Gi.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh();n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]);for(const c of r){const r=t.renderToTexture.getTexture(c),u=e.getTerrainData(c.tileID);n.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,r.texture);const h=t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),f=e.getMeshFrameDelta(t.transform.zoom),p=t.transform.calculateFogMatrix(c.tileID.toUnwrapped()),d=hn(h,f,p,t.style.sky,t.transform.pitch);s.draw(n,i.TRIANGLES,o,Yi.disabled,a,Ji.backCCW,d,u,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class Ga{constructor(t,e,r){this.vertexBuffer=t,this.indexBuffer=e,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}function Wa(t,r){const n=t.context,i=n.gl,a=Xn(r,t.style.map.transform,t.pixelRatio),o=new Gi(i.LEQUAL,Gi.ReadWrite,[0,1]),s=Yi.disabled,l=t.colorModeForRenderPass(),c=t.useProgram("sky");if(!r.mesh){const t=new e.aX;t.emplaceBack(-1,-1),t.emplaceBack(1,-1),t.emplaceBack(1,1),t.emplaceBack(-1,1);const i=new e.aY;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),r.mesh=new Ga(n.createVertexBuffer(t,Ke.members),n.createIndexBuffer(i),e.a0.simpleSegment(0,0,t.length,i.length))}c.draw(n,i.TRIANGLES,o,s,l,Ji.disabled,a,void 0,"sky",r.mesh.vertexBuffer,r.mesh.indexBuffer,r.mesh.segments)}class Za{constructor(t,r){this.context=new qi(t),this.transform=r,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Wt.maxUnderzooming+Wt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ye}resize(t,e,r){if(this.width=Math.floor(t*r),this.height=Math.floor(e*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,r=new e.aX;r.emplaceBack(0,0),r.emplaceBack(e.X,0),r.emplaceBack(0,e.X),r.emplaceBack(e.X,e.X),this.tileExtentBuffer=t.createVertexBuffer(r,Ke.members),this.tileExtentSegments=e.a0.simpleSegment(0,0,4,2);const n=new e.aX;n.emplaceBack(0,0),n.emplaceBack(e.X,0),n.emplaceBack(0,e.X),n.emplaceBack(e.X,e.X),this.debugBuffer=t.createVertexBuffer(n,Ke.members),this.debugSegments=e.a0.simpleSegment(0,0,4,5);const i=new e.$;i.emplaceBack(0,0,0,0),i.emplaceBack(e.X,0,e.X,0),i.emplaceBack(0,e.X,0,e.X),i.emplaceBack(e.X,e.X,e.X,e.X),this.rasterBoundsBuffer=t.createVertexBuffer(i,St.members),this.rasterBoundsSegments=e.a0.simpleSegment(0,0,4,2);const a=new e.aX;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(a,Ke.members),this.viewportSegments=e.a0.simpleSegment(0,0,4,2);const o=new e.aZ;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);const s=new e.aY;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const l=this.context.gl;this.stencilClearMode=new Yi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}clearStencil(){const t=this.context,r=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=e.H();e.aQ(n,0,this.width,this.height,0,0,1),e.K(n,n,[r.drawingBufferWidth,r.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,r.TRIANGLES,Gi.disabled,this.stencilClearMode,Vi.disabled,Ji.disabled,En(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const r=this.context,n=r.gl;this.nextStencilID+e.length>256&&this.clearStencil(),r.setColorMode(Vi.disabled),r.setDepthMode(Gi.disabled);const i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);i.draw(r,n.TRIANGLES,Gi.disabled,new Yi({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Vi.disabled,Ji.disabled,En(t.posMatrix),a,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Yi({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Yi({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,r=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=r[r.length-1].overscaledZ,i=r[0].overscaledZ-n+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],e=o[t.source],r=s[t.source];this._renderTileClippingMasks(t,r),this.renderLayer(this,e,t,r)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer0),i&&(e.b0(r,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,Va(this,this.style.map.terrain),qa(this,this.style.map.terrain))}renderLayer(t,e,r,n){if(!r.isHidden(this.transform.zoom)&&("background"===r.type||"custom"===r.type||(n||[]).length))switch(this.id=r.id,r.type){case"symbol":ra(t,e,r,n,this.style.placement.variableOffsets);break;case"circle":ua(t,e,r,n);break;case"heatmap":ha(t,e,r,n);break;case"line":ma(t,e,r,n);break;case"fill":ya(t,e,r,n);break;case"fill-extrusion":xa(t,e,r,n);break;case"hillshade":ba(t,e,r,n);break;case"raster":ka(t,e,r,n);break;case"background":Ma(t,e,r,n);break;case"custom":Ua(t,e,r)}}translatePosMatrix(t,r,n,i,a){if(!n[0]&&!n[1])return t;const o=a?"map"===i?this.transform.angle:0:"viewport"===i?-this.transform.angle:0;if(o){const t=Math.sin(o),e=Math.cos(o);n=[n[0]*e-n[1]*t,n[0]*t+n[1]*e]}const s=[a?n[0]:_e(r,n[0],this.transform.zoom),a?n[1]:_e(r,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.J(l,t,s),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),r=this.imageManager.getPattern(t.to.toString());return!e||!r}useProgram(t,e){this.cache=this.cache||{};const r=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[r]||(this.cache[r]=new mn(this.context,nn[t],e,$n[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[r]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;const t=this.context.gl;this.debugOverlayTexture=new B(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class Ya{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,r,n){const i=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]],a=Math.pow(2,n),o=i.map((n=>{const i=1/(n=e.ag([],n,t))[3]/r*a;return e.b1(n,n,[i,i,1/n[3],i])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=A([],S([],C([],o[t[0]],o[t[1]]),C([],o[t[2]],o[t[1]]))),r=-M(e,o[t[1]]);return e.concat(r)}));return new Ya(o,s)}}class Xa{constructor(t,e){this.min=t,this.max=e,this.center=k([],w([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],r=b(this.min),n=b(this.max);for(let t=0;t=0&&o++;if(0===o)return 0;o!==r.length&&(n=!1)}if(n)return 2;for(let e=0;e<3;e++){let r=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let i=0;ithis.max[e]-this.min[e])return 0}return 1}}class $a{constructor(t=0,e=0,r=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(r)||r<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=r,this.right=n}interpolate(t,r,n){return null!=r.top&&null!=t.top&&(this.top=e.z.number(t.top,r.top,n)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.z.number(t.bottom,r.bottom,n)),null!=r.left&&null!=t.left&&(this.left=e.z.number(t.left,r.left,n)),null!=r.right&&null!=t.right&&(this.right=e.z.number(t.right,r.right,n)),this}getCenter(t,r){const n=e.ad((this.left+t-this.right)/2,0,t),i=e.ad((this.top+r-this.bottom)/2,0,r);return new e.P(n,i)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new $a(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Ja=85.051129;class Ka{constructor(t,r,n,i,a){this.tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=null==n?0:n,this._maxPitch=null==i?60:i,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new $a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new Ka(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const r=-e.b3(t,-180,180)*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=g(),y(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=e.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,r){this._unmodified=!1,this._edgeInsets.interpolate(t,e,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const r=[new e.b4(0,t)];if(this._renderWorldCopies){const n=this.pointCoordinate(new e.P(0,0)),i=this.pointCoordinate(new e.P(this.width,0)),a=this.pointCoordinate(new e.P(this.width,this.height)),o=this.pointCoordinate(new e.P(0,this.height)),s=Math.floor(Math.min(n.x,i.x,a.x,o.x)),l=Math.floor(Math.max(n.x,i.x,a.x,o.x)),c=1;for(let n=s-c;n<=l+c;n++)0!==n&&r.push(new e.b4(n,t))}return r}coveringTiles(t){var r,n;let i=this.coveringZoomLevel(t);const a=i;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const o=this.pointCoordinate(this.getCameraPoint()),s=e.Z.fromLngLat(this.center),l=Math.pow(2,i),c=[l*o.x,l*o.y,0],u=[l*s.x,l*s.y,0],h=Ya.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,i);let f=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(f=i);const p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,d=t=>({aabb:new Xa([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],g=[],y=i,v=t.reparseOverscaled?a:i;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(d(-t)),m.push(d(t));for(m.push(d(0));m.length>0;){const i=m.pop(),a=i.x,o=i.y;let s=i.fullyVisible;if(!s){const t=i.aabb.intersects(h);if(0===t)continue;s=2===t}const l=t.terrain?c:u,d=i.aabb.distanceX(l),x=i.aabb.distanceY(l),_=Math.max(Math.abs(d),Math.abs(x)),b=p+(1<b&&i.zoom>=f){const t=y-i.zoom,r=c[0]-.5-(a<>1),h=i.zoom+1;let f=i.aabb.quadrant(l);if(t.terrain){const a=new e.S(h,i.wrap,h,c,u),o=t.terrain.getMinMaxElevation(a),s=null!==(r=o.minElevation)&&void 0!==r?r:this.elevation,l=null!==(n=o.maxElevation)&&void 0!==n?n:this.elevation;f=new Xa([f.min[0],f.min[1],s],[f.max[0],f.max[1],l])}m.push({aabb:f,zoom:h,x:c,y:u,wrap:i.wrap,fullyVisible:s})}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const r=e.ad(t.lat,-Ja,Ja);return new e.P(e.O(t.lng)*this.worldSize,e.Q(r)*this.worldSize)}unproject(t){return new e.Z(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const r=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,i=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(i,this.tileZoom);if(!(this.elevation-a))return;const o=n+r-a,s=Math.cos(this._pitch)*this.cameraToCenterDistance/o/e.b5(1,i.lat)/this.tileSize,l=this.scaleZoom(s);this._elevation=a,this._center=i,this.zoom=l}setLocationAtPoint(t,r){const n=this.pointCoordinate(r),i=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(t),o=new e.Z(a.x-(n.x-i.x),a.y-(n.y-i.y));this.center=this.coordinateLocation(o),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,r){if(r){const e=r.pointCoordinate(t);if(null!=e)return e}const n=0,i=[t.x,t.y,0,1],a=[t.x,t.y,1,1];e.ag(i,i,this.pixelMatrixInverse),e.ag(a,a,this.pixelMatrixInverse);const o=i[3],s=a[3],l=i[0]/o,c=a[0]/s,u=i[1]/o,h=a[1]/s,f=i[2]/o,p=a[2]/s,d=f===p?0:(n-f)/(p-f);return new e.Z(e.z.number(l,c,d)/this.worldSize,e.z.number(u,h,d)/this.worldSize)}coordinatePoint(t,r=0,n=this.pixelMatrix){const i=[t.x*this.worldSize,t.y*this.worldSize,r,1];return e.ag(i,i,n),new e.P(i[0]/i[3],i[1]/i[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new bt).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new bt([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-Ja,Ja])}calculateTileMatrix(t){const r=t.canonical,n=this.worldSize/this.zoomScale(r.z),i=r.x+Math.pow(2,r.z)*t.wrap,a=e.ao(new Float64Array(16));return e.J(a,a,[i*n,r.y*n,0]),e.K(a,a,[n/e.X,n/e.X,1]),a}calculatePosMatrix(t,r=!1){const n=t.key,i=r?this._alignedPosMatrixCache:this._posMatrixCache;if(i[n])return i[n];const a=this.calculateTileMatrix(t);return e.L(a,r?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,a),i[n]=new Float32Array(a),i[n]}calculateFogMatrix(t){const r=t.key,n=this._fogMatrixCache;if(n[r])return n[r];const i=this.calculateTileMatrix(t);return e.L(i,this.fogMatrix,i),n[r]=new Float32Array(i),n[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,r){r=e.ad(+r,this.minZoom,this.maxZoom);const n={center:new e.N(t.lng,t.lat),zoom:r};let i=this.lngRange;if(!this._renderWorldCopies&&null===i){const t=180-1e-10;i=[-t,t]}const a=this.tileSize*this.zoomScale(n.zoom);let o=0,s=a,l=0,c=a,u=0,h=0;const{x:f,y:p}=this.size;if(this.latRange){const t=this.latRange;o=e.Q(t[1])*a,s=e.Q(t[0])*a,s-os&&(y=s-t)}if(i){const t=(l+c)/2;let r=d;this._renderWorldCopies&&(r=e.b3(d,t-a/2,t+a/2));const n=f/2;r-nc&&(g=c-n)}if(void 0!==g||void 0!==y){const t=new e.P(null!=g?g:d,null!=y?y:m);n.center=this.unproject.call({worldSize:a},t).wrap()}return n}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:r}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=r,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this._fov/2,r=this.centerOffset,n=this.point.x,i=this.point.y;this.cameraToCenterDistance=.5/Math.tan(t)*this.height,this._pixelPerMeter=e.b5(1,this.center.lat)*this.worldSize;let a=e.ao(new Float64Array(16));e.K(a,a,[this.width/2,-this.height/2,1]),e.J(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=e.ao(new Float64Array(16)),e.K(a,a,[1,-1,1]),e.J(a,a,[-1,-1,0]),e.K(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;const o=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),s=Math.min(this.elevation,this.minElevationForCurrentTile),l=o-s*this._pixelPerMeter/Math.cos(this._pitch),c=s<0?l:o,u=Math.PI/2+this._pitch,h=this._fov*(.5+r.y/this.height),f=Math.sin(h)*c/Math.sin(e.ad(Math.PI-u-h,.01,Math.PI-.01)),p=this.getHorizon(),d=2*Math.atan(p/this.cameraToCenterDistance)*(.5+r.y/(2*p)),m=Math.sin(d)*c/Math.sin(e.ad(Math.PI-u-d,.01,Math.PI-.01)),g=Math.min(f,m);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*g+c),this.nearZ=this.height/50,a=new Float64Array(16),e.b6(a,this._fov,this.width/this.height,this.nearZ,this.farZ),a[8]=2*-r.x/this.width,a[9]=2*r.y/this.height,this.projectionMatrix=e.af(a),e.K(a,a,[1,-1,1]),e.J(a,a,[0,0,-this.cameraToCenterDistance]),e.b7(a,a,this._pitch),e.ae(a,a,this.angle),e.J(a,a,[-n,-i,0]),this.mercatorMatrix=e.K([],a,[this.worldSize,this.worldSize,this.worldSize]),e.K(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.L(new Float64Array(16),this.labelPlaneMatrix,a),e.J(a,a,[0,0,-this.elevation]),this.modelViewProjectionMatrix=a,this.invModelViewProjectionMatrix=e.at([],a),this.fogMatrix=new Float64Array(16),e.b6(this.fogMatrix,this._fov,this.width/this.height,o,this.farZ),this.fogMatrix[8]=2*-r.x/this.width,this.fogMatrix[9]=2*r.y/this.height,e.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),e.b7(this.fogMatrix,this.fogMatrix,this._pitch),e.ae(this.fogMatrix,this.fogMatrix,this.angle),e.J(this.fogMatrix,this.fogMatrix,[-n,-i,0]),e.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=e.L(new Float64Array(16),this.labelPlaneMatrix,a);const y=this.width%2/2,v=this.height%2/2,x=Math.cos(this.angle),_=Math.sin(this.angle),b=n-Math.round(n)+x*y+_*v,w=i-Math.round(i)+x*v+_*y,T=new Float64Array(a);if(e.J(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedModelViewProjectionMatrix=T,a=e.at(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new e.P(0,0)),r=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.ag(r,r,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=this._pitch,r=Math.tan(t)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,r))}getCameraQueryGeometry(t){const r=this.getCameraPoint();if(1===t.length)return[t[0],r];{let n=r.x,i=r.y,a=r.x,o=r.y;for(const e of t)n=Math.min(n,e.x),i=Math.min(i,e.y),a=Math.max(a,e.x),o=Math.max(o,e.y);return[new e.P(n,i),new e.P(a,i),new e.P(a,o),new e.P(n,o),new e.P(n,i)]}}lngLatToCameraDepth(t,r){const n=this.locationCoordinate(t),i=[n.x*this.worldSize,n.y*this.worldSize,r,1];return e.ag(i,i,this.modelViewProjectionMatrix),i[2]/i[3]}}function Qa(t,e){let r,n=!1,i=null,a=null;const o=()=>{i=null,n&&(t.apply(a,r),i=setTimeout(o,e),n=!1)};return(...t)=>(n=!0,a=this,r=t,i||o(),i)}class to{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.+)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let r=e;r.split("&").length>0&&(r=r.split("&")[0]),this._hashName&&(r=`${this._hashName}=${e}`);let n=window.location.hash.replace(r,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let i=window.location.href.replace(/(#.+)?$/,n);i=i.replace("&&","&"),window.history.replaceState(window.history.state,null,i)},this._updateHash=Qa(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.pow(10,n),a=Math.round(e.lng*i)/i,o=Math.round(e.lat*i)/i,s=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${a}/${o}/${r}`:`${r}/${o}/${a}`,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const r=window.location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===t?(e=!0,`${n}=${c}`):r})).filter((t=>t));return e||r.push(`${t}=${c}`),`#${r.join("&")}`}return`#${c}`}}const eo={linearity:.3,easing:e.b8(0,0,.3,1)},ro=e.e({deceleration:2500,maxSpeed:1400},eo),no=e.e({deceleration:20,maxSpeed:1400},eo),io=e.e({deceleration:1e3,maxSpeed:360},eo),ao=e.e({deceleration:1e3,maxSpeed:90},eo);class oo{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=a.now(),r=160;for(;t.length>0&&e-t[0].time>r;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)r.zoom+=t.zoomDelta||0,r.bearing+=t.bearingDelta||0,r.pitch+=t.pitchDelta||0,t.panDelta&&r.pan._add(t.panDelta),t.around&&(r.around=t.around),t.pinchAround&&(r.pinchAround=t.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(r.pan.mag()){const a=lo(r.pan.mag(),n,e.e({},ro,t||{}));i.offset=r.pan.mult(a.amount/r.pan.mag()),i.center=this._map.transform.center,so(i,a)}if(r.zoom){const t=lo(r.zoom,n,no);i.zoom=this._map.transform.zoom+t.amount,so(i,t)}if(r.bearing){const t=lo(r.bearing,n,io);i.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),so(i,t)}if(r.pitch){const t=lo(r.pitch,n,ao);i.pitch=this._map.transform.pitch+t.amount,so(i,t)}if(i.zoom||i.bearing){const t=void 0===r.pinchAround?r.around:r.pinchAround;i.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(i,{noMoveStart:!0})}}function so(t,e){(!t.duration||t.durationr.unproject(t))),l=a.reduce(((t,e,r,n)=>t.add(e.div(n.length))),new e.P(0,0));super(t,{points:a,point:l,lngLats:s,lngLat:r.unproject(l),originalEvent:n}),this._defaultPrevented=!1}}class ho extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,r){super(t,{originalEvent:r}),this._defaultPrevented=!1}}class fo{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new ho(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new co(t.type,this._map,t))}mouseup(t){this._map.fire(new co(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new co(t.type,this._map,t))}dblclick(t){return this._firePreventable(new co(t.type,this._map,t))}mouseover(t){this._map.fire(new co(t.type,this._map,t))}mouseout(t){this._map.fire(new co(t.type,this._map,t))}touchstart(t){return this._firePreventable(new uo(t.type,this._map,t))}touchmove(t){this._map.fire(new uo(t.type,this._map,t))}touchend(t){this._map.fire(new uo(t.type,this._map,t))}touchcancel(t){this._map.fire(new uo(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class po{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new co(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new co("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new co(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class mo{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class go{constructor(t,e){this._map=t,this._tr=new mo(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(o.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const r=e;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)t.fitScreenCoordinates(n,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(o.remove(this._box),this._box=null),o.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new e.k(t,{originalEvent:r}))}}function yo(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const r={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=vo(e),this.touches=yo(r,e)))}touchmove(t,e,r){if(this.aborted||!this.centroid)return;const n=yo(r,e);for(const t in this.touches){const e=this.touches[t],r=n[t];(!r||r.dist(e)>bo)&&(this.aborted=!0)}}touchend(t,e,r){if((!this.centroid||t.timeStamp-this.startTime>_o)&&(this.aborted=!0),0===r.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class To{constructor(t){this.singleTap=new wo(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,r){this.singleTap.touchstart(t,e,r)}touchmove(t,e,r){this.singleTap.touchmove(t,e,r)}touchend(t,e,r){const n=this.singleTap.touchend(t,e,r);if(n){const e=t.timeStamp-this.lastTimethis.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(n)},{originalEvent:t})}):i?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(i)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ao{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const r=this._lastPoint;if(!r)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const n=e.length?e[0]:e;return!this._moved&&n.dist(r){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}},Oo=({enable:t,clickTolerance:e})=>{const r=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&!t.ctrlKey});return new Ao({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:r,enable:t,assignEvents:Do})},Ro=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:r=.8})=>{const n=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&t.ctrlKey||o.mouseButton(t)===zo});return new Ao({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*r}),moveStateManager:n,enable:t,assignEvents:Do})},Fo=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:r=-.5})=>{const n=new Lo({checkCorrectEvent:t=>o.mouseButton(t)===Po&&t.ctrlKey||o.mouseButton(t)===zo});return new Ao({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*r}),moveStateManager:n,enable:t,assignEvents:Do})};class Bo{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,r){return this._calculateTransform(t,e,r)}touchmove(t,e,r){if(this._active){if(!this._shouldBePrevented(r.length))return t.preventDefault(),this._calculateTransform(t,e,r);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,r){this._calculateTransform(t,e,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,r,n){n.length>0&&(this._active=!0);const i=yo(n,r),a=new e.P(0,0),o=new e.P(0,0);let s=0;for(const t in i){const e=i[t],r=this._touches[t];r&&(a._add(e),o._add(e.sub(r)),s++,i[t]=e)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;const l=o.div(s);return this._sum._add(l),this._sum.mag()Math.abs(t.x)}const Yo=100;class Xo extends No{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,r){super.touchstart(t,e,r),this._currentTouchCount=r.length}_start(t){this._lastPoints=t,Zo(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=t[0].sub(this._lastPoints[0]),i=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,i,r.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,r){if(void 0!==this._valid)return this._valid;const n=2,i=t.mag()>=n,a=e.mag()>=n;if(!i&&!a)return;if(!i||!a)return void 0===this._firstMove&&(this._firstMove=r),r-this._firstMove0==e.y>0;return Zo(t)&&Zo(e)&&o}}const $o={panStep:100,bearingStep:15,pitchStep:10};class Jo{constructor(t){this._tr=new mo(t);const e=$o;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,r=0,n=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,n=0),{cameraAnimation:o=>{const s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:Ko,zoom:e?Math.round(s.zoom)+e*(t.shiftKey?2:1):s.zoom,bearing:s.bearing+r*this._bearingStep,pitch:s.pitch+n*this._pitchStep,offset:[-i*this._panStep,-a*this._panStep],center:s.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ko(t){return t*(2-t)}const Qo=4.000244140625,ts=.01,es=1/450,rs=2;class ns{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new mo(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=ts,this._wheelZoomRate=es}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=a.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==e&&e%Qo==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const r=o.mousePos(this._map.getCanvas(),t),n=this._tr;r.y>n.transform.height/2-n.transform.getHorizon()?this._around=e.N.convert(this._aroundCenter?n.center:n.unproject(r)):this._around=e.N.convert(n.center),this._aroundPoint=n.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Qo?this._wheelZoomRate:this._defaultZoomRate;let r=rs/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*r))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:t.zoom,n=this._startZoom,i=this._easing;let o,s=!1;const l=a.now()-this._lastWheelEventTime;if("wheel"===this._type&&n&&i&&l){const t=Math.min(l/200,1),a=i(t);o=e.z.number(n,r,a),t<1?this._frameId||(this._frameId=!0):s=!0}else o=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=e.b9;if(this._prevEase){const t=this._prevEase,n=(a.now()-t.start)/t.duration,i=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(i*i+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.b8(o,s,.25,1)}return this._prevEase={start:a.now(),duration:t,easing:r},r}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class is{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class as{constructor(t){this._tr=new mo(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class os{constructor(){this._tap=new To({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,r){if(!this._swipePoint)if(this._tapTime){const n=e[0],i=t.timeStamp-this._tapTime0&&(this._swipePoint=n,this._swipeTouch=r[0].identifier):this.reset()}else this._tap.touchstart(t,e,r)}touchmove(t,e,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;const n=e[0],i=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(t,e,r)}touchend(t,e,r){if(this._tapTime)this._swipePoint&&0===r.length&&this.reset();else{const n=this._tap.touchend(t,e,r);n&&(this._tapTime=t.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ss{constructor(t,e,r){this._el=t,this._mousePan=e,this._touchPan=r}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ls{constructor(t,e,r){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class cs{constructor(t,e,r,n){this._el=t,this._touchZoom=e,this._touchRotate=r,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class us{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=o.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=e,this._container.appendChild(n);const i=document.createElement("div");i.className="maplibregl-mobile-message",i.textContent=r,this._container.appendChild(i),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(o.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,r){this._enabled&&(this._map.fire(new e.k("cooperativegestureprevented",{gestureType:t,originalEvent:r})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const hs=t=>t.zoom||t.drag||t.pitch||t.rotate;class fs extends e.k{}function ps(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ds{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},i={},a={},s=t.touches,l=s?this._getMapTouches(s):void 0,c=l?o.touchPos(this._map.getCanvas(),l):o.mousePos(this._map.getCanvas(),t);for(const{handlerName:o,handler:s,allowed:u}of this._handlers){if(!s.isEnabled())continue;let h;this._blockedByActive(a,u,o)?s.reset():s[e||t.type]&&(h=s[e||t.type](t,c,l),this.mergeHandlerResult(n,i,h,o,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||s.isActive())&&(a[o]=s)}const u={};for(const t in this._previousActiveHandlers)a[t]||(u[t]=r);this._previousActiveHandlers=a,(Object.keys(u).length||ps(n))&&(this._changes.push([n,i,u]),this._triggerRenderFrame()),(Object.keys(a).length||ps(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new oo(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,r]of this._listeners)o.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,e,r]of this._listeners)o.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,r=e.getCanvasContainer();this._add("mapEvent",new fo(e,t));const n=e.boxZoom=new go(e,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();const i=e.cooperativeGestures=new us(e,t.cooperativeGestures);this._add("cooperativeGestures",i),t.cooperativeGestures&&i.enable();const a=new ko(e),o=new as(e);e.doubleClickZoom=new is(o,a),this._add("tapZoom",a),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const s=new os;this._add("tapDragZoom",s);const l=e.touchPitch=new Xo(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const c=Ro(t),u=Fo(t);e.dragRotate=new ls(t,c,u),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const h=Oo(t),f=new Bo(t,e);e.dragPan=new ss(r,h,f),this._add("mousePan",h),this._add("touchPan",f,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const p=new Wo,d=new qo;e.touchZoomRotate=new cs(r,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const m=e.scrollZoom=new ns(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",m,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const g=e.keyboard=new Jo(e);this._add("keyboard",g),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new po(e))}_add(t,e,r){this._handlers.push({handlerName:t,handler:e,allowed:r}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(hs(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,r){for(const n in t)if(n!==r&&(!e||e.indexOf(n)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const r of t){const t=r.target;this._el.contains(t)&&e.push(r)}return e}mergeHandlerResult(t,r,n,i,a){if(!n)return;e.e(t,n);const o={handlerName:i,originalEvent:n.originalEvent||a};void 0!==n.zoomDelta&&(r.zoom=o),void 0!==n.panDelta&&(r.drag=o),void 0!==n.pitchDelta&&(r.pitch=o),void 0!==n.bearingDelta&&(r.rotate=o)}_applyChanges(){const t={},r={},n={};for(const[i,a,o]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.e(r,a),e.e(n,o);this._updateMapTransform(t,r,n),this._changes=[]}_updateMapTransform(t,e,r){const n=this._map,i=n._getTransformForUpdate(),a=n.terrain;if(!(ps(t)||a&&this._terrainMovement))return this._fireEvents(e,r,!0);let{panDelta:o,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:u,pinchAround:h}=t;void 0!==h&&(u=h),n._stop(!0),u=u||n.transform.centerPoint;const f=i.pointLocation(o?u.sub(o):u);l&&(i.bearing+=l),c&&(i.pitch+=c),s&&(i.zoom+=s),a?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?i.center=i.pointLocation(i.centerPoint.sub(o)):i.setLocationAtPoint(f,u):(this._terrainMovement=!0,this._map._elevationFreeze=!0,i.setLocationAtPoint(f,u)):i.setLocationAtPoint(f,u),n._applyUpdatedTransform(i),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,r,!0)}_fireEvents(t,r,n){const i=hs(this._eventsInProgress),o=hs(t),s={};for(const e in t){const{originalEvent:r}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=r),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:r}=t[e];this._fireEvent(e,r)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=r[e]||n,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const u=hs(this._eventsInProgress),h=(i||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();t.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(t)}if(n&&h){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new fs("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class ms extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{const t=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new e.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,r,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},r),n)}panTo(t,r,n){return this.easeTo(e.e({center:t},r),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,r,n){return this.easeTo(e.e({zoom:t},r),n)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,r,n){return this.easeTo(e.e({bearing:t},r),n)}resetNorth(t,r){return this.rotateTo(0,e.e({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(i.zoom=e.z.number(o,y,n)),this._rotating&&(i.bearing=e.z.number(s,u,n)),this._pitching&&(i.pitch=e.z.number(l,h,n)),this._padding&&(i.interpolatePadding(c,f,n),d=i.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n),b)i.setLocationAtPoint(b,w);else{const t=i.zoomScale(i.zoom-o),e=y>o?Math.min(2,_):Math.max(.5,_),r=Math.pow(e,1-n),a=i.unproject(v.add(x.mult(n*r)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,d)}this._applyUpdatedTransform(i),this._fireMoveEvents(r)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(r,e)}),t),this}_prepareEase(t,r,n={}){this._moving=!0,r||n.moving||this.fire(new e.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const r=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&r!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart,n=(r-(e*t+this._elevationStart))/(1-t);this._elevationStart+=t*(e-n),this._elevationTarget=r}this.transform.elevation=e.z.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){const e=t.getCameraPosition(),r=this.terrain.getElevationForLngLatZoom(e.lngLat,t.zoom);if(e.altitudethis._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const r=t.clone();for(const t of e){const e=r.clone(),{center:n,zoom:i,pitch:a,bearing:o,elevation:s}=t(e);n&&(e.center=n),void 0!==i&&(e.zoom=i),void 0!==a&&(e.pitch=a),void 0!==o&&(e.bearing=o),void 0!==s&&(e.elevation=s),r.apply(e)}this.transform.apply(r)}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;delete this._easeId;const n=this._zooming,i=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.k("zoomend",t)),i&&this.fire(new e.k("rotateend",t)),a&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t))}flyTo(t,r){var n;if(!t.essential&&a.prefersReducedMotion){const n=e.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,r)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b9},t);const i=this._getTransformForUpdate(),o=i.zoom,s=i.bearing,l=i.pitch,c=i.padding,u="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:l,f="padding"in t?t.padding:i.padding,p=e.P.convert(t.offset);let d=i.centerPoint.add(p);const m=i.pointLocation(d),{center:g,zoom:y}=i.getConstrained(e.N.convert(t.center||m),null!==(n=t.zoom)&&void 0!==n?n:o);this._normalizeCenter(g,i);const v=i.zoomScale(y-o),x=i.project(m),_=i.project(g).sub(x);let b=t.curve;const w=Math.max(i.width,i.height),T=w/v,k=_.mag();if("minZoom"in t){const r=e.ad(Math.min(t.minZoom,o,y),i.minZoom,i.maxZoom),n=w/i.zoomScale(r-o);b=Math.sqrt(n/k*2)}const A=b*b;function M(t){const e=(T*T-w*w+(t?-1:1)*A*A*k*k)/(2*(t?T:w)*A*k);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function E(t){return(Math.exp(t)+Math.exp(-t))/2}function C(t){return S(t)/E(t)}const L=M(!1);let I=function(t){return E(L)/E(L+b*t)},P=function(t){return w*((E(L)*C(L+b*t)-S(L))/A)/k},z=(M(!0)-L)/b;if(Math.abs(k)<1e-6||!isFinite(z)){if(Math.abs(w-T)<1e-6)return this.easeTo(t,r);const e=T0,I=t=>Math.exp(e*b*t)}if("duration"in t)t.duration=+t.duration;else{const e="screenSpeed"in t?+t.screenSpeed/b:+t.speed;t.duration=1e3*z/e}return t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==u,this._pitching=h!==l,this._padding=!i.isPaddingEqual(f),this._prepareEase(r,!1),this.terrain&&this._prepareElevation(g),this._ease((n=>{const a=n*z,m=1/I(a);i.zoom=1===n?y:o+i.scaleZoom(m),this._rotating&&(i.bearing=e.z.number(s,u,n)),this._pitching&&(i.pitch=e.z.number(l,h,n)),this._padding&&(i.interpolatePadding(c,f,n),d=i.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n);const v=1===n?g:i.unproject(x.add(_.mult(P(a))).mult(m));i.setLocationAtPoint(i.renderWorldCopies?v.wrap():v,d),this._applyUpdatedTransform(i),this._fireMoveEvents(r)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(r)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var r;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(r=this.handlers)||void 0===r||r.stop(!1),this}_ease(t,e,r){!1===r.animate||0===r.duration?(t(1),e()):(this._easeStart=a.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,r){t=e.b3(t,-180,180);const n=Math.abs(t-r);return Math.abs(t-360-r)180?-360:r<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const gs={compact:!0,customAttribution:'MapLibre'};class ys{constructor(t=gs){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=o.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=o.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){o.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const r=this._map._getUIString(`AttributionControl.${e}`);t.title=r,t.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const r in e){const n=e[r];if(n.used||n.usedForTerrain){const e=n.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,r)=>{for(let n=r+1;n=0)return!1;return!0}));const r=t.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,t.length?(this._innerContainer.innerHTML=r,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class vs{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=o.create("div","maplibregl-ctrl");const e=o.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){o.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class xs{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,r=e?this._queue.concat(e):this._queue;for(const e of r)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const r of e)if(!r.cancelled&&(r.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var _s=e.Y([{name:"a_pos3d",type:"Int16",components:3}]);class bs extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,r){this.sourceCache.update(t,r),this._renderableTilesKeys=[];const n={};for(const i of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:r}))n[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.posMatrix=new Float64Array(16),e.aQ(i.posMatrix,0,e.X,0,e.X,0,1),this._tiles[i.key]=new qt(i,this.tileSize));for(const t in this._tiles)n[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const r=this._tiles[e];(!t||r.tileID.equals(t)||r.tileID.isChildOf(t)||t.isChildOf(r.tileID))&&(r.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const r={};for(const n of this._renderableTilesKeys){const i=this._tiles[n].tileID;if(i.canonical.equals(t.canonical)){const i=t.clone();i.posMatrix=new Float64Array(16),e.aQ(i.posMatrix,0,e.X,0,e.X,0,1),r[n]=i}else if(i.canonical.isChildOf(t.canonical)){const a=t.clone();a.posMatrix=new Float64Array(16);const o=i.canonical.z-t.canonical.z,s=i.canonical.x-(i.canonical.x>>o<>o<>o;e.aQ(a.posMatrix,0,c,0,c,0,1),e.J(a.posMatrix,a.posMatrix,[-s*c,-l*c,0]),r[n]=a}else if(t.canonical.isChildOf(i.canonical)){const a=t.clone();a.posMatrix=new Float64Array(16);const o=t.canonical.z-i.canonical.z,s=t.canonical.x-(t.canonical.x>>o<>o<>o;e.aQ(a.posMatrix,0,e.X,0,e.X,0,1),e.J(a.posMatrix,a.posMatrix,[s*c,l*c,0]),e.K(a.posMatrix,a.posMatrix,[1/2**o,1/2**o,0]),r[n]=a}}return r}getSourceTile(t,e){const r=this.sourceCache._source;let n=t.overscaledZ-this.deltaZoom;if(n>r.maxzoom&&(n=r.maxzoom),n=r.minzoom&&(!i||!i.dem);)i=this.sourceCache.getTileByID(t.scaledTo(n--).key);return i}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class ws{constructor(t,e,r){this.painter=t,this.sourceCache=new bs(e),this.options=r,this.exaggeration="number"==typeof r.exaggeration?r.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,r,n,i=e.X){var a;if(!(r>=0&&r=0&&nt.canonical.z&&(t.canonical.z>=n?i=t.canonical.z-n:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=t.canonical.x-(t.canonical.x>>i<>i<>8<<4|t>>8,r[e+3]=0;const n=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(r.buffer)),i=new B(t,n,t.gl.RGBA,{premultiply:!1});return i.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const r=new Uint8Array(4),n=this.painter.context,i=n.gl,a=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,r),n.bindFramebuffer.set(null);const l=r[0]+(r[2]>>4<<8),c=r[1]+((15&r[2])<<8),u=this.coordsIndex[255-r[3]],h=u&&this.sourceCache.getTileByID(u);if(!h)return null;const f=this._coordsTextureSize,p=(1<t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse))}}const ks={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class As{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Ts(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((r=>!t._layers[r].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const r=t.sourceCaches[e].getVisibleCoordinates();for(const t of r){const r=this.terrain.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(r[t])}}this._coordsDescendingInvStr={};for(const e of t._order){const r=t._layers[e],n=r.source;if(ks[r.type]&&!this._coordsDescendingInvStr[n]){this._coordsDescendingInvStr[n]={};for(const t in this._coordsDescendingInv[n])this._coordsDescendingInvStr[n][t]=this._coordsDescendingInv[n][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[e][t.tileID.key];r&&r!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const r=t.type,n=this.painter,i=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(ks[r]&&(this._prevType&&ks[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!i))return!0;if(ks[this._prevType]||ks[r]&&i){this._prevType=r;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(Ha(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[t]){const e=this.pool.getObjectForId(r.rtt[t].id);if(e.stamp===r.rtt[t].stamp){this.pool.useObject(e);continue}}const a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),r.rtt[t]={id:a.id,stamp:a.stamp},n.context.bindFramebuffer.set(a.fbo.framebuffer),n.context.clear({color:e.aN.transparent,stencil:0}),n.currentStencilSource=void 0;for(let t=0;tr.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitchPs)throw new Error(`maxPitch must be less than or equal to ${Ps}`);if(super(new Ka(r.minZoom,r.maxZoom,r.minPitch,r.maxPitch,r.renderWorldCopies),{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new xs,this._controls=[],this._mapId=e.a4(),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=!0===r.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=!0===r.preserveDrawingBuffer,this._antialias=!0===r.antialias,this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ms),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this.transformCameraUpdate=r.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=d.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))).on("moveend",(()=>this._update(!1))).on("zoom",(()=>this._update(!0))).on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})).once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=Qa((t=>{this._trackResize&&!this._removed&&this.resize(t)._update()}),50);this._resizeObserver=new ResizeObserver((r=>{t?e(r):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new ds(this,r);const n="string"==typeof r.hash&&r.hash||void 0;this._hash=r.hash&&new to(n).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,e.e({},r.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new ys("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new vs,r.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.k(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.k("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,r){if(void 0===r&&(r=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[r];return-1!==r.indexOf("bottom")?i.insertBefore(n,i.firstChild):i.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,r,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(r,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,r,n)}resize(t){var r;const n=this._containerDimensions(),i=n[0],a=n[1],o=this._getClampedPixelRatio(i,a);if(this._resizeCanvas(i,a,o),this.painter.resize(i,a,o),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(i,a);this._resizeCanvas(i,a,e),this.painter.resize(i,a,e)}this.transform.resize(i,a),null===(r=this._requestedCameraState)||void 0===r||r.resize(i,a);const s=!this._moving;return s&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),s&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){const{0:r,1:n}=this._maxCanvasSize,i=this.getPixelRatio(),a=t*i,o=e*i,s=a>r?r/a:1,l=o>n?n/o:1;return Math.min(s,l)*i}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(bt.convert(t)),this._update()}setMinZoom(t){if((t=null==t?Es:t)>=Es&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?Ls:t)=Ls&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()Ps)throw new Error(`maxPitch must be less than or equal to ${Ps}`);if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.N.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,r){if("mouseenter"===t||"mouseover"===t){let n=!1;const i=i=>{const a=this.getLayer(e)?this.queryRenderedFeatures(i.point,{layers:[e]}):[];a.length?n||(n=!0,r.call(this,new co(t,this,i.originalEvent,{features:a}))):n=!1};return{layer:e,listener:r,delegates:{mousemove:i,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1;const i=i=>{(this.getLayer(e)?this.queryRenderedFeatures(i.point,{layers:[e]}):[]).length?n=!0:n&&(n=!1,r.call(this,new co(t,this,i.originalEvent)))},a=e=>{n&&(n=!1,r.call(this,new co(t,this,e.originalEvent)))};return{layer:e,listener:r,delegates:{mousemove:i,mouseout:a}}}{const n=t=>{const n=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,r.call(this,t),delete t.features)};return{layer:e,listener:r,delegates:{[t]:n}}}}on(t,e,r){if(void 0===r)return super.on(t,e);const n=this._createDelegatedListener(t,e,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(n);for(const t in n.delegates)this.on(t,n.delegates[t]);return this}once(t,e,r){if(void 0===r)return super.once(t,e);const n=this._createDelegatedListener(t,e,r);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,r){if(void 0===r)return super.off(t,e);const n=n=>{const i=n[t];for(let t=0;tthis._updateStyle(t,e)));const r=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Je(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,r):this.style.loadJSON(t,e,r),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Je(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,r){if("string"==typeof t){const n=t,i=this._requestManager.transformRequest(n,"Style");e.h(i,new AbortController).then((t=>{this._updateDiff(t.data,r)})).catch((t=>{t&&this.fire(new e.j(t))}))}else"object"==typeof t&&this._updateDiff(t,r)}_updateDiff(t,r){try{this.style.setState(t,r)&&this._update(!0)}catch(n){e.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const r=this.style&&this.style.sourceCaches[t];if(void 0!==r)return r.loaded();this.fire(new e.j(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const r=this.style.sourceCaches[t.source];if(!r)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&r.reload();for(const r in this.style._layers){const n=this.style._layers[r];"hillshade"===n.type&&n.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new ws(this.painter,r,t),this.painter.renderToTexture=new As(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const r=t[e]._tiles;for(const t in r){const e=r[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,r,n={}){const{pixelRatio:i=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;this._lazyInitEmptyStyle();const f=0;if(!(r instanceof HTMLImageElement||e.b(r))){if(void 0===r.width||void 0===r.height)return this.fire(new e.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:n,height:a,data:p}=r,d=r;return this.style.addImage(t,{data:new e.R({width:n,height:a},new Uint8Array(p)),pixelRatio:i,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:f,userImage:d}),d.onAdd&&d.onAdd(this,t),this}}{const{width:n,height:p,data:d}=a.getImageData(r);this.style.addImage(t,{data:new e.R({width:n,height:p},d),pixelRatio:i,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:f})}}updateImage(t,r){const n=this.style.getImage(t);if(!n)return this.fire(new e.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=r instanceof HTMLImageElement||e.b(r)?a.getImageData(r):r,{width:o,height:s,data:l}=i;if(void 0===o||void 0===s)return this.fire(new e.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==n.data.width||s!==n.data.height)return this.fire(new e.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(r instanceof HTMLImageElement||e.b(r));return n.data.replace(l,c),this.style.updateImage(t,n),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return d.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,r){return this.style.setLayerZoomRange(t,e,r),this._update(!0)}setFilter(t,e,r={}){return this.style.setFilter(t,e,r),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,r,n={}){return this.style.setPaintProperty(t,e,r,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,r,n={}){return this.style.setLayoutProperty(t,e,r,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,r,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t){return this._lazyInitEmptyStyle(),this.style.setSky(t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=o.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=o.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const r=this._containerDimensions(),n=this._getClampedPixelRatio(r[0],r[1]);this._resizeCanvas(r[0],r[1],n);const i=this._controlContainer=o.create("div","maplibregl-control-container",t),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{a[t]=o.create("div",`maplibregl-ctrl-${t} `,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,r){this._canvas.width=Math.floor(r*t),this._canvas.height=Math.floor(r*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(r=>{e={requestedAttributes:t},r&&(e.statusMessage=r.statusMessage,e.type=r.type)}),{once:!0});const r=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!r){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Za(r,this.transform),s.testSupport(r)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){const r=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=a.now();this.style.zoomHistory.update(t,i);const o=new e.a9(t,{now:i,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=o.crossFadingFactor();1===s&&s===this._crossFadingFactor||(n=!0,this._crossFadingFactor=s),this.style.update(o)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,r,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding}),this.fire(new e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.be.mark(e.bf.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const i=this._sourcesDirty||this._styleDirty||this._placementDirty;return i||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||i||(this._fullyLoaded=!0,e.be.mark(e.bf.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),d.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const r=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==r?void 0:r.loseContext)&&r.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),o.remove(this._canvasContainer),o.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.be.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((t=>{e.be.frame(t),this._frameRequest=null,this._render(t)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return Ss}getCameraTargetElevation(){return this.transform.elevation}};const Os=t=>{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},Rs=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:r=.8})=>{const n=new Io;return new Ao({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*r}),moveStateManager:n,enable:t,assignEvents:Os})},Fs=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:r=-.5})=>{const n=new Io;return new Ao({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*r}),moveStateManager:n,enable:t,assignEvents:Os})},Bs={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ns{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,e)=>{const r=this._map._getUIString(`NavigationControl.${e}`);t.title=r,t.setAttribute("aria-label",r)},this.options=e.e({},Bs,t),this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),o.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=o.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new js(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){o.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const r=o.create("button",t,this._container);return r.type="button",r.addEventListener("click",e),r}}class js{constructor(t,r,n=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),o.mousePos(this.element,t)),o.addEventListener(window,"mousemove",this.mousemove),o.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,o.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),o.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=o.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const i=t.dragRotate._mouseRotate.getClickTolerance(),a=t.dragRotate._mousePitch.getClickTolerance();this.element=r,this.mouseRotate=Ro({clickTolerance:i,enable:!0}),this.touchRotate=Rs({clickTolerance:i,enable:!0}),this.map=t,n&&(this.mousePitch=Fo({clickTolerance:a,enable:!0}),this.touchPitch=Fs({clickTolerance:a,enable:!0})),o.addEventListener(r,"mousedown",this.mousedown),o.addEventListener(r,"touchstart",this.touchstart,{passive:!1}),o.addEventListener(r,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),o.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),o.disableDrag()}moveMouse(t,e){const r=this.map,{bearingDelta:n}=this.mouseRotate.dragMove(t,e)||{};if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){const{pitchDelta:n}=this.mousePitch.dragMove(t,e)||{};n&&r.setPitch(r.getPitch()+n)}}moveTouch(t,e){const r=this.map,{bearingDelta:n}=this.touchRotate.dragMove(t,e)||{};if(n&&r.setBearing(r.getBearing()+n),this.touchPitch){const{pitchDelta:n}=this.touchPitch.dragMove(t,e)||{};n&&r.setPitch(r.getPitch()+n)}}off(){const t=this.element;o.removeEventListener(t,"mousedown",this.mousedown),o.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),o.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.removeEventListener(window,"touchend",this.touchend),o.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){o.enableDrag(),o.removeEventListener(window,"mousemove",this.mousemove),o.removeEventListener(window,"mouseup",this.mouseup),o.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),o.removeEventListener(window,"touchend",this.touchend)}}let Us;function Vs(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==Us&&!t)return Us;if(void 0===window.navigator.permissions)return Us=!!window.navigator.geolocation,Us;try{const t=yield window.navigator.permissions.query({name:"geolocation"});Us="denied"!==t.state}catch(t){Us=!!window.navigator.geolocation}return Us}))}function qs(t,r,n){const i=new e.N(t.lng,t.lat);if(t=new e.N(t.lng,t.lat),r){const i=new e.N(t.lng-360,t.lat),a=new e.N(t.lng+360,t.lat),o=n.locationPoint(t).distSqr(r);n.locationPoint(i).distSqr(r)180;){const e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t.lng!==i.lng&&n.locationPoint(t).y>n.height/2-n.getHorizon()?t:i}const Hs={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Gs(t,e,r){const n=t.classList;for(const t in Hs)n.remove(`maplibregl-${r}-anchor-${t}`);n.add(`maplibregl-${r}-anchor-${e}`)}class Ws extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,r=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==r&&13!==r||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,r=this._element;this._popup&&(e===r||r.contains(e))&&this.togglePopup()},this._update=t=>{var e;if(!this._map)return;const r=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!r)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies?this._lngLat=qs(this._lngLat,this._flatPos,this._map.transform):this._lngLat=null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let n="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?n=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),o.setTransform(this._element,`${Hs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${n}`),a.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o.create("div");const r=o.createNS("http://www.w3.org/2000/svg","svg"),n=41,i=27;r.setAttributeNS(null,"display","block"),r.setAttributeNS(null,"height",`${n}px`),r.setAttributeNS(null,"width",`${i}px`),r.setAttributeNS(null,"viewBox",`0 0 ${i} ${n}`);const a=o.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=o.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=o.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of c){const e=o.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const u=o.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"fill",this._color);const h=o.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),u.appendChild(h);const f=o.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"fill","#000000");const p=o.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),f.appendChild(p);const d=o.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(6.0, 7.0)"),d.setAttributeNS(null,"fill","#FFFFFF");const m=o.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=o.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const y=o.createNS("http://www.w3.org/2000/svg","circle");y.setAttributeNS(null,"fill","#FFFFFF"),y.setAttributeNS(null,"cx","5.5"),y.setAttributeNS(null,"cy","5.5"),y.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(y),s.appendChild(l),s.appendChild(u),s.appendChild(f),s.appendChild(d),s.appendChild(m),r.appendChild(s),r.setAttributeNS(null,"height",n*this._scale+"px"),r.setAttributeNS(null,"width",i*this._scale+"px"),this._element.appendChild(r),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),Gs(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),o.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,r=13.5,n=Math.abs(r)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[n,-1*(e-r+n)],"bottom-right":[-n,-1*(e-r+n)],left:[r,-1*(e-r)],right:[-r,-1*(e-r)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var r,n;if(!(null===(r=this._map)||void 0===r?void 0:r.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const i=this._map,a=i.terrain.depthAtPoint(this._pos),o=i.terrain.getElevationForLngLatZoom(this._lngLat,i.transform.tileZoom),s=.006;if(i.transform.lngLatToCameraDepth(this._lngLat,o)-as;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Zs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ys=0,Xs=!1;class $s extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const r=new e.N(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,i=this._map.getBearing(),a=e.e({bearing:i},this.options.fitBoundsOptions),o=bt.fromLngLat(r,n);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const r=new e.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Xs)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o.create("button","maplibregl-ctrl-geolocate",this._container),o.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ws({element:this._dotElement}),this._circleElement=o.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ws({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{const r=t.originalEvent&&"resize"===t.originalEvent.type;t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||r||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")),this.fire(new e.k("userlocationlostfocus")))}))}},this.options=e.e({},Zs,t)}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),Vs().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),o.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ys=0,Xs=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),r=t.coords;return e&&(r.longitudee.getEast()||r.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),r=t.getNorthEast(),n=e.distanceTo(r),i=this._map._container.clientHeight,a=Math.ceil(this._accuracy/(n/i)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ys--,Xs=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.k("trackuserlocationstart")),this.fire(new e.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ys++,Ys>1?(t={maximumAge:6e5,timeout:0},Xs=!0):(t=this.options.positionOptions,Xs=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}}const Js={maxWidth:100,unit:"metric"};class Ks{constructor(t){this._onMove=()=>{Qs(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Qs(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Js),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){o.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}}function Qs(t,e,r){const n=r&&r.maxWidth||100,i=t._container.clientHeight/2,a=t.unproject([0,i]),o=t.unproject([n,i]),s=a.distanceTo(o);if(r&&"imperial"===r.unit){const r=3.2808*s;r>5280?tl(e,n,r/5280,t._getUIString("ScaleControl.Miles")):tl(e,n,r,t._getUIString("ScaleControl.Feet"))}else r&&"nautical"===r.unit?tl(e,n,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?tl(e,n,s/1e3,t._getUIString("ScaleControl.Kilometers")):tl(e,n,s,t._getUIString("ScaleControl.Meters"))}function tl(t,e,r,n){const i=rl(r),a=i/r;t.style.width=e*a+"px",t.innerHTML=`${i} ${n}`}function el(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}function rl(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let r=t/e;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:el(r),e*r}class nl extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){o.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=o.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);o.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}}class il{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=o.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=o.create("button","maplibregl-ctrl-terrain",this._container),o.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){o.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}}const al={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ol=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");class sl extends e.E{constructor(t){super(),this.remove=()=>(this._content&&o.remove(this._content),this._container&&(o.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var e;const r=this._lngLat||this._trackPointer;if(!this._map||!r||!this._content)return;if(!this._container){if(this._container=o.create("div","maplibregl-popup",this._map.getContainer()),this._tip=o.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer?this._lngLat=qs(this._lngLat,this._flatPos,this._map.transform):this._lngLat=null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let i=this.options.anchor;const a=ll(this.options.offset);if(!i){const t=this._container.offsetWidth,e=this._container.offsetHeight;let r;r=n.y+a.bottom.ythis._map.transform.height-e?["bottom"]:[],n.xthis._map.transform.width-t/2&&r.push("right"),i=0===r.length?"bottom":r.join("-")}let s=n.add(a[i]);this.options.subpixelPositioning||(s=s.round()),o.setTransform(this._container,`${Hs[i]} translate(${s.x}px,${s.y}px)`),Gs(this._container,i,"popup")},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(al),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),r=document.createElement("body");let n;for(r.innerHTML=t;n=r.firstChild,n;)e.appendChild(n);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=o.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=o.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(ol);t&&t.focus()}}function ll(t){if(t){if("number"==typeof t){const r=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(r,r),"top-right":new e.P(-r,r),bottom:new e.P(0,-t),"bottom-left":new e.P(r,-r),"bottom-right":new e.P(-r,-r),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const r=e.P.convert(t);return{center:r,top:r,"top-left":r,"top-right":r,bottom:r,"bottom-left":r,"bottom-right":r,left:r,right:r}}return{center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return ll(new e.P(0,0))}const cl=r.version;function ul(t,e){return Ut().setRTLTextPlugin(t,e)}function hl(){return Ut().getRTLTextPluginStatus()}function fl(){return cl}function pl(){return it.workerCount}function dl(t){it.workerCount=t}function ml(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS}function gl(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t}function yl(){return e.a.WORKER_URL}function vl(t){e.a.WORKER_URL=t}function xl(t){return ft().broadcast("IS",t)}t.AJAXError=e.bg,t.Evented=e.E,t.LngLat=e.N,t.MercatorCoordinate=e.Z,t.Point=e.P,t.addProtocol=e.bh,t.config=e.a,t.removeProtocol=e.bi,t.AttributionControl=ys,t.BoxZoomHandler=go,t.CanvasSource=It,t.CooperativeGesturesHandler=us,t.DoubleClickZoomHandler=is,t.DragPanHandler=ss,t.DragRotateHandler=ls,t.EdgeInsets=$a,t.FullscreenControl=nl,t.GeoJSONSource=Mt,t.GeolocateControl=$s,t.Hash=to,t.ImageSource=Et,t.KeyboardHandler=Jo,t.LngLatBounds=bt,t.LogoControl=vs,t.Map=Ds,t.MapMouseEvent=co,t.MapTouchEvent=uo,t.MapWheelEvent=ho,t.Marker=Ws,t.NavigationControl=Ns,t.Popup=sl,t.RasterDEMTileSource=At,t.RasterTileSource=kt,t.ScaleControl=Ks,t.ScrollZoomHandler=ns,t.Style=Je,t.TerrainControl=il,t.TwoFingersTouchPitchHandler=Xo,t.TwoFingersTouchRotateHandler=Wo,t.TwoFingersTouchZoomHandler=qo,t.TwoFingersTouchZoomRotateHandler=cs,t.VectorTileSource=Tt,t.VideoSource=Lt,t.addSourceType=Rt,t.clearPrewarmedResources=ut,t.getMaxParallelImageRequests=ml,t.getRTLTextPluginStatus=hl,t.getVersion=fl,t.getWorkerCount=pl,t.getWorkerUrl=yl,t.importScriptInWorkers=xl,t.prewarm=ct,t.setMaxParallelImageRequests=gl,t.setRTLTextPlugin=ul,t.setWorkerCount=dl,t.setWorkerUrl=vl})),t}()},88640:function(t,e,r){"use strict";function n(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function i(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function a(){}r.d(e,{GW:function(){return tt},Dj:function(){return W}});var o=.7,s=1/o,l="\\s*([+-]?\\d+)\\s*",c="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",u="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",h=/^#([0-9a-f]{3,8})$/,f=new RegExp("^rgb\\(".concat(l,",").concat(l,",").concat(l,"\\)$")),p=new RegExp("^rgb\\(".concat(u,",").concat(u,",").concat(u,"\\)$")),d=new RegExp("^rgba\\(".concat(l,",").concat(l,",").concat(l,",").concat(c,"\\)$")),m=new RegExp("^rgba\\(".concat(u,",").concat(u,",").concat(u,",").concat(c,"\\)$")),g=new RegExp("^hsl\\(".concat(c,",").concat(u,",").concat(u,"\\)$")),y=new RegExp("^hsla\\(".concat(c,",").concat(u,",").concat(u,",").concat(c,"\\)$")),v={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function x(){return this.rgb().formatHex()}function _(){return this.rgb().formatRgb()}function b(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=h.exec(t))?(r=e[1].length,e=parseInt(e[1],16),6===r?w(e):3===r?new A(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===r?T(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===r?T(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=f.exec(t))?new A(e[1],e[2],e[3],1):(e=p.exec(t))?new A(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=d.exec(t))?T(e[1],e[2],e[3],e[4]):(e=m.exec(t))?T(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=g.exec(t))?I(e[1],e[2]/100,e[3]/100,1):(e=y.exec(t))?I(e[1],e[2]/100,e[3]/100,e[4]):v.hasOwnProperty(t)?w(v[t]):"transparent"===t?new A(NaN,NaN,NaN,0):null}function w(t){return new A(t>>16&255,t>>8&255,255&t,1)}function T(t,e,r,n){return n<=0&&(t=e=r=NaN),new A(t,e,r,n)}function k(t,e,r,n){return 1===arguments.length?((i=t)instanceof a||(i=b(i)),i?new A((i=i.rgb()).r,i.g,i.b,i.opacity):new A):new A(t,e,r,null==n?1:n);var i}function A(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function M(){return"#".concat(L(this.r)).concat(L(this.g)).concat(L(this.b))}function S(){var t=E(this.opacity);return"".concat(1===t?"rgb(":"rgba(").concat(C(this.r),", ").concat(C(this.g),", ").concat(C(this.b)).concat(1===t?")":", ".concat(t,")"))}function E(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function C(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function L(t){return((t=C(t))<16?"0":"")+t.toString(16)}function I(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new z(t,e,r,n)}function P(t){if(t instanceof z)return new z(t.h,t.s,t.l,t.opacity);if(t instanceof a||(t=b(t)),!t)return new z;if(t instanceof z)return t;var e=(t=t.rgb()).r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),o=Math.max(e,r,n),s=NaN,l=o-i,c=(o+i)/2;return l?(s=e===o?(r-n)/l+6*(r0&&c<1?0:s,new z(s,l,c,t.opacity)}function z(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function D(t){return(t=(t||0)%360)<0?t+360:t}function O(t){return Math.max(0,Math.min(1,t||0))}function R(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}function F(t,e,r,n,i){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*r+(1+3*t+3*a-3*o)*n+o*i)/6}n(a,b,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:x,formatHex:x,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return P(this).formatHsl()},formatRgb:_,toString:_}),n(A,k,i(a,{brighter:function(t){return t=null==t?s:Math.pow(s,t),new A(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?o:Math.pow(o,t),new A(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},clamp:function(){return new A(C(this.r),C(this.g),C(this.b),E(this.opacity))},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:M,formatHex:M,formatHex8:function(){return"#".concat(L(this.r)).concat(L(this.g)).concat(L(this.b)).concat(L(255*(isNaN(this.opacity)?1:this.opacity)))},formatRgb:S,toString:S})),n(z,(function(t,e,r,n){return 1===arguments.length?P(t):new z(t,e,r,null==n?1:n)}),i(a,{brighter:function(t){return t=null==t?s:Math.pow(s,t),new z(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?o:Math.pow(o,t),new z(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new A(R(t>=240?t-240:t+120,i,n),R(t,i,n),R(t<120?t+240:t-120,i,n),this.opacity)},clamp:function(){return new z(D(this.h),O(this.s),O(this.l),E(this.opacity))},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=E(this.opacity);return"".concat(1===t?"hsl(":"hsla(").concat(D(this.h),", ").concat(100*O(this.s),"%, ").concat(100*O(this.l),"%").concat(1===t?")":", ".concat(t,")"))}}));var B=function(t){return function(){return t}};function N(t,e){return function(r){return t+r*e}}function j(t){return 1==(t=+t)?U:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):B(isNaN(e)?r:e)}}function U(t,e){var r=e-t;return r?N(t,r):B(isNaN(t)?e:t)}var V=function t(e){var r=j(e);function n(t,e){var n=r((t=k(t)).r,(e=k(e)).r),i=r(t.g,e.g),a=r(t.b,e.b),o=U(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return n.gamma=t,n}(1);function q(t){return function(e){var r,n,i=e.length,a=new Array(i),o=new Array(i),s=new Array(i);for(r=0;r=1?(r=1,e-1):Math.floor(r*e),i=t[n],a=t[n+1],o=n>0?t[n-1]:2*i-a,s=na&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:W(r,n)})),a=$.lastIndex;return aESRI"},"ortoInstaMaps":{"type":"raster","tiles":["https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"],"tileSize":256,"maxzoom":13},"ortoICGC":{"type":"raster","tiles":["https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"],"tileSize":256,"minzoom":13.1,"maxzoom":20},"openmaptiles":{"type":"vector","url":"https://geoserveis.icgc.cat/contextmaps/basemap.json"}},"sprite":"https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1","glyphs":"https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#F4F9F4"}},{"id":"ortoEsri","type":"raster","source":"ortoEsri","maxzoom":16,"layout":{"visibility":"visible"}},{"id":"ortoICGC","type":"raster","source":"ortoICGC","minzoom":13.1,"maxzoom":19,"layout":{"visibility":"visible"}},{"id":"ortoInstaMaps","type":"raster","source":"ortoInstaMaps","maxzoom":13,"layout":{"visibility":"visible"}},{"id":"waterway_tunnel","type":"line","source":"openmaptiles","source-layer":"waterway","minzoom":14,"filter":["all",["in","class","river","stream","canal"],["==","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,6]]},"line-dasharray":[2,4]}},{"id":"waterway-other","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["!in","class","canal","river","stream"],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,2]]}}},{"id":"waterway-stream-canal","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["all",["in","class","canal","stream"],["!=","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.3,"stops":[[13,0.5],[20,6]]}}},{"id":"waterway-river","type":"line","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"waterway","filter":["all",["==","class","river"],["!=","brunnel","tunnel"]],"layout":{"line-cap":"round"},"paint":{"line-color":"#a0c8f0","line-width":{"base":1.2,"stops":[[10,0.8],[20,4]]},"line-opacity":0.5}},{"id":"water-offset","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","maxzoom":8,"filter":["==","$type","Polygon"],"layout":{"visibility":"visible"},"paint":{"fill-opacity":0,"fill-color":"#a0c8f0","fill-translate":{"base":1,"stops":[[6,[2,0]],[8,[0,0]]]}}},{"id":"water","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","layout":{"visibility":"visible"},"paint":{"fill-color":"hsl(210, 67%, 85%)","fill-opacity":0}},{"id":"water-pattern","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"water","layout":{"visibility":"visible"},"paint":{"fill-translate":[0,2.5],"fill-pattern":"wave","fill-opacity":1}},{"id":"landcover-ice-shelf","type":"fill","metadata":{"mapbox:group":"1444849382550.77"},"source":"openmaptiles","source-layer":"landcover","filter":["==","subclass","ice_shelf"],"layout":{"visibility":"visible"},"paint":{"fill-color":"#fff","fill-opacity":{"base":1,"stops":[[0,0.9],[10,0.3]]}}},{"id":"tunnel-service-track-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","service","track"]],"layout":{"line-join":"round"},"paint":{"line-color":"#cfcdca","line-dasharray":[0.5,0.25],"line-width":{"base":1.2,"stops":[[15,1],[16,4],[20,11]]}}},{"id":"tunnel-minor-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","minor"]],"layout":{"line-join":"round"},"paint":{"line-color":"#cfcdca","line-opacity":{"stops":[[12,0],[12.5,1]]},"line-width":{"base":1.2,"stops":[[12,0.5],[13,1],[14,4],[20,15]]}}},{"id":"tunnel-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[8,1.5],[20,17]]}}},{"id":"tunnel-trunk-primary-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.7}},{"id":"tunnel-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","motorway"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-dasharray":[0.5,0.25],"line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.5}},{"id":"tunnel-path","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","tunnel"],["==","class","path"]]],"paint":{"line-color":"#cba","line-dasharray":[1.5,0.75],"line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]}}},{"id":"tunnel-service-track","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","service","track"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff","line-width":{"base":1.2,"stops":[[15.5,0],[16,2],[20,7.5]]}}},{"id":"tunnel-minor","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","minor_road"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff","line-opacity":1,"line-width":{"base":1.2,"stops":[[13.5,0],[14,2.5],[20,11.5]]}}},{"id":"tunnel-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff4c6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,10]]}}},{"id":"tunnel-trunk-primary","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fff4c6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"tunnel-motorway","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","motorway"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"#ffdaa6","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"tunnel-railway","type":"line","metadata":{"mapbox:group":"1444849354174.1904"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","tunnel"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]},"line-dasharray":[2,2]}},{"id":"ferry","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["in","class","ferry"]],"layout":{"line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(108, 159, 182, 1)","line-width":1.1,"line-dasharray":[2,2]}},{"id":"aeroway-taxiway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":12,"filter":["all",["in","class","taxiway"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(153, 153, 153, 1)","line-width":{"base":1.5,"stops":[[11,2],[17,12]]},"line-opacity":1}},{"id":"aeroway-runway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":12,"filter":["all",["in","class","runway"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(153, 153, 153, 1)","line-width":{"base":1.5,"stops":[[11,5],[17,55]]},"line-opacity":1}},{"id":"aeroway-taxiway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":4,"filter":["all",["in","class","taxiway"],["==","$type","LineString"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(255, 255, 255, 1)","line-width":{"base":1.5,"stops":[[11,1],[17,10]]},"line-opacity":{"base":1,"stops":[[11,0],[12,1]]}}},{"id":"aeroway-runway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"aeroway","minzoom":4,"filter":["all",["in","class","runway"],["==","$type","LineString"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"rgba(255, 255, 255, 1)","line-width":{"base":1.5,"stops":[[11,4],[17,50]]},"line-opacity":{"base":1,"stops":[[11,0],[12,1]]}}},{"id":"highway-motorway-link-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":12,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway_link"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"highway-link-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"highway-minor-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!=","brunnel","tunnel"],["in","class","minor","service","track"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#cfcdca","line-opacity":{"stops":[[12,0],[12.5,0]]},"line-width":{"base":1.2,"stops":[[12,0.5],[13,1],[14,4],[20,15]]}}},{"id":"highway-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":0.5,"line-width":{"base":1.2,"stops":[[8,1.5],[20,17]]}}},{"id":"highway-primary-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":{"stops":[[7,0],[8,0.6]]},"line-width":{"base":1.2,"stops":[[7,0],[8,0.6],[9,1.5],[20,22]]}}},{"id":"highway-trunk-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","trunk"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-opacity":{"stops":[[5,0],[6,0.5]]},"line-width":{"base":1.2,"stops":[[5,0],[6,0.6],[7,1.5],[20,22]]}}},{"id":"highway-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":4,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway"]],"layout":{"line-cap":"butt","line-join":"round","visibility":"visible"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[4,0],[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":{"stops":[[4,0],[5,0.5]]}}},{"id":"highway-path","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["==","class","path"]]],"paint":{"line-color":"#cba","line-dasharray":[1.5,0.75],"line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]}}},{"id":"highway-motorway-link","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":12,"filter":["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway_link"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"highway-link","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"highway-minor","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!=","brunnel","tunnel"],["in","class","minor","service","track"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#fff","line-opacity":0.5,"line-width":{"base":1.2,"stops":[[13.5,0],[14,2.5],[20,11.5]]}}},{"id":"highway-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["!in","brunnel","bridge","tunnel"],["in","class","secondary","tertiary"]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[8,0.5],[20,13]]},"line-opacity":0.5}},{"id":"highway-primary","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["in","class","primary"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[8.5,0],[9,0.5],[20,18]]},"line-opacity":0}},{"id":"highway-trunk","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["in","class","trunk"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"highway-motorway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","minzoom":5,"filter":["all",["==","$type","LineString"],["all",["!in","brunnel","bridge","tunnel"],["==","class","motorway"]]],"layout":{"line-cap":"round","line-join":"round","visibility":"visible"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"railway-transit","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","transit"],["!in","brunnel","tunnel"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.77)","line-width":{"base":1.4,"stops":[[14,0.4],[20,1]]}}},{"id":"railway-transit-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","transit"],["!in","brunnel","tunnel"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.68)","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,2],[20,6]]}}},{"id":"railway-service","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","rail"],["has","service"]]],"paint":{"line-color":"hsla(0, 0%, 73%, 0.77)","line-width":{"base":1.4,"stops":[[14,0.4],[20,1]]}}},{"id":"railway-service-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","class","rail"],["has","service"]]],"layout":{"visibility":"visible"},"paint":{"line-color":"hsla(0, 0%, 73%, 0.68)","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,2],[20,6]]}}},{"id":"railway","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!has","service"],["!in","brunnel","bridge","tunnel"],["==","class","rail"]]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]}}},{"id":"railway-hatching","type":"line","metadata":{"mapbox:group":"1444849345966.4436"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["!has","service"],["!in","brunnel","bridge","tunnel"],["==","class","rail"]]],"paint":{"line-color":"#bbb","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,3],[20,8]]}}},{"id":"bridge-motorway-link-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"bridge-link-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[12,1],[13,3],[14,4],[20,15]]}}},{"id":"bridge-secondary-tertiary-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-opacity":1,"line-width":{"base":1.2,"stops":[[8,1.5],[20,28]]}}},{"id":"bridge-trunk-primary-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"hsl(28, 76%, 67%)","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,26]]}}},{"id":"bridge-motorway-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway"]],"layout":{"line-join":"round"},"paint":{"line-color":"#e9ac77","line-width":{"base":1.2,"stops":[[5,0.4],[6,0.6],[7,1.5],[20,22]]},"line-opacity":0.5}},{"id":"bridge-path-casing","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","bridge"],["==","class","path"]]],"paint":{"line-color":"#f8f4f0","line-width":{"base":1.2,"stops":[[15,1.2],[20,18]]}}},{"id":"bridge-path","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","$type","LineString"],["all",["==","brunnel","bridge"],["==","class","path"]]],"paint":{"line-color":"#cba","line-width":{"base":1.2,"stops":[[15,1.2],[20,4]]},"line-dasharray":[1.5,0.75]}},{"id":"bridge-motorway-link","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"bridge-link","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary_link","secondary_link","tertiary_link","trunk_link"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[12.5,0],[13,1.5],[14,2.5],[20,11.5]]}}},{"id":"bridge-secondary-tertiary","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","secondary","tertiary"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,20]]}}},{"id":"bridge-trunk-primary","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["in","class","primary","trunk"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fea","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]}}},{"id":"bridge-motorway","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","motorway"]],"layout":{"line-join":"round"},"paint":{"line-color":"#fc8","line-width":{"base":1.2,"stops":[[6.5,0],[7,0.5],[20,18]]},"line-opacity":0.5}},{"id":"bridge-railway","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-width":{"base":1.4,"stops":[[14,0.4],[15,0.75],[20,2]]}}},{"id":"bridge-railway-hatching","type":"line","metadata":{"mapbox:group":"1444849334699.1902"},"source":"openmaptiles","source-layer":"transportation","filter":["all",["==","brunnel","bridge"],["==","class","rail"]],"paint":{"line-color":"#bbb","line-dasharray":[0.2,8],"line-width":{"base":1.4,"stops":[[14.5,0],[15,3],[20,8]]}}},{"id":"cablecar","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["==","class","cable_car"],"layout":{"visibility":"visible","line-cap":"round"},"paint":{"line-color":"hsl(0, 0%, 70%)","line-width":{"base":1,"stops":[[11,1],[19,2.5]]}}},{"id":"cablecar-dash","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["==","class","cable_car"],"layout":{"visibility":"visible","line-cap":"round"},"paint":{"line-color":"hsl(0, 0%, 70%)","line-width":{"base":1,"stops":[[11,3],[19,5.5]]},"line-dasharray":[2,3]}},{"id":"boundary-land-level-4","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",[">=","admin_level",4],["<=","admin_level",8],["!=","maritime",1]],"layout":{"line-join":"round"},"paint":{"line-color":"#9e9cab","line-dasharray":[3,1,1,1],"line-width":{"base":1.4,"stops":[[4,0.4],[5,1],[12,3]]},"line-opacity":0.6}},{"id":"boundary-land-level-2","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["==","admin_level",2],["!=","maritime",1],["!=","disputed",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"hsl(248, 7%, 66%)","line-width":{"base":1,"stops":[[0,0.6],[4,1.4],[5,2],[12,2]]}}},{"id":"boundary-land-disputed","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["!=","maritime",1],["==","disputed",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"hsl(248, 7%, 70%)","line-dasharray":[1,3],"line-width":{"base":1,"stops":[[0,0.6],[4,1.4],[5,2],[12,8]]}}},{"id":"boundary-water","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["all",["in","admin_level",2,4],["==","maritime",1]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"rgba(154, 189, 214, 1)","line-width":{"base":1,"stops":[[0,0.6],[4,1],[5,1],[12,1]]},"line-opacity":{"stops":[[6,0],[10,0]]}}},{"id":"waterway-name","type":"symbol","source":"openmaptiles","source-layer":"waterway","minzoom":13,"filter":["all",["==","$type","LineString"],["has","name"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin} {name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"line","text-letter-spacing":0.2,"symbol-spacing":350},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-lakeline","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["==","$type","LineString"],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"line","symbol-spacing":350,"text-letter-spacing":0.2},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-ocean","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["all",["==","$type","Point"],["==","class","ocean"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":14,"text-field":"{name:latin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"point","symbol-spacing":350,"text-letter-spacing":0.2},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"water-name-other","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["all",["==","$type","Point"],["!in","class","ocean"]],"layout":{"text-font":["Noto Sans Italic"],"text-size":{"stops":[[0,10],[6,14]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":5,"text-rotation-alignment":"map","symbol-placement":"point","symbol-spacing":350,"text-letter-spacing":0.2,"visibility":"visible"},"paint":{"text-color":"#74aee9","text-halo-width":1.5,"text-halo-color":"rgba(255,255,255,0.7)"}},{"id":"poi-level-3","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":16,"filter":["all",["==","$type","Point"],[">=","rank",25]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"poi-level-2","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":15,"filter":["all",["==","$type","Point"],["<=","rank",24],[">=","rank",15]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"poi-level-1","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":14,"filter":["all",["==","$type","Point"],["<=","rank",14],["has","name"]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":11,"text-max-width":9},"paint":{"text-halo-blur":0.5,"text-color":"rgba(191, 228, 172, 1)","text-halo-width":1,"text-halo-color":"rgba(30, 29, 29, 1)"}},{"id":"poi-railway","type":"symbol","source":"openmaptiles","source-layer":"poi","minzoom":13,"filter":["all",["==","$type","Point"],["has","name"],["==","class","railway"],["==","subclass","station"]],"layout":{"text-padding":2,"text-font":["Noto Sans Regular"],"text-anchor":"top","icon-image":"{class}_11","text-field":"{name:latin}\\n{name:nonlatin}","text-offset":[0,0.6],"text-size":12,"text-max-width":9,"icon-optional":false,"icon-ignore-placement":false,"icon-allow-overlap":false,"text-ignore-placement":false,"text-allow-overlap":false,"text-optional":true},"paint":{"text-halo-blur":0.5,"text-color":"#666","text-halo-width":1,"text-halo-color":"#ffffff"}},{"id":"road_oneway","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["all",["==","oneway",1],["in","class","motorway","trunk","primary","secondary","tertiary","minor","service"]],"layout":{"symbol-placement":"line","icon-image":"oneway","symbol-spacing":75,"icon-padding":2,"icon-rotation-alignment":"map","icon-rotate":90,"icon-size":{"stops":[[15,0.5],[19,1]]}},"paint":{"icon-opacity":0.5}},{"id":"road_oneway_opposite","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["all",["==","oneway",-1],["in","class","motorway","trunk","primary","secondary","tertiary","minor","service"]],"layout":{"symbol-placement":"line","icon-image":"oneway","symbol-spacing":75,"icon-padding":2,"icon-rotation-alignment":"map","icon-rotate":-90,"icon-size":{"stops":[[15,0.5],[19,1]]}},"paint":{"icon-opacity":0.5}},{"id":"highway-name-path","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":15.5,"filter":["==","class","path"],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-color":"#f8f4f0","text-color":"hsl(30, 23%, 62%)","text-halo-width":0.5}},{"id":"highway-name-minor","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":15,"filter":["all",["==","$type","LineString"],["in","class","minor","service","track"]],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-blur":0.5,"text-color":"#765","text-halo-width":1}},{"id":"highway-name-major","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":12.2,"filter":["in","class","primary","secondary","tertiary","trunk"],"layout":{"text-size":{"base":1,"stops":[[13,12],[14,13]]},"text-font":["Noto Sans Regular"],"text-field":"{name:latin} {name:nonlatin}","symbol-placement":"line","text-rotation-alignment":"map"},"paint":{"text-halo-blur":0.5,"text-color":"#765","text-halo-width":1}},{"id":"highway-shield","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":8,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["!in","network","us-interstate","us-highway","us-state"]],"layout":{"text-size":10,"icon-image":"road_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[10,"point"],[11,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-opacity":1,"text-color":"rgba(20, 19, 19, 1)","text-halo-color":"rgba(230, 221, 221, 0)","text-halo-width":2,"icon-color":"rgba(183, 18, 18, 1)","icon-opacity":0.3,"icon-halo-color":"rgba(183, 55, 55, 0)"}},{"id":"highway-shield-us-interstate","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":7,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["in","network","us-interstate"]],"layout":{"text-size":10,"icon-image":"{network}_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[7,"point"],[7,"line"],[8,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-color":"rgba(0, 0, 0, 1)"}},{"id":"highway-shield-us-other","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","minzoom":9,"filter":["all",["<=","ref_length",6],["==","$type","LineString"],["in","network","us-highway","us-state"]],"layout":{"text-size":10,"icon-image":"{network}_{ref_length}","icon-rotation-alignment":"viewport","symbol-spacing":200,"text-font":["Noto Sans Regular"],"symbol-placement":{"base":1,"stops":[[10,"point"],[11,"line"]]},"text-rotation-alignment":"viewport","icon-size":1,"text-field":"{ref}"},"paint":{"text-color":"rgba(0, 0, 0, 1)"}},{"id":"place-other","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","minzoom":12,"filter":["!in","class","city","town","village","country","continent"],"layout":{"text-letter-spacing":0.1,"text-size":{"base":1.2,"stops":[[12,10],[15,14]]},"text-font":["Noto Sans Bold"],"text-field":"{name:latin}\\n{name:nonlatin}","text-transform":"uppercase","text-max-width":9,"visibility":"visible"},"paint":{"text-color":"rgba(255,255,255,1)","text-halo-width":1.2,"text-halo-color":"rgba(57, 28, 28, 1)"}},{"id":"place-village","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","minzoom":10,"filter":["==","class","village"],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[10,12],[15,16]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(255, 255, 255, 1)","text-halo-width":1.2,"text-halo-color":"rgba(10, 9, 9, 0.8)"}},{"id":"place-town","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["==","class","town"],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[10,14],[15,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(255, 255, 255, 1)","text-halo-width":1.2,"text-halo-color":"rgba(22, 22, 22, 0.8)"}},{"id":"place-city","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["!=","capital",2],["==","class","city"]],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[7,14],[11,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"visibility":"visible"},"paint":{"text-color":"rgba(0, 0, 0, 1)","text-halo-width":1.2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-city-capital","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","capital",2],["==","class","city"]],"layout":{"text-font":["Noto Sans Regular"],"text-size":{"base":1.2,"stops":[[7,14],[11,24]]},"text-field":"{name:latin}\\n{name:nonlatin}","text-max-width":8,"icon-image":"star_11","text-offset":[0.4,0],"icon-size":0.8,"text-anchor":"left","visibility":"visible"},"paint":{"text-color":"#333","text-halo-width":1.2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-other","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],[">=","rank",3],["!has","iso_a2"]],"layout":{"text-font":["Noto Sans Italic"],"text-field":"{name:latin}","text-size":{"stops":[[3,11],[7,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-3","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],[">=","rank",3],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[3,11],[7,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-2","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],["==","rank",2],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[2,11],[5,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-country-1","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","filter":["all",["==","class","country"],["==","rank",1],["has","iso_a2"]],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":{"stops":[[1,11],[4,17]]},"text-transform":"uppercase","text-max-width":6.25,"visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}},{"id":"place-continent","type":"symbol","metadata":{"mapbox:group":"1444849242106.713"},"source":"openmaptiles","source-layer":"place","maxzoom":1,"filter":["==","class","continent"],"layout":{"text-font":["Noto Sans Bold"],"text-field":"{name:latin}","text-size":14,"text-max-width":6.25,"text-transform":"uppercase","visibility":"visible"},"paint":{"text-halo-blur":1,"text-color":"#334","text-halo-width":2,"text-halo-color":"rgba(255,255,255,0.8)"}}],"id":"qebnlkra6"}')},51962:function(t){"use strict";t.exports=JSON.parse('{"version":8,"name":"orto","metadata":{},"center":[1.537786,41.837539],"zoom":12,"bearing":0,"pitch":0,"light":{"anchor":"viewport","color":"white","intensity":0.4,"position":[1.15,45,30]},"sources":{"ortoEsri":{"type":"raster","tiles":["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],"tileSize":256,"maxzoom":18,"attribution":"ESRI © ESRI"},"ortoInstaMaps":{"type":"raster","tiles":["https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"],"tileSize":256,"maxzoom":13},"ortoICGC":{"type":"raster","tiles":["https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"],"tileSize":256,"minzoom":13.1,"maxzoom":20},"openmaptiles":{"type":"vector","url":"https://geoserveis.icgc.cat/contextmaps/basemap.json"}},"sprite":"https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1","glyphs":"https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#F4F9F4"}},{"id":"ortoEsri","type":"raster","source":"ortoEsri","maxzoom":16,"layout":{"visibility":"visible"}},{"id":"ortoICGC","type":"raster","source":"ortoICGC","minzoom":13.1,"maxzoom":19,"layout":{"visibility":"visible"}},{"id":"ortoInstaMaps","type":"raster","source":"ortoInstaMaps","maxzoom":13,"layout":{"visibility":"visible"}}]}')}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={id:n,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}return r.m=t,r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.b=document.baseURI||self.location.href,r.nc=void 0,r(20260)}()},t.exports=e()}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t=r(647),e=r.n(t),n=r(453),i=r.n(n),a=r(653),o=r.n(a);function s(t,e){let r;return function(...n){const i=this;clearTimeout(r),r=setTimeout((()=>t.apply(i,n)),e)}}function l(t){return Math.round(t.getTime()/1e3)}function c(t){return new Date(1e3*t)}function u(t,e){const r=document.getElementById("notifications"),n=document.getElementById("notification-template").content.cloneNode(!0).firstElementChild,i=n.querySelector(".btn-close");let a="";"info"===t?(n.classList.add("bg-primary","text-white"),i.classList.add("btn-close-white"),a="fa-circle-info"):"success"===t?(n.classList.add("bg-success","text-white"),i.classList.add("btn-close-white"),a="fa-circle-check"):"warning"===t?(n.classList.add("bg-warning","text-body"),a="fa-circle-exclamation"):"error"===t?(n.classList.add("bg-danger","text-white"),i.classList.add("btn-close-white"),a="fa-circle-exclamation"):(n.classList.add("bg-secondary","text-white"),i.classList.add("btn-close-white"),a="fa-comment"),n.querySelector(".toast-body").innerHTML=` `+e,r.appendChild(n);new(o())(n,{autohide:!0,delay:1e4}).show(),n.addEventListener("hidden.bs.toast",(()=>{n.remove()}))}const h="varnishmon.",f=`${h}time-range-from`,p=`${h}time-range-to`,d=["now-1h","now"];function m(t=!1){if(!t){const t=g(f),e=g(p);if(null!=t&&null!=e)return[t,e]}return varnishmon.config.scraper.enabled?d:[c(varnishmon.storage.earliest),c(varnishmon.storage.latest)]}function g(t){try{let e=localStorage.getItem(t);if(null!=e)return e}catch(e){console.error(`Failed to read '${t}' from local storage!`,e)}return null}function y(t,e){e instanceof Date&&(e=e.toISOString());try{localStorage.setItem(t,e)}catch(e){console.error(`Failed to write '${t}' to local storage!`,e)}}const v=`${h}refresh-interval`,x=[[-1,"auto"],[0,"disabled"],[1,"1s"],[2,"2s"],[3,"3s"],[4,"4s"],[5,"5s"],[10,"10s"],[15,"15s"],[30,"30s"],[60,"1m"]];function _(t){return Number.isInteger(t)&&x.map((t=>t[0])).includes(t)}const b=`${h}filter`,w=`${h}filter-history`;function T(){try{let t=localStorage.getItem(w);if(null!=t)return JSON.parse(t)}catch(t){console.error(`Failed to read '${w}' from local storage!`,t)}return[]}const k=`${h}verbosity`,A=["normal","debug"];function M(t){return A.includes(t)}const S=`${h}columns`,E=[1,2,3,4,6,12];function C(t){return Number.isInteger(t)&&E.includes(t)}const L=`${h}aggregator`,I=["avg","min","max","first","last","count"];function P(t){return I.includes(t)}const z=`${h}step`;function D(t){return Number.isInteger(t)&&t>=varnishmon.config.scraper.period}const O=[/^MGT[.](?!(?:uptime)$)/,new RegExp("MAIN[.](?!(?:"+["backend_busy","backend_conn","backend_fail","backend_recycle","backend_req","backend_retry","backend_reuse","backend_unhealthy","backend_wait_fail","backend_wait","bans_lurker_obj_killed_cutoff","bans_lurker_obj_killed","bans_obj_killed","bans","bgfetch_no_thread","busy_killed","busy_sleep","busy_wakeup","c_ykey_purges","cache_hit_grace","cache_hit","cache_hitmiss","cache_hitpass","cache_miss","client_req_400","client_req_417","client_req","client_resp_500","esi_errors","esi_maxdepth","esi_req","esi_warnings","fetch_1xx","fetch_204","fetch_304","fetch_bad","fetch_chunked","fetch_eof","fetch_failed","fetch_fast304","fetch_head","fetch_length","fetch_none","fetch_stale_deliver","fetch_stale_rearm","g_mem_file","g_mem_private","g_mem_rss","g_mem_swap","goto_dns_cache_hits","goto_dns_lookup_fails","goto_dns_lookups","losthdr","n_backend","n_expired","n_gunzip","n_gzip","n_lru_limited","n_lru_moved","n_lru_nuked","n_obj_purged","n_object_hitmiss","n_object_hitpass","n_object","n_objectcore","n_objecthead","n_purges","n_test_gunzip","n_vcl","req_dropped","req_reset","s_fetch","s_pass","s_pipe_hdrbytes","s_pipe_in","s_pipe_out","s_pipe","s_req_bodybytes","s_req_hdrbytes","s_resp_bodybytes","s_resp_hdrbytes","s_sess","s_synth","sc_bankrupt","sc_rapid_reset","sc_sock_closed","sc_vcl_failure","sess_closed_err","sess_closed","sess_conn","sess_drop","sess_dropped","sess_fail_ebadf","sess_fail_econnaborted","sess_fail_eintr","sess_fail_emfile","sess_fail_enomem","sess_fail_other","sess_fail","sess_herd","sess_queued","sess_readahead","shm_cont","shm_cycles","shm_flushes","shm_records","thread_queue_len","threads_created","threads_destroyed","threads_failed","threads_limited","threads","uptime","vcl_fail","vmods","ws_backend_overflow","ws_client_overflow","ws_session_overflow","ws_thread_overflow"].join("|")+")$)"),new RegExp("MSE[.](?!.*[.](?:"+["c_fail","c_memcache_hit","c_memcache_miss","c_ykey_purged","g_bytes","g_space","g_sparenode","g_ykey_keys","n_lru_moved","n_lru_nuked","n_vary"].join("|")+")$)"),new RegExp("MSE_BOOK[.](?!.*[.](?:"+["c_insert_timeout","c_waterlevel_purge","c_waterlevel_queue","c_waterlevel_runs","g_banlist_bytes","g_banlist_space","g_bytes","g_space","n_vary"].join("|")+")$)"),new RegExp("MSE_STORE[.](?!.*[.](?:"+["c_aio_finished_bytes_read","c_aio_finished_bytes_write","c_aio_finished_read","c_aio_finished_write","c_waterlevel_purge","c_waterlevel_queue","g_alloc_bytes","g_free_bytes","g_objects","g_ykey_keys"].join("|")+")$)"),new RegExp("MSE4[.](?!(?:"+["g_varyspec","g_ykey_keys","c_ykey_purged"].join("|")+")$)"),new RegExp("MSE4_MEM[.](?!(?:"+["c_allocation","c_allocation_buffer","c_allocation_ephemeral","c_allocation_failure","c_allocation_pass","c_allocation_persisted","c_allocation_reqbody","c_allocation_synthetic","c_eviction","c_eviction_failure","c_eviction_reorder","c_free","c_free_buffer","c_free_ephemeral","c_free_pass","c_free_persisted","c_free_reqbody","c_free_synthetic","c_memcache_hit","c_memcache_miss","g_allocations","g_bytes","g_bytes_buffer","g_bytes_ephemeral","g_bytes_pass","g_bytes_persisted","g_bytes_reqbody","g_bytes_synthetic","g_objects","g_objects_ephemeral","g_objects_pass","g_objects_persisted","g_objects_reqbody","g_objects_synthetic","g_space"].join("|")+")$)"),new RegExp("MSE4_BOOK[.](?!.*[.](?:"+["c_freeslot_queued","c_submitslot_queued","c_ykey_purged","g_freeslot_queue","g_objects","g_slots_unused","g_slots_used","g_submitslot_queue","g_unreachable_objects","g_varyspec","g_ykey_keys","online"].join("|")+")$)"),new RegExp("MSE4_STORE[.](?!.*[.](?:"+["online","g_bytes_used","g_bytes_unused","g_objects","g_allocation_queue","c_allocation_queued","g_io_queued","g_io_queued_read","g_io_queued_write","c_io_finished_read","c_io_finished_write","c_io_finished_bytes_read","c_io_finished_bytes_write","g_io_blocked_read","g_io_blocked_write","c_io_limited"].join("|")+")$)"),new RegExp("MSE4_BANJRN[.](?!.*[.](?:"+["g_ban_bytes","g_bans","g_bytes","g_overflow_ban_bytes","g_overflow_bans","g_space"].join("|")+")$)"),new RegExp("MSE4_CAT[.](?!.*[.](?:"+["c_allocation","c_allocation_ephemeral","c_allocation_pass","c_allocation_persisted","c_eviction","c_eviction_failure","c_eviction_reorder","c_free","c_free_ephemeral","c_free_pass","c_free_persisted","c_memcache_hit","c_memcache_miss","g_allocations","g_bytes","g_bytes_ephemeral","g_bytes_pass","g_bytes_persisted","g_objects","g_objects_ephemeral","g_objects_pass","g_objects_persisted"].join("|")+")$)"),new RegExp("SMA[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_space"].join("|")+")$)"),new RegExp("SMF[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_smf_frag","g_smf_large","g_smf","g_space"].join("|")+")$)"),new RegExp("SMU[.](?!.*[.](?:"+["c_bytes","c_fail","c_freed","c_req","g_alloc","g_bytes","g_space"].join("|")+")$)"),/^BROTLI[.]/,/^SLICER[.]/,new RegExp("VMOD_HTTP[.](?!(?:"+["handle_abandon","handle_completed","handle_internal_error","handle_limited","handle_requests"].join("|")+")$)"),new RegExp("KVSTORE[.](?!.*[.](?:"+[].join("|")+")$)"),new RegExp("ACCG[.](?!.*[.](?:"+["backend_200_count","backend_2xx_count","backend_304_count","backend_3xx_count","backend_404_count","backend_4xx_count","backend_503_count","backend_5xx_count","backend_req_bodybytes","backend_req_count","backend_req_hdrbytes","backend_resp_bodybytes","backend_resp_hdrbytes","client_200_count","client_2xx_count","client_304_count","client_3xx_count","client_404_count","client_4xx_count","client_503_count","client_5xx_count","client_grace_hit_count","client_hit_count","client_hit_req_bodybytes","client_hit_req_hdrbytes","client_hit_resp_bodybytes","client_hit_resp_hdrbytes","client_miss_count","client_miss_req_bodybytes","client_miss_req_hdrbytes","client_miss_resp_bodybytes","client_miss_resp_hdrbytes","client_pass_count","client_pass_req_bodybytes","client_pass_req_hdrbytes","client_pass_resp_bodybytes","client_pass_resp_hdrbytes","client_pipe_count","client_pipe_req_bodybytes","client_pipe_req_hdrbytes","client_pipe_resp_bodybytes","client_pipe_resp_hdrbytes","client_req_bodybytes","client_req_count","client_req_hdrbytes","client_resp_bodybytes","client_resp_hdrbytes","client_synth_count","client_synth_req_bodybytes","client_synth_req_hdrbytes","client_synth_resp_bodybytes","client_synth_resp_hdrbytes"].join("|")+")$)"),new RegExp("ACCG_DIAG[.](?!.*[.](?:"+["bereq_dropped","create_namespace_failure","key_without_namespace","namespace_already_set","namespace_undefined","out_of_key_slots","req_dropped","set_key_failure"].join("|")+")$)"),new RegExp("VBE[.](?!.*[.](?:"+["bereq_bodybytes","bereq_hdrbytes","beresp_bodybytes","beresp_hdrbytes","busy","conn","fail","happy","is_healthy","pipe_hdrbytes","pipe_in","pipe_out","req","unhealthy"].join("|")+")$)"),/^WAITER[.]/,/^MEMPOOL[.]/,/^LCK[.]/],R=[/^(MAIN[.]backend)/,/^(MAIN[.]bans)_?/,/^(MAIN[.]cache)/,/^(MAIN[.]client)/,/^(MAIN[.]esi_)/,/^(MAIN[.]fetch)/,/^(MAIN[.]g_mem)/,/^(MAIN[.]s_)/,/^(MAIN[.]sc_)/,/^(MAIN[.]sess_)/,/^(MAIN[.]shm_)/,/^(MAIN[.]thread)s?_?/,/^(MAIN[.]vgs_)/,/^(MAIN[.]ws_)/,/^(WAITER[.])/,/^(MEMPOOL[.])/,/^(LCK[.])/],F=[/^MGT[.]/,/^MAIN[.][*]$/,/^MAIN[.]/,/^MSE[.]/,/^MSE_/,/^MSE4[.]/,/^MSE4_/,/^SMA[.]/,/^SMF[.]/,/^SMU[.]/,/^BROTLI[.]/,/^SLICER[.]/,/^VMOD_/,/^KVSTORE[.]/,/^ACCG[.]/,/^ACCG_DIAG[.]/,/^VBE[.]/,/^WAITER[.]/,/^MEMPOOL[.]/,/^LCK[.]/];function B(t){t.sort(((t,e)=>t.name.localeCompare(e.name))),function(t){t.forEach((t=>{t.debug=-1!==O.findIndex((e=>e.test(t.name)))}))}(t);const e=function(t){const e={};return t.forEach((t=>{let r="";for(let e of R){const n=t.name.match(e);if(n&&n[1]){r=n[1]+"*";break}}if(""===r){const e=t.name.split(".");e.length>1&&(r=e.slice(0,-1).join(".")+".*")}e[r]||(e[r]=[]),e[r].push(t)})),Object.keys(e).map((t=>({name:t,metrics:e[t]})))}(t);return e.sort(((t,e)=>{const r=F.findIndex((e=>e.test(t.name))),n=F.findIndex((t=>t.test(e.name)));return-1!==r&&-1!==n?r-n:-1!==r?-1:-1!==n?1:t.name.localeCompare(e.name)})),e}function N(t,e){const r=t.sort(((t,e)=>t[0]-e[0])),n=[];for(let t=0;t{t.forEach((t=>{t.target.chart.handleVisibilityChange(t.isIntersecting)}))}),{threshold:.1}),G=new ResizeObserver((t=>{t.forEach((t=>{t.target.chart.handleSizeChange()}))}));const W=class{constructor(t,e,r,n,i,a){this.container=t,this.metric=e,this.rangeFactory=r,this.refreshInterval=n,this.aggregator=i,this.step=a,this.listeners={},this.initializing=!1,this.refreshing=!1,this.debouncedHandleRefresh=s(this.handleRefresh.bind(this),500),this.visible=!1,this.interval=null,this.lastRefresh=0,this.pendingRefresh=!1,this.error=null,this.graph={element:null,x:null,y:null,step:null,range:null,zoomRange:null},H.observe(this.container),G.observe(this.container)}async init(){if(!this.initializing){this.initializing=!0;try{this.processMetric(await this.getMetric()),this.graph.element=this.renderGraph(),this.setupInterval(),this.lastRefresh=l(new Date),this.pendingRefresh=!1}catch(t){this.setError(`Failed to fetch samples of a metric: ${t}`)}finally{this.initializing=!1}}}async handleRefresh(){if(!this.refreshing){this.refreshing=!0;try{if(null!=this.graph.element&&(this.pendingRefresh=!0,this.visible))try{this.processMetric(await this.getMetric()),this.updateGraph(!1),this.clearError(),this.lastRefresh=l(new Date),this.pendingRefresh=!1}catch(t){this.setError(`Failed to fetch samples of a metric: ${t}`)}}finally{this.refreshing=!1}}}handleVisibilityChange(t){this.visible=t,this.visible?null==this.graph.element?this.init():(null==this.interval&&this.setupInterval(),(this.pendingRefresh||this.refreshInterval>0&&l(new Date)-this.lastRefresh>this.refreshInterval)&&this.debouncedHandleRefresh()):this.stopInterval()}handleSizeChange(){null!=this.graph.element&&this.debouncedHandleRefresh()}handleGraphRelayout(t){if(t["xaxis.range[0]"]&&t["xaxis.range[1]"]?this.graph.zoomRange=[new Date(t["xaxis.range[0]"]),new Date(t["xaxis.range[1]"])]:(t["xaxis.range"]&&Array.isArray(t["xaxis.range"])&&t["xaxis.range"].length,this.graph.zoomRange=null),null!=this.graph.zoomRange&&(l(this.graph.zoomRange[0])l(this.graph.range[1])&&(this.graph.zoomRange[1]=this.graph.range[1])),null!=this.graph.zoomRange){const t=l(this.graph.zoomRange[1])-l(this.graph.zoomRange[0]);if(tt!==e)))}notifyEventListeners(t,e){this.listeners[t]&&this.listeners[t].forEach((t=>t(e)))}redraw(t,e,r){let n="normal"===e&&this.metric.debug;if(!n){const e=t.split(/\s+/).filter((t=>t.length>0));e.length>0&&(n=!e.some((t=>this.metric.name.includes(t))))}this.container.classList.toggle("d-none",n),this.container.classList.forEach((t=>{t.startsWith("col-")&&this.container.classList.remove(t)})),this.container.classList.add("col-"+12/r)}setRefreshInterval(t){this.refreshInterval=t,this.visible&&null!=this.graph.element&&this.setupInterval()}refresh(){null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setAggregator(t){this.aggregator=t,null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setStep(t){this.step=t,null!=this.graph.element&&(this.visible&&this.setupInterval(),this.handleRefresh())}setZoomRange(t){this.graph.zoomRange=t,null!=this.graph.element&&this.updateGraph(!0)}destroy(){H.unobserve(this.container),G.unobserve(this.container),this.stopInterval(),this.clearError(),null!=this.graph.element&&U().purge(this.graph.element)}setupInterval(){this.stopInterval(),this.refreshInterval>0&&(this.interval=setInterval(this.handleRefresh.bind(this),1e3*this.refreshInterval))}stopInterval(){null!=this.interval&&(clearInterval(this.interval),this.interval=null)}setError(t){const e=this.container.querySelector(".card"),r=e.querySelector(".error-icon");null==this.error&&(e.classList.add("border-danger"),r.classList.remove("d-none"));const n=`${(new Date).toISOString()}: ${t}`;let i=q().getInstance(r);null==i?i=new(q())(r,{title:n}):i.setContent({".tooltip-inner":n}),this.error=t}clearError(){if(null!=this.error){const t=this.container.querySelector(".card");t.classList.remove("border-danger");const e=t.querySelector(".error-icon");e.classList.add("d-none");q().getInstance(e).dispose(),this.error=null}}async getMetric(){const t=this.container.querySelector(".card .loading-icon");t.classList.remove("d-none");try{const[t,e]=this.rangeFactory(),r=this.estimateOptimalStep(t,e),n="b"===this.metric.flag?"bit_and":this.aggregator;return await async function(t,e,r,n,i){const a=new URLSearchParams({from:l(e),to:l(r),step:n,aggregator:i}),o=await fetch(`/storage/metrics/${t}?${a.toString()}`);if(!o.ok)throw new Error(`Unexpected API response (${o.status}): ${o.statusText}`);const s=await o.json();return{from:c(s.from),to:c(s.to),step:s.step,samples:N(s.samples,s.step)}}(this.metric.id,t,e,r,n)}finally{t.classList.add("d-none")}}estimateOptimalStep(t,e){const r=(l(e)-l(t))/this.step,n=this.container.clientWidth,i=Math.floor(.9*n);if(i<=0)throw new Error("Failed to estimate the optimal step");return r<=i?this.step:Math.ceil(r/i)*this.step}processMetric(t){this.graph.x=[],this.graph.y=[],t.samples.forEach((t=>{this.graph.x.push(t[0]),this.graph.y.push("b"===this.metric.flag?BigInt(`0x${t[1]}`).toString(2).split("").filter((t=>"1"===t)).length:t[1])})),this.graph.step=t.step,this.graph.range=[t.from,new Date(t.to.getTime()-1e3*t.step)];const e=this.container.querySelector(".card .step-factor");if(this.graph.step!==this.step){const t=Math.round(this.graph.step/this.step);e.innerHTML=` ${t}x`}else e.innerHTML=""}renderGraph(){const t=null!=this.graph.zoomRange?this.graph.zoomRange:this.graph.range,e=[{x:this.graph.x,y:this.graph.y,type:"scatter",mode:this.estimatePlotlyDataMode(...t,this.graph.step),marker:{size:4},hovertemplate:"X: %{x|%Y-%m-%d %H:%M:%S}
Y: %{y:,.1f}",connectgaps:!1,line:{shape:"linear",width:2}}],r={autosize:!0,title:{text:this.metric.name,font:{size:14},subtitle:{text:this.metric.description}},margin:{l:60,r:10,b:40,t:40,pad:5},xaxis:{fixedrange:!1,griddash:"dash",range:Array.from(t),autorange:!1},yaxis:{fixedrange:!0,griddash:"dash",rangemode:"normal",title:(()=>{if("c"===this.metric.flag)return"d"===this.metric.format?"seconds":"B"===this.metric.format?"Bps":"eps";if("g"===this.metric.flag){if("d"===this.metric.format)return"seconds";if("B"===this.metric.format)return"bytes"}return""})()}},n={responsive:!0,displaylogo:!1,modeBarButtonsToRemove:["zoom2d","pan2d","select2d","lasso2d","autoScale2d"],toImageButtonOptions:{filename:`${varnishmon.storage.hostname} - ${this.metric.name}`,format:"png"},scrollZoom:!1},i=this.container.querySelector(".graph");return U().newPlot(i,e,r,n),i.on("plotly_relayout",this.handleGraphRelayout.bind(this)),i}updateGraph(t){const e=null!=this.graph.zoomRange?this.graph.zoomRange:this.graph.range,r={mode:this.estimatePlotlyDataMode(...e,this.graph.step)};t||(r.x=[this.graph.x],r.y=[this.graph.y]);const n={xaxis:{range:Array.from(e)}};U().update(this.graph.element,r,n)}estimatePlotlyDataMode(t,e,r){const n=(l(e)-l(t))/r,i=this.container.clientWidth;return n>Math.floor(.9*i/6)?"lines":"lines+markers"}};var Z=["onChange","onClose","onDayCreate","onDestroy","onKeyDown","onMonthChange","onOpen","onParseConfig","onReady","onValueUpdate","onYearChange","onPreCalendarPosition"],Y={_disable:[],allowInput:!1,allowInvalidPreload:!1,altFormat:"F j, Y",altInput:!1,altInputClass:"form-control input",animate:"object"==typeof window&&-1===window.navigator.userAgent.indexOf("MSIE"),ariaDateFormat:"F j, Y",autoFillDefaultTime:!0,clickOpens:!0,closeOnSelect:!0,conjunction:", ",dateFormat:"Y-m-d",defaultHour:12,defaultMinute:0,defaultSeconds:0,disable:[],disableMobile:!1,enableSeconds:!1,enableTime:!1,errorHandler:function(t){return"undefined"!=typeof console&&console.warn(t)},getWeek:function(t){var e=new Date(t.getTime());e.setHours(0,0,0,0),e.setDate(e.getDate()+3-(e.getDay()+6)%7);var r=new Date(e.getFullYear(),0,4);return 1+Math.round(((e.getTime()-r.getTime())/864e5-3+(r.getDay()+6)%7)/7)},hourIncrement:1,ignoredFocusElements:[],inline:!1,locale:"default",minuteIncrement:5,mode:"single",monthSelectorType:"dropdown",nextArrow:"",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},X={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(t){var e=t%100;if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1};const $=X;var J=function(t,e){return void 0===e&&(e=2),("000"+t).slice(-1*e)},K=function(t){return!0===t?1:0};function Q(t,e){var r;return function(){var n=this,i=arguments;clearTimeout(r),r=setTimeout((function(){return t.apply(n,i)}),e)}}var tt=function(t){return t instanceof Array?t:[t]};function et(t,e,r){if(!0===r)return t.classList.add(e);t.classList.remove(e)}function rt(t,e,r){var n=window.document.createElement(t);return e=e||"",r=r||"",n.className=e,void 0!==r&&(n.textContent=r),n}function nt(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function it(t,e){return e(t)?t:t.parentNode?it(t.parentNode,e):void 0}function at(t,e){var r=rt("div","numInputWrapper"),n=rt("input","numInput "+t),i=rt("span","arrowUp"),a=rt("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?n.type="number":(n.type="text",n.pattern="\\d*"),void 0!==e)for(var o in e)n.setAttribute(o,e[o]);return r.appendChild(n),r.appendChild(i),r.appendChild(a),r}function ot(t){try{return"function"==typeof t.composedPath?t.composedPath()[0]:t.target}catch(e){return t.target}}var st=function(){},lt=function(t,e,r){return r.months[e?"shorthand":"longhand"][t]},ct={D:st,F:function(t,e,r){t.setMonth(r.months.longhand.indexOf(e))},G:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},H:function(t,e){t.setHours(parseFloat(e))},J:function(t,e){t.setDate(parseFloat(e))},K:function(t,e,r){t.setHours(t.getHours()%12+12*K(new RegExp(r.amPM[1],"i").test(e)))},M:function(t,e,r){t.setMonth(r.months.shorthand.indexOf(e))},S:function(t,e){t.setSeconds(parseFloat(e))},U:function(t,e){return new Date(1e3*parseFloat(e))},W:function(t,e,r){var n=parseInt(e),i=new Date(t.getFullYear(),0,2+7*(n-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+r.firstDayOfWeek),i},Y:function(t,e){t.setFullYear(parseFloat(e))},Z:function(t,e){return new Date(e)},d:function(t,e){t.setDate(parseFloat(e))},h:function(t,e){t.setHours((t.getHours()>=12?12:0)+parseFloat(e))},i:function(t,e){t.setMinutes(parseFloat(e))},j:function(t,e){t.setDate(parseFloat(e))},l:st,m:function(t,e){t.setMonth(parseFloat(e)-1)},n:function(t,e){t.setMonth(parseFloat(e)-1)},s:function(t,e){t.setSeconds(parseFloat(e))},u:function(t,e){return new Date(parseFloat(e))},w:st,y:function(t,e){t.setFullYear(2e3+parseFloat(e))}},ut={D:"",F:"",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},ht={Z:function(t){return t.toISOString()},D:function(t,e,r){return e.weekdays.shorthand[ht.w(t,e,r)]},F:function(t,e,r){return lt(ht.n(t,e,r)-1,!1,e)},G:function(t,e,r){return J(ht.h(t,e,r))},H:function(t){return J(t.getHours())},J:function(t,e){return void 0!==e.ordinal?t.getDate()+e.ordinal(t.getDate()):t.getDate()},K:function(t,e){return e.amPM[K(t.getHours()>11)]},M:function(t,e){return lt(t.getMonth(),!0,e)},S:function(t){return J(t.getSeconds())},U:function(t){return t.getTime()/1e3},W:function(t,e,r){return r.getWeek(t)},Y:function(t){return J(t.getFullYear(),4)},d:function(t){return J(t.getDate())},h:function(t){return t.getHours()%12?t.getHours()%12:12},i:function(t){return J(t.getMinutes())},j:function(t){return t.getDate()},l:function(t,e){return e.weekdays.longhand[t.getDay()]},m:function(t){return J(t.getMonth()+1)},n:function(t){return t.getMonth()+1},s:function(t){return t.getSeconds()},u:function(t){return t.getTime()},w:function(t){return t.getDay()},y:function(t){return String(t.getFullYear()).substring(2)}},ft=function(t){var e=t.config,r=void 0===e?Y:e,n=t.l10n,i=void 0===n?X:n,a=t.isMobile,o=void 0!==a&&a;return function(t,e,n){var a=n||i;return void 0===r.formatDate||o?e.split("").map((function(e,n,i){return ht[e]&&"\\"!==i[n-1]?ht[e](t,a,r):"\\"!==e?e:""})).join(""):r.formatDate(t,e,a)}},pt=function(t){var e=t.config,r=void 0===e?Y:e,n=t.l10n,i=void 0===n?X:n;return function(t,e,n,a){if(0===t||t){var o,s=a||i,l=t;if(t instanceof Date)o=new Date(t.getTime());else if("string"!=typeof t&&void 0!==t.toFixed)o=new Date(t);else if("string"==typeof t){var c=e||(r||Y).dateFormat,u=String(t).trim();if("today"===u)o=new Date,n=!0;else if(r&&r.parseDate)o=r.parseDate(t,c);else if(/Z$/.test(u)||/GMT$/.test(u))o=new Date(t);else{for(var h=void 0,f=[],p=0,d=0,m="";p=0?new Date:new Date(r.config.minDate.getTime()),n=yt(r.config);e.setHours(n.hours,n.minutes,n.seconds,e.getMilliseconds()),r.selectedDates=[e],r.latestSelectedDateObj=e}void 0!==t&&"blur"!==t.type&&function(t){t.preventDefault();var e="keydown"===t.type,n=ot(t),i=n;void 0!==r.amPM&&n===r.amPM&&(r.amPM.textContent=r.l10n.amPM[K(r.amPM.textContent===r.l10n.amPM[0])]);var a=parseFloat(i.getAttribute("min")),o=parseFloat(i.getAttribute("max")),s=parseFloat(i.getAttribute("step")),l=parseInt(i.value,10),c=t.delta||(e?38===t.which?1:-1:0),u=l+s*c;if(void 0!==i.value&&2===i.value.length){var h=i===r.hourElement,f=i===r.minuteElement;uo&&(u=i===r.hourElement?u-o-K(!r.amPM):a,f&&m(void 0,1,r.hourElement)),r.amPM&&h&&(1===s?u+l===23:Math.abs(u-l)>s)&&(r.amPM.textContent=r.l10n.amPM[K(r.amPM.textContent===r.l10n.amPM[0])]),i.value=J(u)}}(t);var i=r._input.value;s(),Tt(),r._input.value!==i&&r._debouncedChange()}function s(){if(void 0!==r.hourElement&&void 0!==r.minuteElement){var t,e,n=(parseInt(r.hourElement.value.slice(-2),10)||0)%24,i=(parseInt(r.minuteElement.value,10)||0)%60,a=void 0!==r.secondElement?(parseInt(r.secondElement.value,10)||0)%60:0;void 0!==r.amPM&&(t=n,e=r.amPM.textContent,n=t%12+12*K(e===r.l10n.amPM[1]));var o=void 0!==r.config.minTime||r.config.minDate&&r.minDateHasTime&&r.latestSelectedDateObj&&0===dt(r.latestSelectedDateObj,r.config.minDate,!0),s=void 0!==r.config.maxTime||r.config.maxDate&&r.maxDateHasTime&&r.latestSelectedDateObj&&0===dt(r.latestSelectedDateObj,r.config.maxDate,!0);if(void 0!==r.config.maxTime&&void 0!==r.config.minTime&&r.config.minTime>r.config.maxTime){var l=mt(r.config.minTime.getHours(),r.config.minTime.getMinutes(),r.config.minTime.getSeconds()),u=mt(r.config.maxTime.getHours(),r.config.maxTime.getMinutes(),r.config.maxTime.getSeconds()),h=mt(n,i,a);if(h>u&&h=12)]),void 0!==r.secondElement&&(r.secondElement.value=J(n)))}function u(t){var e=ot(t),r=parseInt(e.value)+(t.delta||0);(r/1e3>1||"Enter"===t.key&&!/[^\d]/.test(r.toString()))&&L(r)}function h(t,e,n,i){return e instanceof Array?e.forEach((function(e){return h(t,e,n,i)})):t instanceof Array?t.forEach((function(t){return h(t,e,n,i)})):(t.addEventListener(e,n,i),void r._handlers.push({remove:function(){return t.removeEventListener(e,n,i)}}))}function f(){st("onChange")}function p(t,e){var n=void 0!==t?r.parseDate(t):r.latestSelectedDateObj||(r.config.minDate&&r.config.minDate>r.now?r.config.minDate:r.config.maxDate&&r.config.maxDate=0&&dt(t,r.selectedDates[1])<=0)}(e)&&!ht(e)&&o.classList.add("inRange"),r.weekNumbers&&1===r.config.showMonths&&"prevMonthDay"!==t&&i%7==6&&r.weekNumbers.insertAdjacentHTML("beforeend",""+r.config.getWeek(e)+""),st("onDayCreate",o),o}function y(t){t.focus(),"range"===r.config.mode&&O(t)}function v(t){for(var e=t>0?0:r.config.showMonths-1,n=t>0?r.config.showMonths:-1,i=e;i!=n;i+=t)for(var a=r.daysContainer.children[i],o=t>0?0:a.children.length-1,s=t>0?a.children.length:-1,l=o;l!=s;l+=t){var c=a.children[l];if(-1===c.className.indexOf("hidden")&&I(c.dateObj))return c}}function x(t,e){var i=n(),a=P(i||document.body),o=void 0!==t?t:a?i:void 0!==r.selectedDateElem&&P(r.selectedDateElem)?r.selectedDateElem:void 0!==r.todayDateElem&&P(r.todayDateElem)?r.todayDateElem:v(e>0?1:-1);void 0===o?r._input.focus():a?function(t,e){for(var n=-1===t.className.indexOf("Month")?t.dateObj.getMonth():r.currentMonth,i=e>0?r.config.showMonths:-1,a=e>0?1:-1,o=n-r.currentMonth;o!=i;o+=a)for(var s=r.daysContainer.children[o],l=n-r.currentMonth===o?t.$i+e:e<0?s.children.length-1:0,c=s.children.length,u=l;u>=0&&u0?c:-1);u+=a){var h=s.children[u];if(-1===h.className.indexOf("hidden")&&I(h.dateObj)&&Math.abs(t.$i-u)>=Math.abs(e))return y(h)}r.changeMonth(a),x(v(a),0)}(o,e):y(o)}function _(t,e){for(var n=(new Date(t,e,1).getDay()-r.l10n.firstDayOfWeek+7)%7,i=r.utils.getDaysInMonth((e-1+12)%12,t),a=r.utils.getDaysInMonth(e,t),o=window.document.createDocumentFragment(),s=r.config.showMonths>1,l=s?"prevMonthDay hidden":"prevMonthDay",c=s?"nextMonthDay hidden":"nextMonthDay",u=i+1-n,h=0;u<=i;u++,h++)o.appendChild(g("flatpickr-day "+l,new Date(t,e-1,u),0,h));for(u=1;u<=a;u++,h++)o.appendChild(g("flatpickr-day",new Date(t,e,u),0,h));for(var f=a+1;f<=42-n&&(1===r.config.showMonths||h%7!=0);f++,h++)o.appendChild(g("flatpickr-day "+c,new Date(t,e+1,f%a),0,h));var p=rt("div","dayContainer");return p.appendChild(o),p}function b(){if(void 0!==r.daysContainer){nt(r.daysContainer),r.weekNumbers&&nt(r.weekNumbers);for(var t=document.createDocumentFragment(),e=0;e1||"dropdown"!==r.config.monthSelectorType)){var t=function(t){return!(void 0!==r.config.minDate&&r.currentYear===r.config.minDate.getFullYear()&&tr.config.maxDate.getMonth())};r.monthsDropdownContainer.tabIndex=-1,r.monthsDropdownContainer.innerHTML="";for(var e=0;e<12;e++)if(t(e)){var n=rt("option","flatpickr-monthDropdown-month");n.value=new Date(r.currentYear,e).getMonth().toString(),n.textContent=lt(e,r.config.shorthandCurrentMonth,r.l10n),n.tabIndex=-1,r.currentMonth===e&&(n.selected=!0),r.monthsDropdownContainer.appendChild(n)}}}function T(){var t,e=rt("div","flatpickr-month"),n=window.document.createDocumentFragment();r.config.showMonths>1||"static"===r.config.monthSelectorType?t=rt("span","cur-month"):(r.monthsDropdownContainer=rt("select","flatpickr-monthDropdown-months"),r.monthsDropdownContainer.setAttribute("aria-label",r.l10n.monthAriaLabel),h(r.monthsDropdownContainer,"change",(function(t){var e=ot(t),n=parseInt(e.value,10);r.changeMonth(n-r.currentMonth),st("onMonthChange")})),w(),t=r.monthsDropdownContainer);var i=at("cur-year",{tabindex:"-1"}),a=i.getElementsByTagName("input")[0];a.setAttribute("aria-label",r.l10n.yearAriaLabel),r.config.minDate&&a.setAttribute("min",r.config.minDate.getFullYear().toString()),r.config.maxDate&&(a.setAttribute("max",r.config.maxDate.getFullYear().toString()),a.disabled=!!r.config.minDate&&r.config.minDate.getFullYear()===r.config.maxDate.getFullYear());var o=rt("div","flatpickr-current-month");return o.appendChild(t),o.appendChild(i),n.appendChild(o),e.appendChild(n),{container:e,yearElement:a,monthElement:t}}function k(){nt(r.monthNav),r.monthNav.appendChild(r.prevMonthNav),r.config.showMonths&&(r.yearElements=[],r.monthElements=[]);for(var t=r.config.showMonths;t--;){var e=T();r.yearElements.push(e.yearElement),r.monthElements.push(e.monthElement),r.monthNav.appendChild(e.container)}r.monthNav.appendChild(r.nextMonthNav)}function A(){r.weekdayContainer?nt(r.weekdayContainer):r.weekdayContainer=rt("div","flatpickr-weekdays");for(var t=r.config.showMonths;t--;){var e=rt("div","flatpickr-weekdaycontainer");r.weekdayContainer.appendChild(e)}return M(),r.weekdayContainer}function M(){if(r.weekdayContainer){var t=r.l10n.firstDayOfWeek,e=xt(r.l10n.weekdays.shorthand);t>0&&t\n "+e.join("")+"\n \n "}}function S(t,e){void 0===e&&(e=!0);var n=e?t:t-r.currentMonth;n<0&&!0===r._hidePrevMonthArrow||n>0&&!0===r._hideNextMonthArrow||(r.currentMonth+=n,(r.currentMonth<0||r.currentMonth>11)&&(r.currentYear+=r.currentMonth>11?1:-1,r.currentMonth=(r.currentMonth+12)%12,st("onYearChange"),w()),b(),st("onMonthChange"),_t())}function E(t){return r.calendarContainer.contains(t)}function C(t){if(r.isOpen&&!r.config.inline){var e=ot(t),n=E(e),i=!(e===r.input||e===r.altInput||r.element.contains(e)||t.path&&t.path.indexOf&&(~t.path.indexOf(r.input)||~t.path.indexOf(r.altInput)))&&!n&&!E(t.relatedTarget),a=!r.config.ignoredFocusElements.some((function(t){return t.contains(e)}));i&&a&&(r.config.allowInput&&r.setDate(r._input.value,!1,r.config.altInput?r.config.altFormat:r.config.dateFormat),void 0!==r.timeContainer&&void 0!==r.minuteElement&&void 0!==r.hourElement&&""!==r.input.value&&void 0!==r.input.value&&o(),r.close(),r.config&&"range"===r.config.mode&&1===r.selectedDates.length&&r.clear(!1))}}function L(t){if(!(!t||r.config.minDate&&tr.config.maxDate.getFullYear())){var e=t,n=r.currentYear!==e;r.currentYear=e||r.currentYear,r.config.maxDate&&r.currentYear===r.config.maxDate.getFullYear()?r.currentMonth=Math.min(r.config.maxDate.getMonth(),r.currentMonth):r.config.minDate&&r.currentYear===r.config.minDate.getFullYear()&&(r.currentMonth=Math.max(r.config.minDate.getMonth(),r.currentMonth)),n&&(r.redraw(),st("onYearChange"),w())}}function I(t,e){var n;void 0===e&&(e=!0);var i=r.parseDate(t,void 0,e);if(r.config.minDate&&i&&dt(i,r.config.minDate,void 0!==e?e:!r.minDateHasTime)<0||r.config.maxDate&&i&&dt(i,r.config.maxDate,void 0!==e?e:!r.maxDateHasTime)>0)return!1;if(!r.config.enable&&0===r.config.disable.length)return!0;if(void 0===i)return!1;for(var a=!!r.config.enable,o=null!==(n=r.config.enable)&&void 0!==n?n:r.config.disable,s=0,l=void 0;s=l.from.getTime()&&i.getTime()<=l.to.getTime())return a}return!a}function P(t){return void 0!==r.daysContainer&&(-1===t.className.indexOf("hidden")&&-1===t.className.indexOf("flatpickr-disabled")&&r.daysContainer.contains(t))}function z(t){var e=t.target===r._input,n=r._input.value.trimEnd()!==bt();!e||!n||t.relatedTarget&&E(t.relatedTarget)||r.setDate(r._input.value,!0,t.target===r.altInput?r.config.altFormat:r.config.dateFormat)}function D(e){var i=ot(e),a=r.config.wrap?t.contains(i):i===r._input,l=r.config.allowInput,c=r.isOpen&&(!l||!a),u=r.config.inline&&a&&!l;if(13===e.keyCode&&a){if(l)return r.setDate(r._input.value,!0,i===r.altInput?r.config.altFormat:r.config.dateFormat),r.close(),i.blur();r.open()}else if(E(i)||c||u){var h=!!r.timeContainer&&r.timeContainer.contains(i);switch(e.keyCode){case 13:h?(e.preventDefault(),o(),V()):q(e);break;case 27:e.preventDefault(),V();break;case 8:case 46:a&&!r.config.allowInput&&(e.preventDefault(),r.clear());break;case 37:case 39:if(h||a)r.hourElement&&r.hourElement.focus();else{e.preventDefault();var f=n();if(void 0!==r.daysContainer&&(!1===l||f&&P(f))){var p=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),S(p),x(v(1),0)):x(void 0,p)}}break;case 38:case 40:e.preventDefault();var d=40===e.keyCode?1:-1;r.daysContainer&&void 0!==i.$i||i===r.input||i===r.altInput?e.ctrlKey?(e.stopPropagation(),L(r.currentYear-d),x(v(1),0)):h||x(void 0,7*d):i===r.currentYearElement?L(r.currentYear-d):r.config.enableTime&&(!h&&r.hourElement&&r.hourElement.focus(),o(e),r._debouncedChange());break;case 9:if(h){var m=[r.hourElement,r.minuteElement,r.secondElement,r.amPM].concat(r.pluginElements).filter((function(t){return t})),g=m.indexOf(i);if(-1!==g){var y=m[g+(e.shiftKey?-1:1)];e.preventDefault(),(y||r._input).focus()}}else!r.config.noCalendar&&r.daysContainer&&r.daysContainer.contains(i)&&e.shiftKey&&(e.preventDefault(),r._input.focus())}}if(void 0!==r.amPM&&i===r.amPM)switch(e.key){case r.l10n.amPM[0].charAt(0):case r.l10n.amPM[0].charAt(0).toLowerCase():r.amPM.textContent=r.l10n.amPM[0],s(),Tt();break;case r.l10n.amPM[1].charAt(0):case r.l10n.amPM[1].charAt(0).toLowerCase():r.amPM.textContent=r.l10n.amPM[1],s(),Tt()}(a||E(i))&&st("onKeyDown",e)}function O(t,e){if(void 0===e&&(e="flatpickr-day"),1===r.selectedDates.length&&(!t||t.classList.contains(e)&&!t.classList.contains("flatpickr-disabled"))){for(var n=t?t.dateObj.getTime():r.days.firstElementChild.dateObj.getTime(),i=r.parseDate(r.selectedDates[0],void 0,!0).getTime(),a=Math.min(n,r.selectedDates[0].getTime()),o=Math.max(n,r.selectedDates[0].getTime()),s=!1,l=0,c=0,u=a;ua&&ul)?l=u:u>i&&(!c||u ."+e)).forEach((function(e){var a,o,u,h=e.dateObj.getTime(),f=l>0&&h0&&h>c;if(f)return e.classList.add("notAllowed"),void["inRange","startRange","endRange"].forEach((function(t){e.classList.remove(t)}));s&&!f||(["startRange","inRange","endRange","notAllowed"].forEach((function(t){e.classList.remove(t)})),void 0!==t&&(t.classList.add(n<=r.selectedDates[0].getTime()?"startRange":"endRange"),in&&h===i&&e.classList.add("endRange"),h>=l&&(0===c||h<=c)&&(o=i,u=n,(a=h)>Math.min(o,u)&&a0||n.getMinutes()>0||n.getSeconds()>0),r.selectedDates&&(r.selectedDates=r.selectedDates.filter((function(t){return I(t)})),r.selectedDates.length||"min"!==t||l(n),Tt()),r.daysContainer&&(U(),void 0!==n?r.currentYearElement[t]=n.getFullYear().toString():r.currentYearElement.removeAttribute(t),r.currentYearElement.disabled=!!i&&void 0!==n&&i.getFullYear()===n.getFullYear())}}function B(){return r.config.wrap?t.querySelector("[data-input]"):t}function N(){"object"!=typeof r.config.locale&&void 0===wt.l10ns[r.config.locale]&&r.config.errorHandler(new Error("flatpickr: invalid locale "+r.config.locale)),r.l10n=vt(vt({},wt.l10ns.default),"object"==typeof r.config.locale?r.config.locale:"default"!==r.config.locale?wt.l10ns[r.config.locale]:void 0),ut.D="("+r.l10n.weekdays.shorthand.join("|")+")",ut.l="("+r.l10n.weekdays.longhand.join("|")+")",ut.M="("+r.l10n.months.shorthand.join("|")+")",ut.F="("+r.l10n.months.longhand.join("|")+")",ut.K="("+r.l10n.amPM[0]+"|"+r.l10n.amPM[1]+"|"+r.l10n.amPM[0].toLowerCase()+"|"+r.l10n.amPM[1].toLowerCase()+")",void 0===vt(vt({},e),JSON.parse(JSON.stringify(t.dataset||{}))).time_24hr&&void 0===wt.defaultConfig.time_24hr&&(r.config.time_24hr=r.l10n.time_24hr),r.formatDate=ft(r),r.parseDate=pt({config:r.config,l10n:r.l10n})}function j(t){if("function"!=typeof r.config.position){if(void 0!==r.calendarContainer){st("onPreCalendarPosition");var e=t||r._positionElement,n=Array.prototype.reduce.call(r.calendarContainer.children,(function(t,e){return t+e.offsetHeight}),0),i=r.calendarContainer.offsetWidth,a=r.config.position.split(" "),o=a[0],s=a.length>1?a[1]:null,l=e.getBoundingClientRect(),c=window.innerHeight-l.bottom,u="above"===o||"below"!==o&&cn,h=window.pageYOffset+l.top+(u?-n-2:e.offsetHeight+2);if(et(r.calendarContainer,"arrowTop",!u),et(r.calendarContainer,"arrowBottom",u),!r.config.inline){var f=window.pageXOffset+l.left,p=!1,d=!1;"center"===s?(f-=(i-l.width)/2,p=!0):"right"===s&&(f-=i-l.width,d=!0),et(r.calendarContainer,"arrowLeft",!p&&!d),et(r.calendarContainer,"arrowCenter",p),et(r.calendarContainer,"arrowRight",d);var m=window.document.body.offsetWidth-(window.pageXOffset+l.right),g=f+i>window.document.body.offsetWidth,y=m+i>window.document.body.offsetWidth;if(et(r.calendarContainer,"rightMost",g),!r.config.static)if(r.calendarContainer.style.top=h+"px",g)if(y){var v=function(){for(var t=null,e=0;er.currentMonth+r.config.showMonths-1)&&"range"!==r.config.mode;if(r.selectedDateElem=n,"single"===r.config.mode)r.selectedDates=[i];else if("multiple"===r.config.mode){var o=ht(i);o?r.selectedDates.splice(parseInt(o),1):r.selectedDates.push(i)}else"range"===r.config.mode&&(2===r.selectedDates.length&&r.clear(!1,!1),r.latestSelectedDateObj=i,r.selectedDates.push(i),0!==dt(i,r.selectedDates[0],!0)&&r.selectedDates.sort((function(t,e){return t.getTime()-e.getTime()})));if(s(),a){var l=r.currentYear!==i.getFullYear();r.currentYear=i.getFullYear(),r.currentMonth=i.getMonth(),l&&(st("onYearChange"),w()),st("onMonthChange")}if(_t(),b(),Tt(),a||"range"===r.config.mode||1!==r.config.showMonths?void 0!==r.selectedDateElem&&void 0===r.hourElement&&r.selectedDateElem&&r.selectedDateElem.focus():y(n),void 0!==r.hourElement&&void 0!==r.hourElement&&r.hourElement.focus(),r.config.closeOnSelect){var c="single"===r.config.mode&&!r.config.enableTime,u="range"===r.config.mode&&2===r.selectedDates.length&&!r.config.enableTime;(c||u)&&V()}f()}}r.parseDate=pt({config:r.config,l10n:r.l10n}),r._handlers=[],r.pluginElements=[],r.loadedPlugins=[],r._bind=h,r._setHoursFromDate=l,r._positionCalendar=j,r.changeMonth=S,r.changeYear=L,r.clear=function(t,e){void 0===t&&(t=!0);void 0===e&&(e=!0);r.input.value="",void 0!==r.altInput&&(r.altInput.value="");void 0!==r.mobileInput&&(r.mobileInput.value="");r.selectedDates=[],r.latestSelectedDateObj=void 0,!0===e&&(r.currentYear=r._initialDate.getFullYear(),r.currentMonth=r._initialDate.getMonth());if(!0===r.config.enableTime){var n=yt(r.config);c(n.hours,n.minutes,n.seconds)}r.redraw(),t&&st("onChange")},r.close=function(){r.isOpen=!1,r.isMobile||(void 0!==r.calendarContainer&&r.calendarContainer.classList.remove("open"),void 0!==r._input&&r._input.classList.remove("active"));st("onClose")},r.onMouseOver=O,r._createElement=rt,r.createDay=g,r.destroy=function(){void 0!==r.config&&st("onDestroy");for(var t=r._handlers.length;t--;)r._handlers[t].remove();if(r._handlers=[],r.mobileInput)r.mobileInput.parentNode&&r.mobileInput.parentNode.removeChild(r.mobileInput),r.mobileInput=void 0;else if(r.calendarContainer&&r.calendarContainer.parentNode)if(r.config.static&&r.calendarContainer.parentNode){var e=r.calendarContainer.parentNode;if(e.lastChild&&e.removeChild(e.lastChild),e.parentNode){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}}else r.calendarContainer.parentNode.removeChild(r.calendarContainer);r.altInput&&(r.input.type="text",r.altInput.parentNode&&r.altInput.parentNode.removeChild(r.altInput),delete r.altInput);r.input&&(r.input.type=r.input._type,r.input.classList.remove("flatpickr-input"),r.input.removeAttribute("readonly"));["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach((function(t){try{delete r[t]}catch(t){}}))},r.isEnabled=I,r.jumpToDate=p,r.updateValue=Tt,r.open=function(t,e){void 0===e&&(e=r._positionElement);if(!0===r.isMobile){if(t){t.preventDefault();var n=ot(t);n&&n.blur()}return void 0!==r.mobileInput&&(r.mobileInput.focus(),r.mobileInput.click()),void st("onOpen")}if(r._input.disabled||r.config.inline)return;var i=r.isOpen;r.isOpen=!0,i||(r.calendarContainer.classList.add("open"),r._input.classList.add("active"),st("onOpen"),j(e));!0===r.config.enableTime&&!0===r.config.noCalendar&&(!1!==r.config.allowInput||void 0!==t&&r.timeContainer.contains(t.relatedTarget)||setTimeout((function(){return r.hourElement.select()}),50))},r.redraw=U,r.set=function(t,e){if(null!==t&&"object"==typeof t)for(var n in Object.assign(r.config,t),t)void 0!==H[n]&&H[n].forEach((function(t){return t()}));else r.config[t]=e,void 0!==H[t]?H[t].forEach((function(t){return t()})):Z.indexOf(t)>-1&&(r.config[t]=tt(e));r.redraw(),Tt(!0)},r.setDate=function(t,e,n){void 0===e&&(e=!1);void 0===n&&(n=r.config.dateFormat);if(0!==t&&!t||t instanceof Array&&0===t.length)return r.clear(e);G(t,n),r.latestSelectedDateObj=r.selectedDates[r.selectedDates.length-1],r.redraw(),p(void 0,e),l(),0===r.selectedDates.length&&r.clear(!1);Tt(e),e&&st("onChange")},r.toggle=function(t){if(!0===r.isOpen)return r.close();r.open(t)};var H={locale:[N,M],showMonths:[k,a,A],minDate:[p],maxDate:[p],positionElement:[X],clickOpens:[function(){!0===r.config.clickOpens?(h(r._input,"focus",r.open),h(r._input,"click",r.open)):(r._input.removeEventListener("focus",r.open),r._input.removeEventListener("click",r.open))}]};function G(t,e){var n=[];if(t instanceof Array)n=t.map((function(t){return r.parseDate(t,e)}));else if(t instanceof Date||"number"==typeof t)n=[r.parseDate(t,e)];else if("string"==typeof t)switch(r.config.mode){case"single":case"time":n=[r.parseDate(t,e)];break;case"multiple":n=t.split(r.config.conjunction).map((function(t){return r.parseDate(t,e)}));break;case"range":n=t.split(r.l10n.rangeSeparator).map((function(t){return r.parseDate(t,e)}))}else r.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(t)));r.selectedDates=r.config.allowInvalidPreload?n:n.filter((function(t){return t instanceof Date&&I(t,!1)})),"range"===r.config.mode&&r.selectedDates.sort((function(t,e){return t.getTime()-e.getTime()}))}function W(t){return t.slice().map((function(t){return"string"==typeof t||"number"==typeof t||t instanceof Date?r.parseDate(t,void 0,!0):t&&"object"==typeof t&&t.from&&t.to?{from:r.parseDate(t.from,void 0),to:r.parseDate(t.to,void 0)}:t})).filter((function(t){return t}))}function X(){r._positionElement=r.config.positionElement||r._input}function st(t,e){if(void 0!==r.config){var n=r.config[t];if(void 0!==n&&n.length>0)for(var i=0;n[i]&&i1||"static"===r.config.monthSelectorType?r.monthElements[e].textContent=lt(n.getMonth(),r.config.shorthandCurrentMonth,r.l10n)+" ":r.monthsDropdownContainer.value=n.getMonth().toString(),t.value=n.getFullYear().toString()})),r._hidePrevMonthArrow=void 0!==r.config.minDate&&(r.currentYear===r.config.minDate.getFullYear()?r.currentMonth<=r.config.minDate.getMonth():r.currentYearr.config.maxDate.getMonth():r.currentYear>r.config.maxDate.getFullYear()))}function bt(t){var e=t||(r.config.altInput?r.config.altFormat:r.config.dateFormat);return r.selectedDates.map((function(t){return r.formatDate(t,e)})).filter((function(t,e,n){return"range"!==r.config.mode||r.config.enableTime||n.indexOf(t)===e})).join("range"!==r.config.mode?r.config.conjunction:r.l10n.rangeSeparator)}function Tt(t){void 0===t&&(t=!0),void 0!==r.mobileInput&&r.mobileFormatStr&&(r.mobileInput.value=void 0!==r.latestSelectedDateObj?r.formatDate(r.latestSelectedDateObj,r.mobileFormatStr):""),r.input.value=bt(r.config.dateFormat),void 0!==r.altInput&&(r.altInput.value=bt(r.config.altFormat)),!1!==t&&st("onValueUpdate")}function kt(t){var e=ot(t),n=r.prevMonthNav.contains(e),i=r.nextMonthNav.contains(e);n||i?S(n?-1:1):r.yearElements.indexOf(e)>=0?e.select():e.classList.contains("arrowUp")?r.changeYear(r.currentYear+1):e.classList.contains("arrowDown")&&r.changeYear(r.currentYear-1)}return function(){r.element=r.input=t,r.isOpen=!1,function(){var n=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],a=vt(vt({},JSON.parse(JSON.stringify(t.dataset||{}))),e),o={};r.config.parseDate=a.parseDate,r.config.formatDate=a.formatDate,Object.defineProperty(r.config,"enable",{get:function(){return r.config._enable},set:function(t){r.config._enable=W(t)}}),Object.defineProperty(r.config,"disable",{get:function(){return r.config._disable},set:function(t){r.config._disable=W(t)}});var s="time"===a.mode;if(!a.dateFormat&&(a.enableTime||s)){var l=wt.defaultConfig.dateFormat||Y.dateFormat;o.dateFormat=a.noCalendar||s?"H:i"+(a.enableSeconds?":S":""):l+" H:i"+(a.enableSeconds?":S":"")}if(a.altInput&&(a.enableTime||s)&&!a.altFormat){var c=wt.defaultConfig.altFormat||Y.altFormat;o.altFormat=a.noCalendar||s?"h:i"+(a.enableSeconds?":S K":" K"):c+" h:i"+(a.enableSeconds?":S":"")+" K"}Object.defineProperty(r.config,"minDate",{get:function(){return r.config._minDate},set:F("min")}),Object.defineProperty(r.config,"maxDate",{get:function(){return r.config._maxDate},set:F("max")});var u=function(t){return function(e){r.config["min"===t?"_minTime":"_maxTime"]=r.parseDate(e,"H:i:S")}};Object.defineProperty(r.config,"minTime",{get:function(){return r.config._minTime},set:u("min")}),Object.defineProperty(r.config,"maxTime",{get:function(){return r.config._maxTime},set:u("max")}),"time"===a.mode&&(r.config.noCalendar=!0,r.config.enableTime=!0);Object.assign(r.config,o,a);for(var h=0;h-1?r.config[p]=tt(f[p]).map(i).concat(r.config[p]):void 0===a[p]&&(r.config[p]=f[p])}a.altInputClass||(r.config.altInputClass=B().className+" "+r.config.altInputClass);st("onParseConfig")}(),N(),function(){if(r.input=B(),!r.input)return void r.config.errorHandler(new Error("Invalid input element specified"));r.input._type=r.input.type,r.input.type="text",r.input.classList.add("flatpickr-input"),r._input=r.input,r.config.altInput&&(r.altInput=rt(r.input.nodeName,r.config.altInputClass),r._input=r.altInput,r.altInput.placeholder=r.input.placeholder,r.altInput.disabled=r.input.disabled,r.altInput.required=r.input.required,r.altInput.tabIndex=r.input.tabIndex,r.altInput.type="text",r.input.setAttribute("type","hidden"),!r.config.static&&r.input.parentNode&&r.input.parentNode.insertBefore(r.altInput,r.input.nextSibling));r.config.allowInput||r._input.setAttribute("readonly","readonly");X()}(),function(){r.selectedDates=[],r.now=r.parseDate(r.config.now)||new Date;var t=r.config.defaultDate||("INPUT"!==r.input.nodeName&&"TEXTAREA"!==r.input.nodeName||!r.input.placeholder||r.input.value!==r.input.placeholder?r.input.value:null);t&&G(t,r.config.dateFormat);r._initialDate=r.selectedDates.length>0?r.selectedDates[0]:r.config.minDate&&r.config.minDate.getTime()>r.now.getTime()?r.config.minDate:r.config.maxDate&&r.config.maxDate.getTime()0&&(r.latestSelectedDateObj=r.selectedDates[0]);void 0!==r.config.minTime&&(r.config.minTime=r.parseDate(r.config.minTime,"H:i"));void 0!==r.config.maxTime&&(r.config.maxTime=r.parseDate(r.config.maxTime,"H:i"));r.minDateHasTime=!!r.config.minDate&&(r.config.minDate.getHours()>0||r.config.minDate.getMinutes()>0||r.config.minDate.getSeconds()>0),r.maxDateHasTime=!!r.config.maxDate&&(r.config.maxDate.getHours()>0||r.config.maxDate.getMinutes()>0||r.config.maxDate.getSeconds()>0)}(),r.utils={getDaysInMonth:function(t,e){return void 0===t&&(t=r.currentMonth),void 0===e&&(e=r.currentYear),1===t&&(e%4==0&&e%100!=0||e%400==0)?29:r.l10n.daysInMonth[t]}},r.isMobile||function(){var t=window.document.createDocumentFragment();if(r.calendarContainer=rt("div","flatpickr-calendar"),r.calendarContainer.tabIndex=-1,!r.config.noCalendar){if(t.appendChild((r.monthNav=rt("div","flatpickr-months"),r.yearElements=[],r.monthElements=[],r.prevMonthNav=rt("span","flatpickr-prev-month"),r.prevMonthNav.innerHTML=r.config.prevArrow,r.nextMonthNav=rt("span","flatpickr-next-month"),r.nextMonthNav.innerHTML=r.config.nextArrow,k(),Object.defineProperty(r,"_hidePrevMonthArrow",{get:function(){return r.__hidePrevMonthArrow},set:function(t){r.__hidePrevMonthArrow!==t&&(et(r.prevMonthNav,"flatpickr-disabled",t),r.__hidePrevMonthArrow=t)}}),Object.defineProperty(r,"_hideNextMonthArrow",{get:function(){return r.__hideNextMonthArrow},set:function(t){r.__hideNextMonthArrow!==t&&(et(r.nextMonthNav,"flatpickr-disabled",t),r.__hideNextMonthArrow=t)}}),r.currentYearElement=r.yearElements[0],_t(),r.monthNav)),r.innerContainer=rt("div","flatpickr-innerContainer"),r.config.weekNumbers){var e=function(){r.calendarContainer.classList.add("hasWeeks");var t=rt("div","flatpickr-weekwrapper");t.appendChild(rt("span","flatpickr-weekday",r.l10n.weekAbbreviation));var e=rt("div","flatpickr-weeks");return t.appendChild(e),{weekWrapper:t,weekNumbers:e}}(),n=e.weekWrapper,i=e.weekNumbers;r.innerContainer.appendChild(n),r.weekNumbers=i,r.weekWrapper=n}r.rContainer=rt("div","flatpickr-rContainer"),r.rContainer.appendChild(A()),r.daysContainer||(r.daysContainer=rt("div","flatpickr-days"),r.daysContainer.tabIndex=-1),b(),r.rContainer.appendChild(r.daysContainer),r.innerContainer.appendChild(r.rContainer),t.appendChild(r.innerContainer)}r.config.enableTime&&t.appendChild(function(){r.calendarContainer.classList.add("hasTime"),r.config.noCalendar&&r.calendarContainer.classList.add("noCalendar");var t=yt(r.config);r.timeContainer=rt("div","flatpickr-time"),r.timeContainer.tabIndex=-1;var e=rt("span","flatpickr-time-separator",":"),n=at("flatpickr-hour",{"aria-label":r.l10n.hourAriaLabel});r.hourElement=n.getElementsByTagName("input")[0];var i=at("flatpickr-minute",{"aria-label":r.l10n.minuteAriaLabel});r.minuteElement=i.getElementsByTagName("input")[0],r.hourElement.tabIndex=r.minuteElement.tabIndex=-1,r.hourElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getHours():r.config.time_24hr?t.hours:function(t){switch(t%24){case 0:case 12:return 12;default:return t%12}}(t.hours)),r.minuteElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getMinutes():t.minutes),r.hourElement.setAttribute("step",r.config.hourIncrement.toString()),r.minuteElement.setAttribute("step",r.config.minuteIncrement.toString()),r.hourElement.setAttribute("min",r.config.time_24hr?"0":"1"),r.hourElement.setAttribute("max",r.config.time_24hr?"23":"12"),r.hourElement.setAttribute("maxlength","2"),r.minuteElement.setAttribute("min","0"),r.minuteElement.setAttribute("max","59"),r.minuteElement.setAttribute("maxlength","2"),r.timeContainer.appendChild(n),r.timeContainer.appendChild(e),r.timeContainer.appendChild(i),r.config.time_24hr&&r.timeContainer.classList.add("time24hr");if(r.config.enableSeconds){r.timeContainer.classList.add("hasSeconds");var a=at("flatpickr-second");r.secondElement=a.getElementsByTagName("input")[0],r.secondElement.value=J(r.latestSelectedDateObj?r.latestSelectedDateObj.getSeconds():t.seconds),r.secondElement.setAttribute("step",r.minuteElement.getAttribute("step")),r.secondElement.setAttribute("min","0"),r.secondElement.setAttribute("max","59"),r.secondElement.setAttribute("maxlength","2"),r.timeContainer.appendChild(rt("span","flatpickr-time-separator",":")),r.timeContainer.appendChild(a)}r.config.time_24hr||(r.amPM=rt("span","flatpickr-am-pm",r.l10n.amPM[K((r.latestSelectedDateObj?r.hourElement.value:r.config.defaultHour)>11)]),r.amPM.title=r.l10n.toggleTitle,r.amPM.tabIndex=-1,r.timeContainer.appendChild(r.amPM));return r.timeContainer}());et(r.calendarContainer,"rangeMode","range"===r.config.mode),et(r.calendarContainer,"animate",!0===r.config.animate),et(r.calendarContainer,"multiMonth",r.config.showMonths>1),r.calendarContainer.appendChild(t);var a=void 0!==r.config.appendTo&&void 0!==r.config.appendTo.nodeType;if((r.config.inline||r.config.static)&&(r.calendarContainer.classList.add(r.config.inline?"inline":"static"),r.config.inline&&(!a&&r.element.parentNode?r.element.parentNode.insertBefore(r.calendarContainer,r._input.nextSibling):void 0!==r.config.appendTo&&r.config.appendTo.appendChild(r.calendarContainer)),r.config.static)){var o=rt("div","flatpickr-wrapper");r.element.parentNode&&r.element.parentNode.insertBefore(o,r.element),o.appendChild(r.element),r.altInput&&o.appendChild(r.altInput),o.appendChild(r.calendarContainer)}r.config.static||r.config.inline||(void 0!==r.config.appendTo?r.config.appendTo:window.document.body).appendChild(r.calendarContainer)}(),function(){r.config.wrap&&["open","close","toggle","clear"].forEach((function(t){Array.prototype.forEach.call(r.element.querySelectorAll("[data-"+t+"]"),(function(e){return h(e,"click",r[t])}))}));if(r.isMobile)return void function(){var t=r.config.enableTime?r.config.noCalendar?"time":"datetime-local":"date";r.mobileInput=rt("input",r.input.className+" flatpickr-mobile"),r.mobileInput.tabIndex=1,r.mobileInput.type=t,r.mobileInput.disabled=r.input.disabled,r.mobileInput.required=r.input.required,r.mobileInput.placeholder=r.input.placeholder,r.mobileFormatStr="datetime-local"===t?"Y-m-d\\TH:i:S":"date"===t?"Y-m-d":"H:i:S",r.selectedDates.length>0&&(r.mobileInput.defaultValue=r.mobileInput.value=r.formatDate(r.selectedDates[0],r.mobileFormatStr));r.config.minDate&&(r.mobileInput.min=r.formatDate(r.config.minDate,"Y-m-d"));r.config.maxDate&&(r.mobileInput.max=r.formatDate(r.config.maxDate,"Y-m-d"));r.input.getAttribute("step")&&(r.mobileInput.step=String(r.input.getAttribute("step")));r.input.type="hidden",void 0!==r.altInput&&(r.altInput.type="hidden");try{r.input.parentNode&&r.input.parentNode.insertBefore(r.mobileInput,r.input.nextSibling)}catch(t){}h(r.mobileInput,"change",(function(t){r.setDate(ot(t).value,!1,r.mobileFormatStr),st("onChange"),st("onClose")}))}();var t=Q(R,50);r._debouncedChange=Q(f,300),r.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&h(r.daysContainer,"mouseover",(function(t){"range"===r.config.mode&&O(ot(t))}));h(r._input,"keydown",D),void 0!==r.calendarContainer&&h(r.calendarContainer,"keydown",D);r.config.inline||r.config.static||h(window,"resize",t);void 0!==window.ontouchstart?h(window.document,"touchstart",C):h(window.document,"mousedown",C);h(window.document,"focus",C,{capture:!0}),!0===r.config.clickOpens&&(h(r._input,"focus",r.open),h(r._input,"click",r.open));void 0!==r.daysContainer&&(h(r.monthNav,"click",kt),h(r.monthNav,["keyup","increment"],u),h(r.daysContainer,"click",q));if(void 0!==r.timeContainer&&void 0!==r.minuteElement&&void 0!==r.hourElement){var e=function(t){return ot(t).select()};h(r.timeContainer,["increment"],o),h(r.timeContainer,"blur",o,{capture:!0}),h(r.timeContainer,"click",d),h([r.hourElement,r.minuteElement],["focus","click"],e),void 0!==r.secondElement&&h(r.secondElement,"focus",(function(){return r.secondElement&&r.secondElement.select()})),void 0!==r.amPM&&h(r.amPM,"click",(function(t){o(t)}))}r.config.allowInput&&h(r._input,"blur",z)}(),(r.selectedDates.length||r.config.noCalendar)&&(r.config.enableTime&&l(r.config.noCalendar?r.latestSelectedDateObj:void 0),Tt(!1)),a();var n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!r.isMobile&&n&&j(),st("onReady")}(),r}function bt(t,e){for(var r=Array.prototype.slice.call(t).filter((function(t){return t instanceof HTMLElement})),n=[],i=0;it}if(null!=this.expression){const t=this.expression;return()=>this.parseExpression(t)}return null}parseExpression(t){const e=new Date;if(e.setMilliseconds(0),"now"===t.toLowerCase())return e;const r=t.match(/^\s*now\s*(-|\+)\s*(\d+)([dhms])\s*$/i);if(r){const[,t,n,i]=r;let a;switch(i.toLowerCase()){case"d":a=60*n*60*24;break;case"h":a=60*n*60;break;case"m":a=60*n;break;case"s":a=n;break;default:return null}return"-"===t&&(a=-a),c(l(e)+a)}return null}}class At{constructor(t,e){this.fromPicker=new kt(t),this.toPicker=new kt(e)}setDates(t,e){this.fromPicker.setDate(t),this.toPicker.setDate(e)}getDates(){return[this.fromPicker.getDate(),this.toPicker.getDate()]}getRawDates(){return[this.fromPicker.getRawDate(),this.toPicker.getRawDate()]}getDatesFactory(){const t=this.fromPicker.getDateFactory(),e=this.toPicker.getDateFactory();return()=>[t(),e()]}hasValidDates(){const t=this.fromPicker.getDate(),e=this.toPicker.getDate();return null!=t&&null!=e&&t<=e}}function Mt(){function t(t,e,r){e.forEach((e=>{const r=document.createElement("option");Array.isArray(e)&&2===e.length?(r.value=e[0],r.text=e[1]):(r.value=e,r.text=e),t.appendChild(r)})),t.value=r}const e=document.getElementById("range").timeRangePicker;try{e.setDates(...m())}catch{e.setDates(...m(!0))}const r=document.getElementById("refresh-interval");t(r,x,function(){try{let t=localStorage.getItem(v);if(null!=t&&(t=parseInt(t,10),_(t)))return t}catch(t){console.error(`Failed to read '${v}' from local storage!`,t)}return varnishmon.config.scraper.enabled?-1:0}()),r.addEventListener("change",(t=>{!function(t){if(_(t))try{localStorage.setItem(v,t)}catch(t){console.error(`Failed to write '${v}' to local storage!`,t)}else console.error("Invalid refresh interval value!",t)}(parseInt(t.target.value,10))}));const n=document.getElementById("filter");n.value=function(){try{let t=localStorage.getItem(b);if(null!=t)return t}catch(t){console.error(`Failed to read '${b}' from local storage!`,t)}return""}(),n.addEventListener("change",(t=>{!function(t){try{localStorage.setItem(b,t)}catch(t){console.error(`Failed to write '${b}' to local storage!`,t)}}(t.target.value)}));const i=document.getElementById("verbosity");t(i,A,function(){try{let t=localStorage.getItem(k);if(null!=t&&M(t))return t}catch(t){console.error(`Failed to read '${k}' from local storage!`,t)}return"normal"}()),i.addEventListener("change",(t=>{!function(t){if(M(t))try{localStorage.setItem(k,t)}catch(t){console.error(`Failed to write '${k}' to local storage!`,t)}else console.error("Invalid verbosity value!",t)}(t.target.value)}));const a=document.getElementById("columns");t(a,E,function(){try{let t=localStorage.getItem(S);if(null!=t&&(t=parseInt(t,10),C(t)))return t}catch(t){console.error(`Failed to read '${S}' from local storage!`,t)}return 3}()),a.addEventListener("change",(t=>{!function(t){if(C(t))try{localStorage.setItem(S,t)}catch(t){console.error(`Failed to write '${S}' to local storage!`,t)}else console.error("Invalid columns value!",t)}(parseInt(t.target.value,10))}));const o=document.getElementById("aggregator");t(o,I,function(){try{let t=localStorage.getItem(L);if(null!=t&&P(t))return t}catch(t){console.error(`Failed to read '${L}' from local storage!`,t)}return"avg"}()),o.addEventListener("change",(t=>{!function(t){if(P(t))try{localStorage.setItem(L,t)}catch(t){console.error(`Failed to write '${L}' to local storage!`,t)}else console.error("Invalid aggregator value!",t)}(t.target.value)}));const s=document.getElementById("step");s.min=varnishmon.config.scraper.period,s.value=function(){try{let t=localStorage.getItem(z);if(null!=t&&(t=parseInt(t,10),D(t)))return t}catch(t){console.error(`Failed to read '${z}' from local storage!`,t)}return varnishmon.config.scraper.period}(),s.addEventListener("change",(t=>{const e=parseInt(t.target.value,10);e>=varnishmon.config.scraper.period?function(t){if(D(t))try{localStorage.setItem(z,t)}catch(t){console.error(`Failed to write '${z}' to local storage!`,t)}else console.error("Invalid columns value!",t)}(e):(t.stopPropagation(),s.value=varnishmon.config.scraper.period,u("error",`Step must be at least ${varnishmon.config.scraper.period} seconds, which is the metrics scraping period`))}))}function St(){let t=parseInt(document.getElementById("refresh-interval").value,10);return t<0&&(t=varnishmon.config.scraper.period),t}function Et(){let t=parseInt(document.getElementById("step").value,10);return t{"Enter"===t.key&&document.getElementById("apply-time-range").click()})),document.getElementById("range-to").addEventListener("keydown",(t=>{"Enter"===t.key&&document.getElementById("apply-time-range").click()})),document.getElementById("apply-time-range").addEventListener("click",(t=>{const e=document.getElementById("range");if(!e.timeRangePicker.hasValidDates())return t.stopPropagation(),void u("error","The selected time range is invalid. ISO 8601 and relative expressions like 'now-1h', 'now', 'now-1d', etc. are allowed.");!function(t,e){y(f,t),y(p,e)}(...e.timeRangePicker.getRawDates()),e.initialRange=null,Lt()})),document.getElementById("refresh-interval").addEventListener("change",(()=>{let t=St();document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setRefreshInterval(t)}))})),document.getElementById("refresh").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((t=>{t.chart.refresh()}))})),document.getElementById("filter").addEventListener("input",s(It,500)),document.getElementById("verbosity").addEventListener("change",It),document.getElementById("columns").addEventListener("change",It),document.getElementById("filter").addEventListener("change",(t=>{const e=t.target.value;if(e){const t=T(),r=t.indexOf(e);0!==r&&(-1!==r&&t.splice(r,1),t.unshift(e),t.length>10&&t.pop(),function(t){try{localStorage.setItem(w,JSON.stringify(t))}catch(t){console.error(`Failed to write '${w}' to local storage!`,t)}}(t)),Pt()}})),document.getElementById("aggregator").addEventListener("change",(t=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setAggregator(t.target.value)}))})),document.getElementById("step").addEventListener("change",(()=>{const t=Et();document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart.setStep(t)}))})),document.getElementById("reset").addEventListener("click",(()=>{!function(){for(let t=localStorage.length-1;t>=0;t--)try{const e=localStorage.key(t);e.startsWith(h)&&localStorage.removeItem(e)}catch(t){console.error("Failed to remove item from local storage!",t)}}(),location.reload()})),document.getElementById("collapse-all").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".cluster").forEach((t=>{e().getInstance(t.querySelector(".accordion-collapse")).hide(),t.querySelector(".accordion-button").classList.add("collapsed")}))})),document.getElementById("expand-all").addEventListener("click",(()=>{document.getElementById("clusters").querySelectorAll(".cluster").forEach((t=>{e().getInstance(t.querySelector(".accordion-collapse")).show(),t.querySelector(".accordion-button").classList.remove("collapsed")}))}))}async function Lt(){const t=document.getElementById("clusters");t.querySelectorAll(".chart").forEach((t=>{t.chart.destroy()})),t.innerHTML="",t.appendChild(document.getElementById("spinner-template").content.cloneNode(!0).firstElementChild);const r=document.getElementById("range").timeRangePicker.getDatesFactory(),n=St(),i=document.getElementById("aggregator").value,a=Et();let o;try{const[t,e]=r();o=await async function(t,e,r){const n=new URLSearchParams({from:l(t),to:l(e),step:r}),i=await fetch(`/storage/metrics?${n.toString()}`);if(!i.ok)throw new Error(`Unexpected API response (${i.status}): ${i.statusText}`);const a=await i.json();return{from:c(a.from),to:c(a.to),step:a.step,clusters:B(a.metrics)}}(t,e,a)}catch(e){return t.innerHTML="",t.appendChild(document.getElementById("metrics-meditation-template").content.cloneNode(!0).firstElementChild),void u("error",`Failed to fetch metrics: ${e}`)}const s=o.clusters.length;u("info",`Fetched ${o.clusters.reduce(((t,e)=>t+e.metrics.length),0)} metrics organized in ${s} clusters`);const h=document.getElementById("cluster-template"),f=document.getElementById("chart-template");t.innerHTML="",o.clusters.forEach((o=>{const s=h.content.cloneNode(!0).firstElementChild;s.querySelector(".cluster-name").textContent=o.name,t.appendChild(s);const l=new(e())(s.querySelector(".accordion-collapse"));s.querySelector(".accordion-button").addEventListener("click",(t=>{t.currentTarget.classList.toggle("collapsed"),l.toggle()}));const c=s.querySelector(".charts");o.metrics.forEach((t=>{const e=f.content.cloneNode(!0).firstElementChild,o=new W(e,t,r,n,i,a);o.addEventListener("zoom",(t=>{document.getElementById("clusters").querySelectorAll(".chart").forEach((e=>{e.chart!==t.target&&e.chart.setZoomRange(t.range)}));const e=document.getElementById("range");null!=t.range?(null==e.initialRange&&(e.initialRange=e.timeRangePicker.getRawDates()),e.timeRangePicker.setDates(...t.range)):null!=e.initialRange&&(e.timeRangePicker.setDates(...e.initialRange),e.initialRange=null)})),e.chart=o,c.appendChild(e)}))})),It()}function It(){const t=document.getElementById("clusters");t.querySelectorAll(".chart").forEach((t=>{t.chart.redraw(document.getElementById("filter").value,document.getElementById("verbosity").value,parseInt(document.getElementById("columns").value,10))})),t.querySelectorAll(".cluster").forEach((t=>{0===t.querySelectorAll(".chart:not(.d-none)").length?t.classList.add("d-none"):t.classList.remove("d-none")}));const e=t.querySelectorAll(".cluster").length,r=t.querySelectorAll(".cluster:not(.d-none)").length,n=t.querySelectorAll(".chart").length,i=t.querySelectorAll(".chart:not(.d-none)").length;document.getElementById("filter-stats").textContent=`${i} metrics found (${n-i} hidden), organized in ${r} clusters (${e-r} hidden)`}function Pt(){const t=document.getElementById("filterHistoryList");t.innerHTML="",T().forEach((e=>{const r=document.createElement("li");r.classList.add("dropdown-item"),r.textContent=e,r.addEventListener("click",(()=>{const t=document.getElementById("filter");t.value=e,t.dispatchEvent(new Event("change")),It()})),t.appendChild(r)}))}document.addEventListener("DOMContentLoaded",(async()=>{!function(){const t=new MutationObserver(((e,r)=>{for(const r of e)"childList"===r.type&&r.addedNodes.forEach((e=>{if(e.classList&&e.classList.contains("plotly-notifier")){e.style.display="none",t.disconnect(),e.querySelectorAll(".notifier-note").forEach((t=>{u("info",t.querySelector("span").innerText)}));const r=new MutationObserver(((t,e)=>{for(const e of t)"childList"===e.type&&e.addedNodes.forEach((t=>{t.classList&&t.classList.contains("notifier-note")&&u("info",t.querySelector("span").innerText)}))}));r.observe(e,{childList:!0})}}))}));t.observe(document.body,{childList:!0})}(),document.getElementById("range").timeRangePicker=new At(document.getElementById("range-from"),document.getElementById("range-to")),Mt(),Ct(),new(i())(document.getElementById("filterHistoryList")),Pt(),Lt()}))})()})(); \ No newline at end of file diff --git a/assets/webpack/src/js/chart.js b/assets/webpack/src/js/chart.js index 637d657..954d019 100644 --- a/assets/webpack/src/js/chart.js +++ b/assets/webpack/src/js/chart.js @@ -200,23 +200,21 @@ class Chart { } handleGraphRelayout(event) { - // Extract the zoom range of the graph. + // Extract the zoom range of the graph, if any. This includes detecting the + // no-zoom / zoom-reset event. if (event['xaxis.range[0]'] && event['xaxis.range[1]']) { this.graph.zoomRange = [ new Date(event['xaxis.range[0]']), new Date(event['xaxis.range[1]']), ]; } else if (event['xaxis.range'] && Array.isArray(event['xaxis.range']) && event['xaxis.range'].length === 2) { - this.graph.zoomRange = [ - new Date(event['xaxis.range'][0]), - new Date(event['xaxis.range'][1]), - ]; + this.graph.zoomRange = null; } else { this.graph.zoomRange = null; } - // If the zoom range goes beyond the original range, adjust it to the - // original range. + // If the zoom range goes beyond the current range, adjust it to the + // current range. if (this.graph.zoomRange != null) { if (helpers.dateToUnix(this.graph.zoomRange[0]) < helpers.dateToUnix(this.graph.range[0])) { this.graph.zoomRange[0] = this.graph.range[0]; @@ -238,15 +236,6 @@ class Chart { } } - // In the zoom range is identical to the original range, reset the zoom - // range so listeners can detect the no-zoom event. - if (this.graph.zoomRange != null) { - if (helpers.dateToUnix(this.graph.zoomRange[0]) === helpers.dateToUnix(this.graph.range[0]) && - helpers.dateToUnix(this.graph.zoomRange[1]) === helpers.dateToUnix(this.graph.range[1])) { - this.graph.zoomRange = null; - } - } - // Force a re-render of the graph. The zoom range is already applied, but we // might want to adjust other properties of the graph (e.g., the data mode), // or the adjusted zoom range itself. @@ -255,7 +244,7 @@ class Chart { // Inform listeners about the zoom event. this.notifyEventListeners('zoom', { target: this, - range: this.graph.zoomRange, + range: this.graph.zoomRange, // null if no zoom. }); } diff --git a/go.mod b/go.mod index 1ef481a..2c401dd 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect diff --git a/go.sum b/go.sum index f62129a..cd83f00 100644 --- a/go.sum +++ b/go.sum @@ -108,6 +108,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= diff --git a/pkg/workers/api/mock_Application.go b/pkg/workers/api/mock_Application.go new file mode 100644 index 0000000..385bfdc --- /dev/null +++ b/pkg/workers/api/mock_Application.go @@ -0,0 +1,47 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package api + +import ( + config "github.com/allenta/varnishmon/pkg/config" + mock "github.com/stretchr/testify/mock" +) + +// MockApplication is an autogenerated mock type for the Application type +type MockApplication struct { + mock.Mock +} + +// Cfg provides a mock function with given fields: +func (_m *MockApplication) Cfg() *config.Config { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Cfg") + } + + var r0 *config.Config + if rf, ok := ret.Get(0).(func() *config.Config); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*config.Config) + } + } + + return r0 +} + +// NewMockApplication creates a new instance of MockApplication. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockApplication(t interface { + mock.TestingT + Cleanup(func()) +}) *MockApplication { + mock := &MockApplication{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/workers/mock_APIHandler.go b/pkg/workers/mock_APIHandler.go new file mode 100644 index 0000000..cb053eb --- /dev/null +++ b/pkg/workers/mock_APIHandler.go @@ -0,0 +1,34 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package workers + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + fasthttp "github.com/valyala/fasthttp" +) + +// MockAPIHandler is an autogenerated mock type for the APIHandler type +type MockAPIHandler struct { + mock.Mock +} + +// HandleRequest provides a mock function with given fields: ctx, rctx +func (_m *MockAPIHandler) HandleRequest(ctx context.Context, rctx *fasthttp.RequestCtx) { + _m.Called(ctx, rctx) +} + +// NewMockAPIHandler creates a new instance of MockAPIHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAPIHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAPIHandler { + mock := &MockAPIHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/workers/mock_Application.go b/pkg/workers/mock_Application.go new file mode 100644 index 0000000..e850927 --- /dev/null +++ b/pkg/workers/mock_Application.go @@ -0,0 +1,47 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package workers + +import ( + config "github.com/allenta/varnishmon/pkg/config" + mock "github.com/stretchr/testify/mock" +) + +// MockApplication is an autogenerated mock type for the Application type +type MockApplication struct { + mock.Mock +} + +// Cfg provides a mock function with given fields: +func (_m *MockApplication) Cfg() *config.Config { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Cfg") + } + + var r0 *config.Config + if rf, ok := ret.Get(0).(func() *config.Config); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*config.Config) + } + } + + return r0 +} + +// NewMockApplication creates a new instance of MockApplication. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockApplication(t interface { + mock.TestingT + Cleanup(func()) +}) *MockApplication { + mock := &MockApplication{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/workers/storage/mock_Application.go b/pkg/workers/storage/mock_Application.go new file mode 100644 index 0000000..863fc0e --- /dev/null +++ b/pkg/workers/storage/mock_Application.go @@ -0,0 +1,47 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package storage + +import ( + config "github.com/allenta/varnishmon/pkg/config" + mock "github.com/stretchr/testify/mock" +) + +// MockApplication is an autogenerated mock type for the Application type +type MockApplication struct { + mock.Mock +} + +// Cfg provides a mock function with given fields: +func (_m *MockApplication) Cfg() *config.Config { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Cfg") + } + + var r0 *config.Config + if rf, ok := ret.Get(0).(func() *config.Config); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*config.Config) + } + } + + return r0 +} + +// NewMockApplication creates a new instance of MockApplication. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockApplication(t interface { + mock.TestingT + Cleanup(func()) +}) *MockApplication { + mock := &MockApplication{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}