maplibre-gl 2.2.0-pre.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -8
- package/build/generate-debug-index-file.ts +19 -0
- package/build/generate-style-code.ts +6 -1
- package/build/generate-style-spec.ts +151 -35
- package/build/rollup_plugins.ts +4 -1
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +1317 -4304
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +443 -145
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +70 -67
- package/src/css/maplibre-gl.css +48 -32
- package/src/data/bucket/fill_bucket.test.ts +1 -0
- package/src/data/bucket/symbol_bucket.test.ts +2 -0
- package/src/data/bucket/symbol_bucket.ts +1 -1
- package/src/data/evaluation_feature.ts +1 -1
- package/src/data/program_configuration.ts +2 -2
- package/src/geo/transform.test.ts +34 -1
- package/src/geo/transform.ts +25 -15
- package/src/gl/vertex_buffer.ts +4 -4
- package/src/index.ts +1 -1
- package/src/render/draw_debug.ts +1 -1
- package/src/render/draw_symbol.test.ts +2 -23
- package/src/render/draw_terrain.ts +1 -1
- package/src/render/image_atlas.ts +1 -0
- package/src/render/image_manager.ts +1 -0
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/render_to_texture.ts +3 -0
- package/src/render/terrain.test.ts +119 -17
- package/src/render/terrain.ts +39 -21
- package/src/shaders/README.md +2 -2
- package/src/shaders/shaders.ts +3 -1
- package/src/source/geojson_worker_source.test.ts +2 -2
- package/src/source/geojson_wrapper.test.ts +1 -1
- package/src/source/image_source.test.ts +8 -8
- package/src/source/image_source.ts +1 -1
- package/src/source/load_tilejson.ts +6 -1
- package/src/source/pixels_to_tile_units.ts +1 -1
- package/src/source/raster_tile_source.test.ts +1 -1
- package/src/source/source_cache.test.ts +12 -12
- package/src/source/source_cache.ts +1 -1
- package/src/source/terrain_source_cache.test.ts +17 -2
- package/src/source/terrain_source_cache.ts +16 -12
- package/src/source/vector_tile_source.test.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +1 -1
- package/src/source/video_source.test.ts +2 -2
- package/src/style/light.test.ts +1 -1
- package/src/style/load_sprite.ts +1 -1
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/style.test.ts +3 -3
- package/src/style/style.ts +2 -2
- package/src/style/style_layer/background_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/line_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -0
- package/src/style/style_layer/symbol_style_layer.ts +16 -1
- package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -3
- package/src/style-spec/CHANGELOG.md +5 -0
- package/src/style-spec/composite.test.ts +2 -0
- package/src/style-spec/composite.ts +3 -2
- package/src/style-spec/diff.test.ts +3 -3
- package/src/style-spec/empty.ts +3 -2
- package/src/style-spec/expression/compound_expression.ts +0 -4
- package/src/style-spec/expression/definitions/assertion.ts +0 -18
- package/src/style-spec/expression/definitions/at.ts +0 -4
- package/src/style-spec/expression/definitions/case.ts +0 -6
- package/src/style-spec/expression/definitions/coalesce.ts +0 -6
- package/src/style-spec/expression/definitions/coercion.ts +13 -18
- package/src/style-spec/expression/definitions/collator.ts +0 -10
- package/src/style-spec/expression/definitions/comparison.ts +0 -6
- package/src/style-spec/expression/definitions/format.ts +0 -19
- package/src/style-spec/expression/definitions/image.ts +0 -4
- package/src/style-spec/expression/definitions/in.ts +0 -4
- package/src/style-spec/expression/definitions/index_of.ts +0 -8
- package/src/style-spec/expression/definitions/interpolate.ts +1 -25
- package/src/style-spec/expression/definitions/length.ts +0 -6
- package/src/style-spec/expression/definitions/let.ts +0 -9
- package/src/style-spec/expression/definitions/literal.ts +1 -23
- package/src/style-spec/expression/definitions/match.ts +0 -41
- package/src/style-spec/expression/definitions/number_format.ts +0 -17
- package/src/style-spec/expression/definitions/slice.ts +0 -8
- package/src/style-spec/expression/definitions/step.ts +0 -11
- package/src/style-spec/expression/definitions/var.ts +0 -4
- package/src/style-spec/expression/definitions/within.ts +0 -5
- package/src/style-spec/expression/expression.test.ts +1 -1
- package/src/style-spec/expression/expression.ts +3 -3
- package/src/style-spec/expression/index.ts +8 -2
- package/src/style-spec/expression/parsing_context.ts +2 -0
- package/src/style-spec/expression/types/formatted.ts +0 -23
- package/src/style-spec/expression/types/resolved_image.ts +0 -4
- package/src/style-spec/expression/types.ts +6 -1
- package/src/style-spec/expression/values.ts +9 -4
- package/src/style-spec/feature_filter/convert.ts +65 -65
- package/src/style-spec/feature_filter/feature_filter.test.ts +45 -4
- package/src/style-spec/feature_filter/index.ts +2 -1
- package/src/style-spec/function/index.test.ts +117 -1
- package/src/style-spec/function/index.ts +24 -12
- package/src/style-spec/migrate/expressions.ts +2 -2
- package/src/style-spec/migrate/v8.test.ts +2 -0
- package/src/style-spec/migrate/v8.ts +8 -7
- package/src/style-spec/migrate/v9.test.ts +6 -4
- package/src/style-spec/migrate/v9.ts +3 -2
- package/src/style-spec/migrate.test.ts +3 -1
- package/src/style-spec/migrate.ts +5 -4
- package/src/style-spec/package.json +1 -1
- package/src/style-spec/read_style.ts +2 -1
- package/src/style-spec/reference/latest.ts +1 -1
- package/src/style-spec/reference/v8.json +9 -6
- package/src/style-spec/style-spec.test.ts +2 -1
- package/src/style-spec/style-spec.ts +8 -0
- package/src/style-spec/types.g.ts +152 -36
- package/src/style-spec/util/extend.ts +1 -1
- package/src/style-spec/util/interpolate.test.ts +5 -0
- package/src/style-spec/util/interpolate.ts +12 -0
- package/src/style-spec/util/padding.test.ts +27 -0
- package/src/style-spec/util/padding.ts +64 -0
- package/src/style-spec/util/ref_properties.ts +2 -1
- package/src/style-spec/validate/validate.ts +3 -1
- package/src/style-spec/validate/validate_expression.ts +2 -1
- package/src/style-spec/validate/validate_function.ts +2 -2
- package/src/style-spec/validate/validate_glyphs_url.ts +1 -1
- package/src/style-spec/validate/validate_object.ts +2 -2
- package/src/style-spec/validate/validate_padding.test.ts +82 -0
- package/src/style-spec/validate/validate_padding.ts +36 -0
- package/src/style-spec/validate_style.min.ts +4 -3
- package/src/style-spec/validate_style.ts +4 -3
- package/src/symbol/check_max_angle.test.ts +5 -5
- package/src/symbol/collision_feature.test.ts +22 -5
- package/src/symbol/collision_feature.ts +7 -5
- package/src/symbol/collision_index.ts +1 -1
- package/src/symbol/get_anchors.test.ts +4 -4
- package/src/symbol/{mergelines.test.ts → merge_lines.test.ts} +1 -1
- package/src/symbol/{mergelines.ts → merge_lines.ts} +1 -1
- package/src/symbol/projection.ts +1 -1
- package/src/symbol/quads.test.ts +1 -1
- package/src/symbol/shaping.ts +10 -10
- package/src/symbol/symbol_layout.ts +5 -4
- package/src/symbol/symbol_style_layer.test.ts +1 -1
- package/src/symbol/transform_text.ts +3 -3
- package/src/ui/camera.test.ts +11 -11
- package/src/ui/control/geolocate_control.ts +1 -1
- package/src/ui/control/terrain_control.ts +4 -4
- package/src/ui/handler/cooperative_gestures.test.ts +167 -0
- package/src/ui/handler/drag_pan.test.ts +2 -1
- package/src/ui/handler/scroll_zoom.ts +7 -0
- package/src/ui/handler/touch_pan.ts +22 -2
- package/src/ui/handler/touch_zoom_rotate.ts +18 -1
- package/src/ui/handler_manager.ts +2 -2
- package/src/ui/map.test.ts +17 -17
- package/src/ui/map.ts +76 -8
- package/src/ui/map_events.test.ts +33 -32
- package/src/ui/popup.test.ts +2 -2
- package/src/util/ajax.test.ts +5 -5
- package/src/util/ajax.ts +1 -1
- package/src/util/classify_rings.test.ts +27 -27
- package/src/util/find_pole_of_inaccessibility.ts +1 -1
- package/src/util/primitives.ts +4 -4
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/smart_wrap.ts +1 -1
- package/src/util/tile_request_cache.test.ts +5 -5
- package/src/util/util.test.ts +5 -5
package/dist/maplibre-gl-csp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).maplibregl=e()}(this,(function(){"use strict";var t=e;function e(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl",r)||i.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var r}(t)}var i={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var r=s;function s(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}function n(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!n(t[i],e[i]))return!1;return!0}return t===e}function a(t,e,i,s){const n=new r(t,e,i,s);return function(t){return n.solve(t)}}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 i=t,r=0;r<8;r++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var n=this.sampleCurveDerivativeX(i);if(Math.abs(n)<1e-6)break;i-=s/n}var a=0,o=1;for(i=t,r=0;r<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));r++)t>s?a=i:o=i,i=.5*(o-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};const o=a(.25,.1,.25,1);function l(t,e,i){return Math.min(i,Math.max(e,t))}function c(t,e,i){const r=i-e,s=((t-e)%r+r)%r+e;return s===e?i:s}function h(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const s=new Array(t.length);let n=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(n=t),s[a]=e,0==--r&&i(n,s)}))}))}function u(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function p(t,e){const i={};for(let r=0;r<e.length;r++){const s=e[r];s in t&&(i[s]=t[s])}return i}let d=1;function m(){return d++}function f(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function _(t,e,i){const r={};for(const s in t)r[s]=e.call(i||this,t[s],s,t);return r}function g(t,e,i){const r={};for(const s in t)e.call(i||this,t[s],s,t)&&(r[s]=t[s]);return r}function y(t){return Array.isArray(t)?t.map(y):"object"==typeof t&&t?_(t,y):t}const x={};function v(t){x[t]||("undefined"!=typeof console&&console.warn(t),x[t]=!0)}function b(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function w(t){let e=0;for(let i,r,s=0,n=t.length,a=n-1;s<n;a=s++)i=t[s],r=t[a],e+=(r.x-i.x)*(i.y+r.y);return e}function T(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function I(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,s)=>{const n=r||s;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let z,S,A=null;function E(t){if(null==A){const e=t.navigator?t.navigator.userAgent:null;A=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return A}function C(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const P={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const i=window.document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return i.width=t.width,i.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:t=>(z||(z=document.createElement("a")),z.href=t,z.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==S&&(S=matchMedia("(prefers-reduced-motion: reduce)")),S.matches)}};var k=M;function M(t,e){this.x=t,this.y=e}M.prototype={clone:function(){return new M(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,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},M.convert=function(t){return t instanceof M?t:Array.isArray(t)?new M(t[0],t[1]):t};class D{static testProp(t){if(!D.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in D.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){D.docStyle&&D.selectProp&&(D.userSelect=D.docStyle[D.selectProp],D.docStyle[D.selectProp]="none")}static enableDrag(){D.docStyle&&D.selectProp&&(D.docStyle[D.selectProp]=D.userSelect)}static setTransform(t,e){t.style[D.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",D.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",D.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",D.suppressClickInternal,!0)}),0)}static mousePos(t,e){const i=t.getBoundingClientRect();return new k(e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop)}static touchPos(t,e){const i=t.getBoundingClientRect(),r=[];for(let s=0;s<e.length;s++)r.push(new k(e[s].clientX-i.left-t.clientLeft,e[s].clientY-i.top-t.clientTop));return r}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}D.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,D.selectProp=D.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),D.transformProp=D.testProp(["transform","WebkitTransform"]);const L={MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},B="mapbox-tiles";let R,F,O=500,V=50;function U(){"undefined"==typeof caches||R||(R=caches.open(B))}let N=1/0;function q(t){N++,N>V&&(t.getActor().send("enforceCacheSizeLimit",O),N=0)}const $={supported:!1,testSupport:function(t){!G&&Z&&(X?W(t):j=t)}};let j,Z,G=!1,X=!1;function W(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Z),t.isContextLost())return;$.supported=!0}catch(t){}t.deleteTexture(e),G=!0}"undefined"!=typeof document&&(Z=document.createElement("img"),Z.onload=function(){j&&W(j),j=null,X=!0},Z.onerror=function(){G=!0,j=null},Z.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const H={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(H);class K extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const Y=T()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href;function J(t,e){const i=new AbortController,r=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Y(),signal:i.signal});let s=!1,n=!1;"json"===t.type&&r.headers.set("Accept","application/json");return((i,a,o)=>{if(n)return;const l=Date.now();fetch(r).then((i=>i.ok?((i,a,o)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{n||(a&&o&&function(t,e,i){if(U(),!R)return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const s=I(e.headers.get("Cache-Control")||"");s["no-store"]||(s["max-age"]&&r.headers.set("Expires",new Date(i+1e3*s["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-i<42e4||function(t,e){if(void 0===F)try{new Response(new ReadableStream),F=!0}catch(t){F=!1}F?e(t.body):t.blob().then(e)}(e,(e=>{const i=new Response(e,r);U(),R&&R.then((e=>e.put(function(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}(t.url),i))).catch((t=>v(t.message)))})))}(r,a,o),s=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{n||e(new Error(t.message))}))})(i,null,l):i.blob().then((r=>e(new K(i.status,i.statusText,t.url,r)))))).catch((t=>{20!==t.code&&e(new Error(t.message))}))})(),{cancel:()=>{n=!0,s||i.abort()}}}const Q=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!T()){const i=t.url.substring(0,t.url.indexOf("://"));return(L.REGISTERED_PROTOCOLS[i]||J)(t,e)}}if(!(/^file:/.test(i=t.url)||/^file:/.test(Y())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return J(t,e);if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else{const r=new Blob([i.response],{type:i.getResponseHeader("Content-Type")});e(new K(i.status,i.statusText,t.url,r))}},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},tt=function(t,e){return Q(u(t,{type:"json"}),e)},et=function(t,e){return Q(u(t,{type:"arrayBuffer"}),e)};function it(t){const e=window.document.createElement("a");return e.href=t,e.protocol===window.document.location.protocol&&e.host===window.document.location.host}const rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let st,nt;st=[],nt=0;const at=function(t,e){if($.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),nt>=L.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return st.push(i),i}nt++;let i=!1;const r=()=>{if(!i)for(i=!0,nt--;st.length&&nt<L.MAX_PARALLEL_IMAGE_REQUESTS;){const t=st.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=at(e,i).cancel)}},s=et(t,((t,i,s,n)=>{r(),t?e(t):i&&function(t,e){"function"==typeof createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(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.`))}))}(t,e):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame((()=>{i.src=rt}))},i.onerror=()=>e(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 r=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(r):rt}(t,e)}(i,((t,i)=>{null!=t?e(t):null!=i&&e(null,i,{cacheControl:s,expires:n})}))}));return{cancel:()=>{s.cancel(),r()}}};class ot{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeSpriteURL(t,e,i){const r=function(t){const e=t.match(lt);if(!e)throw new Error(`Unable to parse URL "${t}"`);return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}(t);return r.path+=`${e}${i}`,function(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}(r)}setTransformRequest(t){this._transformRequestFn=t}}const lt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ct(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function ht(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class ut{constructor(t,e={}){u(this,e),this.type=t}}class pt extends ut{constructor(t,e={}){super("error",u({error:t},e))}}class dt{on(t,e){return this._listeners=this._listeners||{},ct(t,e,this._listeners),this}off(t,e){return ht(t,e,this._listeners),ht(t,e,this._oneTimeListeners),this}once(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},ct(t,e,this._oneTimeListeners),this}fire(t,e){"string"==typeof t&&(t=new ut(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)ht(i,e,this._oneTimeListeners),e.call(this,t);const s=this._eventedParent;s&&(u(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof pt&&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 mt={$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"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"string"},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:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{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:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"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-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":{},within:{}}},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}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1},elevationOffset:{type:"number",default:450}},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"}}};class ft{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function _t(t){const e=t.value;return e?[new ft(t.key,e,"constants have been deprecated as of v8")]:[]}function gt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function yt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function xt(t){if(Array.isArray(t))return t.map(xt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=xt(t[i]);return e}return yt(t)}class vt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class bt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new bt(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 wt={kind:"null"},Tt={kind:"number"},It={kind:"string"},zt={kind:"boolean"},St={kind:"color"},At={kind:"object"},Et={kind:"value"},Ct={kind:"collator"},Pt={kind:"formatted"},kt={kind:"resolvedImage"};function Mt(t,e){return{kind:"array",itemType:t,N:e}}function Dt(t){if("array"===t.kind){const e=Dt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Lt=[wt,Tt,It,zt,St,Pt,At,Mt(Et),kt];function Bt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Bt(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 Lt)if(!Bt(t,e))return null}return`Expected ${Dt(t)} but found ${Dt(e)} instead.`}function Rt(t,e){return e.some((e=>e.kind===t.kind))}function Ft(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))}var Ot,Vt={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Ut(t){return(t=Math.round(t))<0?0:t>255?255:t}function Nt(t){return Ut("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function qt(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function $t(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Ot={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Vt)return Vt[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var r=i.indexOf("("),s=i.indexOf(")");if(-1!==r&&s+1===i.length){var n=i.substr(0,r),a=i.substr(r+1,s-(r+1)).split(","),o=1;switch(n){case"rgba":if(4!==a.length)return null;o=qt(a.pop());case"rgb":return 3!==a.length?null:[Nt(a[0]),Nt(a[1]),Nt(a[2]),o];case"hsla":if(4!==a.length)return null;o=qt(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,c=qt(a[1]),h=qt(a[2]),u=h<=.5?h*(c+1):h+c-h*c,p=2*h-u;return[Ut(255*$t(p,u,l+1/3)),Ut(255*$t(p,u,l)),Ut(255*$t(p,u,l-1/3)),o];default:return null}}return null}}catch(t){}class jt{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof jt)return t;if("string"!=typeof t)return;const e=Ot(t);return e?new jt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}jt.black=new jt(0,0,0,1),jt.white=new jt(1,1,1,1),jt.transparent=new jt(0,0,0,0),jt.red=new jt(1,0,0,1);class Zt{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,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 Gt{constructor(t,e,i,r,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=s}}class Xt{constructor(t){this.sections=t}static fromString(t){return new Xt([new Gt(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 Xt?t:Xt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class Wt{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Wt({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Ht(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Kt(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof jt)return!0;if(t instanceof Zt)return!0;if(t instanceof Xt)return!0;if(t instanceof Wt)return!0;if(Array.isArray(t)){for(const e of t)if(!Kt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Kt(t[e]))return!1;return!0}return!1}function Yt(t){if(null===t)return wt;if("string"==typeof t)return It;if("boolean"==typeof t)return zt;if("number"==typeof t)return Tt;if(t instanceof jt)return St;if(t instanceof Zt)return Ct;if(t instanceof Xt)return Pt;if(t instanceof Wt)return kt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Yt(e);if(i){if(i===t)continue;i=Et;break}i=t}return Mt(i||Et,e)}return At}function Jt(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof jt||t instanceof Xt||t instanceof Wt?t.toString():JSON.stringify(t)}class Qt{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(!Kt(t[1]))return e.error("invalid value");const i=t[1];let r=Yt(i);const s=e.expectedType;return"array"!==r.kind||0!==r.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(r=s),new Qt(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof jt?["rgba"].concat(this.value.toArray()):this.value instanceof Xt?this.value.serialize():this.value}}class te{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const ee={string:It,number:Tt,boolean:zt,object:At};class ie{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 i,r=1;const s=t[0];if("array"===s){let s,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in ee)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=ee[i],r++}else s=Et;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);n=t[2],r++}i=Mt(s,n)}else i=ee[s];const n=[];for(;r<t.length;r++){const i=e.parse(t[r],r,Et);if(!i)return null;n.push(i)}return new ie(i,n)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Bt(this.type,Yt(i)))return i;if(e===this.args.length-1)throw new te(`Expected value to be of type ${Dt(this.type)}, but found ${Dt(Yt(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}class re{constructor(t){this.type=Pt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let s=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(s&&"object"==typeof n&&!Array.isArray(n)){s=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,Tt),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,Mt(It)),!i))return null;let a=null;if(n["text-color"]&&(a=e.parse(n["text-color"],1,St),!a))return null;const o=r[r.length-1];o.scale=t,o.font=i,o.textColor=a}else{const n=e.parse(t[i],1,Et);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new re(r)}evaluate(t){return new Xt(this.sections.map((e=>{const i=e.content.evaluate(t);return Yt(i)===kt?new Gt("",i,null,null,null):new Gt(Jt(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class se{constructor(t){this.type=kt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,It);return i?new se(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Wt.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const ne={"to-boolean":zt,"to-color":St,"to-number":Tt,"to-string":It};class ae{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 i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=ne[i],s=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,Et);if(!r)return null;s.push(r)}return new ae(r,s)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof jt)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ht(e[0],e[1],e[2],e[3]),!i))return new jt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new te(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new te(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Xt.fromString(Jt(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Wt.fromString(Jt(this.args[0].evaluate(t))):Jt(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new re([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new se(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const oe=["Unknown","Point","LineString","Polygon"];class le{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?oe[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]=jt.parse(t)),e}}class ce{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=ce.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(r)?r[0]:r.type,n=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=n.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[r,n]of a){o=new Me(e.registry,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],s=Array.isArray(r)?r[e-1]:r.type,n=o.parse(i,1+a.length,s);if(!n){l=!0;break}a.push(n)}if(!l)if(Array.isArray(r)&&r.length!==a.length)o.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let t=0;t<a.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=a[t];o.concat(t+1).checkSubtype(e,i.type)}if(0===o.errors.length)return new ce(i,s,n,a)}}if(1===a.length)e.errors.push(...o.errors);else{const i=(a.length?a:n).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Dt).join(", ")})`:`(${Dt(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const s=e.parse(t[i],1+r.length);if(!s)return null;r.push(Dt(s.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){ce.definitions=e;for(const i in e)t[i]=ce}}class he{constructor(t,e,i){this.type=Ct,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,zt);if(!r)return null;const s=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,zt);if(!s)return null;let n=null;return i.locale&&(n=e.parse(i.locale,1,It),!n)?null:new he(r,s,n)}evaluate(t){return new Zt(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}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const ue=8192;function pe(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 de(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function me(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*ue),Math.round(r*s*ue)]}function fe(t,e,i){const r=t[0]-e[0],s=t[1]-e[1],n=t[0]-i[0],a=t[1]-i[1];return r*a-n*s==0&&r*n<=0&&s*a<=0}function _e(t,e){let i=!1;for(let a=0,o=e.length;a<o;a++){const o=e[a];for(let e=0,a=o.length;e<a-1;e++){if(fe(t,o[e],o[e+1]))return!1;(s=o[e])[1]>(r=t)[1]!=(n=o[e+1])[1]>r[1]&&r[0]<(n[0]-s[0])*(r[1]-s[1])/(n[1]-s[1])+s[0]&&(i=!i)}}var r,s,n;return i}function ge(t,e){for(let i=0;i<e.length;i++)if(_e(t,e[i]))return!0;return!1}function ye(t,e,i,r){const s=r[0]-i[0],n=r[1]-i[1],a=(t[0]-i[0])*n-s*(t[1]-i[1]),o=(e[0]-i[0])*n-s*(e[1]-i[1]);return a>0&&o<0||a<0&&o>0}function xe(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(o=[(a=c[i+1])[0]-(n=c[i])[0],a[1]-n[1]])[0]*(l=[(s=e)[0]-(r=t)[0],s[1]-r[1]])[1]-o[1]*l[0]&&ye(r,s,n,a)&&ye(n,a,r,s))return!0;var r,s,n,a,o,l;return!1}function ve(t,e){for(let i=0;i<t.length;++i)if(!_e(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(xe(t[i],t[i+1],e))return!1;return!0}function be(t,e){for(let i=0;i<e.length;i++)if(ve(t,e[i]))return!0;return!1}function we(t,e,i){const r=[];for(let s=0;s<t.length;s++){const n=[];for(let r=0;r<t[s].length;r++){const a=me(t[s][r],i);pe(e,a),n.push(a)}r.push(n)}return r}function Te(t,e,i){const r=[];for(let s=0;s<t.length;s++){const n=we(t[s],e,i);r.push(n)}return r}function Ie(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let s=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===s&&(s=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=s}pe(e,t)}function ze(t,e,i,r){const s=Math.pow(2,r.z)*ue,n=[r.x*ue,r.y*ue],a=[];for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];Ie(r,e,i,s),a.push(r)}return a}function Se(t,e,i,r){const s=Math.pow(2,r.z)*ue,n=[r.x*ue,r.y*ue],a=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];pe(e,i),t.push(i)}a.push(t)}if(e[2]-e[0]<=s/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const r of t)Ie(r,e,i,s)}var o;return a}class Ae{constructor(t,e){this.type=zt,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(Kt(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Ae(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Ae(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Ae(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=we(e.coordinates,r,s),a=ze(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!_e(t,n))return!1}if("MultiPolygon"===e.type){const n=Te(e.coordinates,r,s),a=ze(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!ge(t,n))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=we(e.coordinates,r,s),a=Se(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!ve(t,n))return!1}if("MultiPolygon"===e.type){const n=Te(e.coordinates,r,s),a=Se(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!be(t,n))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function Ee(t){if(t instanceof ce){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 Ae)return!1;let e=!0;return t.eachChild((t=>{e&&!Ee(t)&&(e=!1)})),e}function Ce(t){if(t instanceof ce&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Ce(t)&&(e=!1)})),e}function Pe(t,e){if(t instanceof ce&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Pe(t,e)&&(i=!1)})),i}class ke{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ke(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Me{constructor(t,e=[],i,r=new bt,s=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=s,this.expectedType=i}parse(t,e,i,r,s={}){return e?this.concat(e,i,r)._parse(t,s):this._parse(t,s)}_parse(t,e){function i(t,e,i){return"assert"===i?new ie(e,[t]):"coerce"===i?new ae(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 r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[r];if(s){let r=s.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,s=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(t,s))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Qt)&&"resolvedImage"!==r.type.kind&&De(r)){const t=new le;try{r=new Qt(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,s=i?this.scope.concat(i):this.scope;return new Me(this.registry,r,e||null,s,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new vt(i,t))}checkSubtype(t,e){const i=Bt(t,e);return i&&this.error(i),i}}function De(t){if(t instanceof ke)return De(t.boundExpression);if(t instanceof ce&&"error"===t.name)return!1;if(t instanceof he)return!1;if(t instanceof Ae)return!1;const e=t instanceof ae||t instanceof ie;let i=!0;return t.eachChild((t=>{i=e?i&&De(t):i&&t instanceof Qt})),!!i&&Ee(t)&&Pe(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Le(t,e){const i=t.length-1;let r,s,n=0,a=i,o=0;for(;n<=a;)if(o=Math.floor((n+a)/2),r=t[o],s=t[o+1],r<=e){if(o===i||e<s)return o;n=o+1}else{if(!(r>e))throw new te("Input is not a number.");a=o-1}return 0}class Be{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)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 i=e.parse(t[1],1,Tt);if(!i)return null;const r=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let i=1;i<t.length;i+=2){const n=1===i?-1/0:t[i],a=t[i+1],o=i,l=i+1;if("number"!=typeof n)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(r.length&&r[r.length-1][0]>=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(a,l,s);if(!c)return null;s=s||c.type,r.push([n,c])}return new Be(s,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;return r>=e[s-1]?i[s-1].evaluate(t):i[Le(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}function Re(t,e,i){return t*(1-i)+e*i}var Fe=Object.freeze({__proto__:null,number:Re,color:function(t,e,i){return new jt(Re(t.r,e.r,i),Re(t.g,e.g,i),Re(t.b,e.b,i),Re(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>Re(t,e[r],i)))}});const Oe=.95047,Ve=1.08883,Ue=4/29,Ne=6/29,qe=3*Ne*Ne,$e=Math.PI/180,je=180/Math.PI;function Ze(t){return t>.008856451679035631?Math.pow(t,1/3):t/qe+Ue}function Ge(t){return t>Ne?t*t*t:qe*(t-Ue)}function Xe(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function We(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function He(t){const e=We(t.r),i=We(t.g),r=We(t.b),s=Ze((.4124564*e+.3575761*i+.1804375*r)/Oe),n=Ze((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*n-16,a:500*(s-n),b:200*(n-Ze((.0193339*e+.119192*i+.9503041*r)/Ve)),alpha:t.a}}function Ke(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ge(e),i=Oe*Ge(i),r=Ve*Ge(r),new jt(Xe(3.2404542*i-1.5371385*e-.4985314*r),Xe(-.969266*i+1.8760108*e+.041556*r),Xe(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Ye(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Je={forward:He,reverse:Ke,interpolate:function(t,e,i){return{l:Re(t.l,e.l,i),a:Re(t.a,e.a,i),b:Re(t.b,e.b,i),alpha:Re(t.alpha,e.alpha,i)}}},Qe={forward:function(t){const{l:e,a:i,b:r}=He(t),s=Math.atan2(r,i)*je;return{h:s<0?s+360:s,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*$e,i=t.c;return Ke({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Ye(t.h,e.h,i),c:Re(t.c,e.c,i),l:Re(t.l,e.l,i),alpha:Re(t.alpha,e.alpha,i)}}};var ti=Object.freeze({__proto__:null,lab:Je,hcl:Qe});class ei{constructor(t,e,i,r,s){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of s)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,s){let n=0;if("exponential"===t.name)n=ii(e,t.base,i,s);else if("linear"===t.name)n=ii(e,1,i,s);else if("cubic-bezier"===t.name){const a=t.controlPoints;n=new r(a[0],a[1],a[2],a[3]).solve(ii(e,1,i,s))}return n}static parse(t,e){let[i,r,s,...n]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((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);r={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(s=e.parse(s,2,Tt),!s)return null;const a=[];let o=null;"interpolate-hcl"===i||"interpolate-lab"===i?o=St:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t<n.length;t+=2){const i=n[t],r=n[t+1],s=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(a.length&&a[a.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(r,l,o);if(!c)return null;o=o||c.type,a.push([i,c])}return"number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new ei(o,i,r,s,a):e.error(`Type ${Dt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;if(r>=e[s-1])return i[s-1].evaluate(t);const n=Le(e,r),a=ei.interpolationFactor(this.interpolation,r,e[n],e[n+1]),o=i[n].evaluate(t),l=i[n+1].evaluate(t);return"interpolate"===this.operator?Fe[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?Qe.reverse(Qe.interpolate(Qe.forward(o),Qe.forward(l),a)):Je.reverse(Je.interpolate(Je.forward(o),Je.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function ii(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}class ri{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 i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const s=[];for(const r of t.slice(1)){const t=e.parse(r,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,s.push(t)}const n=r&&s.some((t=>Bt(r,t.type)));return new ri(n?Et:i,s)}evaluate(t){let e,i=null,r=0;for(const s of this.args)if(r++,i=s.evaluate(t),i&&i instanceof Wt&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class si{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 i=[];for(let r=1;r<t.length-1;r+=2){const s=t[r];if("string"!=typeof s)return e.error(`Expected string, but found ${typeof s} instead.`,r);if(/[^a-zA-Z0-9_]/.test(s))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const n=e.parse(t[r+1],r+1);if(!n)return null;i.push([s,n])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new si(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,i]of this.bindings)t.push(e,i.serialize());return t.push(this.result.serialize()),t}}class ni{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Tt),r=e.parse(t[2],2,Mt(e.expectedType||Et));return i&&r?new ni(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new te(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new te(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new te(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class ai{constructor(t,e){this.type=zt,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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Et);return i&&r?Rt(i.type,[zt,It,Tt,wt,Et])?new ai(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Dt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Ft(e,["boolean","string","number","null"]))throw new te(`Expected first argument to be of type boolean, string, number or null, but found ${Dt(Yt(e))} instead.`);if(!Ft(i,["string","array"]))throw new te(`Expected second argument to be of type array or string, but found ${Dt(Yt(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class oi{constructor(t,e,i){this.type=Tt,this.needle=t,this.haystack=e,this.fromIndex=i}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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Et);if(!i||!r)return null;if(!Rt(i.type,[zt,It,Tt,wt,Et]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Dt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Tt);return s?new oi(i,r,s):null}return new oi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Ft(e,["boolean","string","number","null"]))throw new te(`Expected first argument to be of type boolean, string, number or null, but found ${Dt(Yt(e))} instead.`);if(!Ft(i,["string","array"]))throw new te(`Expected second argument to be of type array or string, but found ${Dt(Yt(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class li{constructor(t,e,i,r,s,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=s,this.otherwise=n}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 i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const s={},n=[];for(let a=2;a<t.length-1;a+=2){let o=t[a];const l=t[a+1];Array.isArray(o)||(o=[o]);const c=e.concat(a);if(0===o.length)return c.error("Expected at least one branch label.");for(const t of o){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.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(i){if(c.checkSubtype(i,Yt(t)))return null}else i=Yt(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=n.length}const h=e.parse(l,a,r);if(!h)return null;r=r||h.type,n.push(h)}const a=e.parse(t[1],1,Et);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,r);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(i,a.type)?null:new li(i,r,a,s,n,o):null}evaluate(t){const e=this.input.evaluate(t);return(Yt(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()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const s=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?s(r[0]):r.map(s)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class ci{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}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 i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let s=1;s<t.length-1;s+=2){const n=e.parse(t[s],s,zt);if(!n)return null;const a=e.parse(t[s+1],s+1,i);if(!a)return null;r.push([n,a]),i=i||a.type}const s=e.parse(t[t.length-1],t.length-1,i);return s?new ci(i,r,s):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class hi{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Tt);if(!i||!r)return null;if(!Rt(i.type,[Mt(Et),It,Et]))return e.error(`Expected first argument to be of type array or string, but found ${Dt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Tt);return s?new hi(i.type,i,r,s):null}return new hi(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Ft(e,["string","array"]))throw new te(`Expected first argument to be of type array or string, but found ${Dt(Yt(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ui(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 pi(t,e,i,r){return 0===r.compare(e,i)}function di(t,e,i){const r="=="!==t&&"!="!==t;return class s{constructor(t,e,i){this.type=zt,this.lhs=t,this.rhs=e,this.collator=i,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 i=t[0];let n=e.parse(t[1],1,Et);if(!n)return null;if(!ui(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Dt(n.type)}'.`);let a=e.parse(t[2],2,Et);if(!a)return null;if(!ui(i,a.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Dt(a.type)}'.`);if(n.type.kind!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Dt(n.type)}' and '${Dt(a.type)}'.`);r&&("value"===n.type.kind&&"value"!==a.type.kind?n=new ie(a.type,[n]):"value"!==n.type.kind&&"value"===a.type.kind&&(a=new ie(n.type,[a])));let o=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ct),!o)return null}return new s(n,a,o)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(r&&this.hasUntypedArgument){const e=Yt(n),i=Yt(a);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new te(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Yt(n),i=Yt(a);if("string"!==t.kind||"string"!==i.kind)return e(s,n,a)}return this.collator?i(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const mi=di("==",(function(t,e,i){return e===i}),pi),fi=di("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!pi(0,e,i,r)})),_i=di("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),gi=di(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),yi=di("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),xi=di(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class vi{constructor(t,e,i,r,s){this.type=It,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Tt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=e.parse(r.locale,1,It),!s))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,It),!n))return null;let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,Tt),!a))return null;let o=null;return r["max-fraction-digits"]&&(o=e.parse(r["max-fraction-digits"],1,Tt),!o)?null:new vi(i,s,n,a,o)}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}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class bi{constructor(t){this.type=Tt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Dt(i.type)} instead.`):new bi(i):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 te(`Expected value to be of type string or array, but found ${Dt(Yt(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const wi={"==":mi,"!=":fi,">":gi,"<":_i,">=":xi,"<=":yi,array:ie,at:ni,boolean:ie,case:ci,coalesce:ri,collator:he,format:re,image:se,in:ai,"index-of":oi,interpolate:ei,"interpolate-hcl":ei,"interpolate-lab":ei,length:bi,let:si,literal:Qt,match:li,number:ie,"number-format":vi,object:ie,slice:hi,step:Be,string:ie,"to-boolean":ae,"to-color":ae,"to-number":ae,"to-string":ae,var:ke,within:Ae};function Ti(t,[e,i,r,s]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const n=s?s.evaluate(t):1,a=Ht(e,i,r,n);if(a)throw new te(a);return new jt(e/255*n,i/255*n,r/255*n,n)}function Ii(t,e){return t in e}function zi(t,e){const i=e[t];return void 0===i?null:i}function Si(t){return{type:t}}function Ai(t){return{result:"success",value:t}}function Ei(t){return{result:"error",value:t}}function Ci(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Pi(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function ki(t){return!!t.expression&&t.expression.interpolated}function Mi(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Di(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Li(t){return t}function Bi(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],s=r||!(r||void 0!==t.property),n=t.type||(ki(e)?"exponential":"interval");if(i&&((t=gt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],jt.parse(t[1])]))),t.default=jt.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ti[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let a,o,l;if("exponential"===n)a=Vi;else if("interval"===n)a=Oi;else if("categorical"===n){a=Fi,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);a=Ui}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const s=t.stops[e],n=s[0].zoom;void 0===i[n]&&(i[n]={zoom:n,type:t.type,property:t.property,default:t.default,stops:[]},r.push(n)),i[n].stops.push([s[0].value,s[1]])}const s=[];for(const t of r)s.push([i[t].zoom,Bi(i[t],e)]);const n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:ei.interpolationFactor.bind(void 0,n),zoomStops:s.map((t=>t[0])),evaluate:({zoom:i},r)=>Vi({stops:s,base:t.base},e,i).evaluate(i,r)}}if(s){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ei.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,o,l)}}return{kind:"source",evaluate(i,r){const s=r&&r.properties?r.properties[t.property]:void 0;return void 0===s?Ri(t.default,e.default):a(t,e,s,o,l)}}}function Ri(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Fi(t,e,i,r,s){return Ri(typeof i===s?r[i]:void 0,t.default,e.default)}function Oi(t,e,i){if("number"!==Mi(i))return Ri(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const s=Le(t.stops.map((t=>t[0])),i);return t.stops[s][1]}function Vi(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Mi(i))return Ri(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const n=Le(t.stops.map((t=>t[0])),i),a=function(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),o=t.stops[n][1],l=t.stops[n+1][1];let c=Fe[e.type]||Li;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ti[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),a))}return"function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,a)}}:c(o,l,a)}function Ui(t,e,i){return"color"===e.type?i=jt.parse(i):"formatted"===e.type?i=Xt.fromString(i.toString()):"resolvedImage"===e.type?i=Wt.fromString(i.toString()):Mi(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Ri(i,t.default,e.default)}ce.register(wi,{error:[{kind:"error"},[It],(t,[e])=>{throw new te(e.evaluate(t))}],typeof:[It,[Et],(t,[e])=>Dt(Yt(e.evaluate(t)))],"to-rgba":[Mt(Tt,4),[St],(t,[e])=>e.evaluate(t).toArray()],rgb:[St,[Tt,Tt,Tt],Ti],rgba:[St,[Tt,Tt,Tt,Tt],Ti],has:{type:zt,overloads:[[[It],(t,[e])=>Ii(e.evaluate(t),t.properties())],[[It,At],(t,[e,i])=>Ii(e.evaluate(t),i.evaluate(t))]]},get:{type:Et,overloads:[[[It],(t,[e])=>zi(e.evaluate(t),t.properties())],[[It,At],(t,[e,i])=>zi(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Et,[It],(t,[e])=>zi(e.evaluate(t),t.featureState||{})],properties:[At,[],t=>t.properties()],"geometry-type":[It,[],t=>t.geometryType()],id:[Et,[],t=>t.id()],zoom:[Tt,[],t=>t.globals.zoom],"heatmap-density":[Tt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Tt,[],t=>t.globals.lineProgress||0],accumulated:[Et,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Tt,Si(Tt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Tt,Si(Tt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Tt,overloads:[[[Tt,Tt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Tt],(t,[e])=>-e.evaluate(t)]]},"/":[Tt,[Tt,Tt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Tt,[Tt,Tt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Tt,[Tt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Tt,[Tt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Tt,[Tt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Tt,[Tt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Tt,[Tt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Tt,[Tt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Tt,[Tt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Tt,Si(Tt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Tt,Si(Tt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Tt,[Tt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Tt,[Tt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Tt,[Tt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Tt,[Tt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[zt,[It,Et],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[zt,[Et],(t,[e])=>t.id()===e.value],"filter-type-==":[zt,[It],(t,[e])=>t.geometryType()===e.value],"filter-<":[zt,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[zt,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[zt,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[zt,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[zt,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[zt,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[zt,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[zt,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[zt,[Et],(t,[e])=>e.value in t.properties()],"filter-has-id":[zt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[zt,[Mt(It)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[zt,[Mt(Et)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[zt,[It,Mt(Et)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[zt,[It,Mt(Et)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const s=i+r>>1;if(e[s]===t)return!0;e[s]>t?r=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:zt,overloads:[[[zt,zt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Si(zt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:zt,overloads:[[[zt,zt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Si(zt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[zt,[zt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[zt,[It],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[It,[It],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[It,[It],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[It,Si(Et),(t,e)=>e.map((e=>Jt(e.evaluate(t)))).join("")],"resolved-locale":[It,[Ct],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Ni{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new le,this._defaultValue=e?function(t){return"color"===t.type&&Di(t.default)?new jt(0,0,0,0):"color"===t.type?jt.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,s,n){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||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 te(`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 qi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in wi}function $i(t,e){const i=new Me(wi,[],e?function(t){const e={color:St,string:It,number:Tt,enum:It,boolean:zt,formatted:Pt,resolvedImage:kt};return"array"===t.type?Mt(e[t.value]||Et,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Ai(new Ni(r,e)):Ei(i.errors)}class ji{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ce(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}}class Zi{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ce(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?ei.interpolationFactor(this.interpolationType,t,e,i):0}}function Gi(t,e){const i=$i(t,e);if("error"===i.result)return i;const r=i.value.expression,s=Ee(r);if(!s&&!Ci(e))return Ei([new vt("","data expressions not supported")]);const n=Pe(r,["zoom"]);if(!n&&!Pi(e))return Ei([new vt("","zoom expressions not supported")]);const a=Wi(r);return a||n?a instanceof vt?Ei([a]):a instanceof ei&&!ki(e)?Ei([new vt("",'"interpolate" expressions cannot be used with this property')]):Ai(a?new Zi(s?"camera":"composite",i.value,a.labels,a instanceof ei?a.interpolation:void 0):new ji(s?"constant":"source",i.value)):Ei([new vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Xi{constructor(t,e){this._parameters=t,this._specification=e,gt(this,Bi(this._parameters,this._specification))}static deserialize(t){return new Xi(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Wi(t){let e=null;if(t instanceof si)e=Wi(t.result);else if(t instanceof ri){for(const i of t.args)if(e=Wi(i),e)break}else(t instanceof Be||t instanceof ei)&&t.input instanceof ce&&"zoom"===t.input.name&&(e=t);return e instanceof vt||t.eachChild((t=>{const i=Wi(t);i instanceof vt?e=i:!e&&i?e=new vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new vt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Hi(t){const e=t.key,i=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},n=t.style,a=t.styleSpec;let o=[];const l=Mi(i);if("object"!==l)return[new ft(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(s[l])h=s[l];else if(r[l])h=Tr;else if(s["*"])h=s["*"];else{if(!r["*"]){o.push(new ft(e,i[t],`unknown property "${t}"`));continue}h=Tr}o=o.concat(h({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:n,styleSpec:a,object:i,objectKey:t},i))}for(const t in r)s[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&o.push(new ft(e,i,`missing required property "${t}"`));return o}function Ki(t){const e=t.value,i=t.valueSpec,r=t.style,s=t.styleSpec,n=t.key,a=t.arrayElementValidator||Tr;if("array"!==Mi(e))return[new ft(n,e,`array expected, ${Mi(e)} found`)];if(i.length&&e.length!==i.length)return[new ft(n,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new ft(n,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let o={type:i.value,values:i.values};s.$version<7&&(o.function=i.function),"object"===Mi(i.value)&&(o=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(a({array:e,arrayIndex:t,value:e[t],valueSpec:o,style:r,styleSpec:s,key:`${n}[${t}]`}));return l}function Yi(t){const e=t.key,i=t.value,r=t.valueSpec;let s=Mi(i);return"number"===s&&i!=i&&(s="NaN"),"number"!==s?[new ft(e,i,`number expected, ${s} found`)]:"minimum"in r&&i<r.minimum?[new ft(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new ft(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function Ji(t){const e=t.valueSpec,i=yt(t.value.type);let r,s,n,a={};const o="categorical"!==i&&void 0===t.value.property,l=!o,c="array"===Mi(t.value.stops)&&"array"===Mi(t.value.stops[0])&&"object"===Mi(t.value.stops[0][0]),h=Hi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new ft(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ki({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Mi(r)&&0===r.length&&e.push(new ft(t.key,r,"array must have at least one stop")),e},default:function(t){return Tr({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&o&&h.push(new ft(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new ft(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!ki(t.valueSpec)&&h.push(new ft(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Ci(t.valueSpec)?h.push(new ft(t.key,t.value,"property functions not supported")):o&&!Pi(t.valueSpec)&&h.push(new ft(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new ft(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,o=t.key;if("array"!==Mi(r))return[new ft(o,r,`array expected, ${Mi(r)} found`)];if(2!==r.length)return[new ft(o,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Mi(r[0]))return[new ft(o,r,`object expected, ${Mi(r[0])} found`)];if(void 0===r[0].zoom)return[new ft(o,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new ft(o,r,"object stop key must have value")];if(n&&n>yt(r[0].zoom))return[new ft(o,r[0].zoom,"stop zoom values must appear in ascending order")];yt(r[0].zoom)!==n&&(n=yt(r[0].zoom),s=void 0,a={}),i=i.concat(Hi({key:`${o}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Yi,value:p}}))}else i=i.concat(p({key:`${o}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return qi(xt(r[1]))?i.concat([new ft(`${o}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(Tr({key:`${o}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,n){const o=Mi(t.value),l=yt(t.value),c=null!==t.value?t.value:n;if(r){if(o!==r)return[new ft(t.key,c,`${o} stop domain type must match previous stop domain type ${r}`)]}else r=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new ft(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==i){let r=`number expected, ${o} found`;return Ci(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ft(t.key,c,r)]}return"categorical"!==i||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===o&&void 0!==s&&l<s?[new ft(t.key,c,"stop domain values must appear in ascending order")]:(s=l,"categorical"===i&&l in a?[new ft(t.key,c,"stop domain values must be unique")]:(a[l]=!0,[])):[new ft(t.key,c,`integer expected, found ${l}`)]}}function Qi(t){const e=("property"===t.expressionContext?Gi:$i)(xt(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new ft(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.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&&!Ce(i))return[new ft(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ce(i))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(!Pe(i,["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&&!Ee(i))return[new ft(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function tr(t){const e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(yt(i))&&s.push(new ft(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(yt(i))&&s.push(new ft(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function er(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(!er(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const ir={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function rr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};er(t)||(t=ar(t));const e=$i(t,ir);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:nr(t)}}function sr(t,e){return t<e?-1:t>e?1:0}function nr(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(nr(t[e]))return!0;return!1}function ar(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?or(t[1],t[2],"=="):"!="===e?hr(or(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?or(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(ar))):"all"===e?["all"].concat(t.slice(1).map(ar)):"none"===e?["all"].concat(t.slice(1).map(ar).map(hr)):"in"===e?lr(t[1],t.slice(2)):"!in"===e?hr(lr(t[1],t.slice(2))):"has"===e?cr(t[1]):"!has"===e?hr(cr(t[1])):"within"!==e||t;var i}function or(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function lr(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(sr)]]:["filter-in-small",t,["literal",e]]}}function cr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function hr(t){return["!",t]}function ur(t){return er(xt(t.value))?Qi(gt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):pr(t)}function pr(t){const e=t.value,i=t.key;if("array"!==Mi(e))return[new ft(i,e,`array expected, ${Mi(e)} found`)];const r=t.styleSpec;let s,n=[];if(e.length<1)return[new ft(i,e,"filter array must have at least 1 element")];switch(n=n.concat(tr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),yt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===yt(e[1])&&n.push(new ft(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new ft(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=Mi(e[1]),"string"!==s&&n.push(new ft(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let a=2;a<e.length;a++)s=Mi(e[a]),"$type"===yt(e[1])?n=n.concat(tr({key:`${i}[${a}]`,value:e[a],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==s&&"number"!==s&&"boolean"!==s&&n.push(new ft(`${i}[${a}]`,e[a],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)n=n.concat(pr({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":s=Mi(e[1]),2!==e.length?n.push(new ft(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==s&&n.push(new ft(`${i}[1]`,e[1],`string expected, ${s} found`));break;case"within":s=Mi(e[1]),2!==e.length?n.push(new ft(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==s&&n.push(new ft(`${i}[1]`,e[1],`object expected, ${s} found`))}return n}function dr(t,e){const i=t.key,r=t.style,s=t.styleSpec,n=t.value,a=t.objectKey,o=s[`${e}_${t.layerType}`];if(!o)return[];const l=a.match(/^(.*)-transition$/);if("paint"===e&&l&&o[l[1]]&&o[l[1]].transition)return Tr({key:i,value:n,valueSpec:s.transition,style:r,styleSpec:s});const c=t.valueSpec||o[a];if(!c)return[new ft(i,n,`unknown property "${a}"`)];let h;if("string"===Mi(n)&&Ci(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(n)))return[new ft(i,n,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===a&&r&&!r.glyphs&&u.push(new ft(i,n,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Di(xt(n))&&"identity"===yt(n.type)&&u.push(new ft(i,n,'"text-font" does not support identity functions'))),u.concat(Tr({key:t.key,value:n,valueSpec:c,style:r,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function mr(t){return dr(t,"paint")}function fr(t){return dr(t,"layout")}function _r(t){let e=[];const i=t.value,r=t.key,s=t.style,n=t.styleSpec;i.type||i.ref||e.push(new ft(r,i,'either "type" or "ref" is required'));let a=yt(i.type);const o=yt(i.ref);if(i.id){const n=yt(i.id);for(let a=0;a<t.arrayIndex;a++){const t=s.layers[a];yt(t.id)===n&&e.push(new ft(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new ft(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{yt(e.id)===o&&(t=e)})),t?t.ref?e.push(new ft(r,i.ref,"ref cannot reference another ref layer")):a=yt(t.type):e.push(new ft(r,i.ref,`ref layer "${o}" not found`))}else if("background"!==a)if(i.source){const t=s.sources&&s.sources[i.source],n=t&&yt(t.type);t?"vector"===n&&"raster"===a?e.push(new ft(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===n&&"raster"!==a?e.push(new ft(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==a?e.push(new ft(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]||"geojson"===n&&t.lineMetrics||e.push(new ft(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ft(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new ft(r,i.source,`source "${i.source}" not found`))}else e.push(new ft(r,i,'missing required property "source"'));return e=e.concat(Hi({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Tr({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:ur,layout:t=>Hi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>fr(gt({layerType:a},t))}}),paint:t=>Hi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>mr(gt({layerType:a},t))}})}})),e}function gr(t){const e=t.value,i=t.key,r=Mi(e);return"string"!==r?[new ft(i,e,`string expected, ${r} found`)]:[]}const yr={promoteId:function({key:t,value:e}){if("string"===Mi(e))return gr({key:t,value:e});{const i=[];for(const r in e)i.push(...gr({key:`${t}.${r}`,value:e[r]}));return i}}};function xr(t){const e=t.value,i=t.key,r=t.styleSpec,s=t.style;if(!e.type)return[new ft(i,e,'"type" is required')];const n=yt(e.type);let a;switch(n){case"vector":case"raster":case"raster-dem":return a=Hi({key:i,value:e,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:yr}),a;case"geojson":if(a=Hi({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,objectElementValidators:yr}),e.cluster)for(const t in e.clusterProperties){const[r,s]=e.clusterProperties[t],n="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...Qi({key:`${i}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...Qi({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return a;case"video":return Hi({key:i,value:e,valueSpec:r.source_video,style:s,styleSpec:r});case"image":return Hi({key:i,value:e,valueSpec:r.source_image,style:s,styleSpec:r});case"canvas":return[new ft(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return tr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,styleSpec:r})}}function vr(t){const e=t.value,i=t.styleSpec,r=i.light,s=t.style;let n=[];const a=Mi(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new ft("light",e,`object expected, ${a} found`)]),n;for(const t in e){const a=t.match(/^(.*)-transition$/);n=n.concat(a&&r[a[1]]&&r[a[1]].transition?Tr({key:t,value:e[t],valueSpec:i.transition,style:s,styleSpec:i}):r[t]?Tr({key:t,value:e[t],valueSpec:r[t],style:s,styleSpec:i}):[new ft(t,e[t],`unknown property "${t}"`)])}return n}function br(t){const e=t.value,i=t.styleSpec,r=i.terrain,s=t.style;let n=[];const a=Mi(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new ft("terrain",e,`object expected, ${a} found`)]),n;for(const t in e)n=n.concat(r[t]?Tr({key:t,value:e[t],valueSpec:r[t],style:s,styleSpec:i}):[new ft(t,e[t],`unknown property "${t}"`)]);return n}const wr={"*":()=>[],array:Ki,boolean:function(t){const e=t.value,i=t.key,r=Mi(e);return"boolean"!==r?[new ft(i,e,`boolean expected, ${r} found`)]:[]},number:Yi,color:function(t){const e=t.key,i=t.value,r=Mi(i);return"string"!==r?[new ft(e,i,`color expected, ${r} found`)]:null===Ot(i)?[new ft(e,i,`color expected, "${i}" found`)]:[]},constants:_t,enum:tr,filter:ur,function:Ji,layer:_r,object:Hi,source:xr,light:vr,terrain:br,string:gr,formatted:function(t){return 0===gr(t).length?[]:Qi(t)},resolvedImage:function(t){return 0===gr(t).length?[]:Qi(t)}};function Tr(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Di(yt(e))?Ji(t):i.expression&&qi(xt(e))?Qi(t):i.type&&wr[i.type]?wr[i.type](t):Hi(gt({},t,{valueSpec:i.type?r[i.type]:i}))}function Ir(t){const e=t.value,i=t.key,r=gr(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new ft(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new ft(i,e,'"glyphs" url must include a "{range}" token'))),r}function zr(t,e=mt){let i=[];return i=i.concat(Tr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Ir,"*":()=>[]}})),t.constants&&(i=i.concat(_t({key:"constants",value:t.constants,style:t,styleSpec:e}))),Sr(i)}function Sr(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Ar(t){return function(...e){return Sr(t.apply(this,e))}}zr.source=Ar(xr),zr.light=Ar(vr),zr.terrain=Ar(br),zr.layer=Ar(_r),zr.filter=Ar(ur),zr.paintProperty=Ar(mr),zr.layoutProperty=Ar(fr);const Er=zr,Cr=Er.light,Pr=Er.paintProperty,kr=Er.layoutProperty;function Mr(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new pt(new Error(r.message))),i=!0;return i}class Dr{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t<this.d*this.d;t++){const e=s[3+t],i=s[3+t+1];r.push(e===i?null:s.subarray(e,i))}const n=s[3+r.length+1];this.keys=s.subarray(s[3+r.length],n),this.bboxes=s.subarray(n),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const s=i/e*t;this.min=-s,this.max=t+s}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,s,n){this.cells[s].push(n)}query(t,e,i,r,s){const n=this.min,a=this.max;if(t<=n&&e<=n&&a<=i&&a<=r&&!s)return Array.prototype.slice.call(this.keys);{const n=[];return this._forEachCell(t,e,i,r,this._queryCell,n,{},s),n}}_queryCell(t,e,i,r,s,n,a,o){const l=this.cells[s];if(null!==l){const s=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===a[u]){const l=4*u;(o?o(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(a[u]=!0,n.push(s[u])):a[u]=!1}}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++){const c=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&s.call(this,t,e,i,r,c,n,a,o))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let s=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=s,r.set(i,s),s+=i.length}return r[3+t.length]=s,r.set(this.keys,s),s+=this.keys.length,r[3+t.length+1]=s,r.set(this.bboxes,s),s+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new Dr(t.buffer)}}const Lr={};function Br(t,e,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Lr[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Br("Object",Object),Br("TransferableGridIndex",Dr),Br("Color",jt),Br("Error",Error),Br("AJAXError",K),Br("ResolvedImage",Wt),Br("StylePropertyFunction",Xi),Br("StyleExpression",Ni,{omit:["_evaluator"]}),Br("ZoomDependentExpression",Zi),Br("ZoomConstantExpression",ji),Br("CompoundExpression",ce,{omit:["_evaluate"]});for(const t in wi)wi[t]._classRegistryKey||Br(`Expression_${t}`,wi[t]);function Rr(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Fr(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob)return t;if(Rr(t))return e&&e.push(t),t;if(C(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(Fr(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class");const s=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const i in t){if(!t.hasOwnProperty(i))continue;if(Lr[r].omit.indexOf(i)>=0)continue;const n=t[i];s[i]=Lr[r].shallow.indexOf(i)>=0?n:Fr(n,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(s.$name=r),s}throw new Error("can't serialize object of type "+typeof t)}function Or(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Rr(t)||C(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Or);if("object"==typeof t){const e=t.$name||"Object";if(!Lr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Lr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const s=t[i];r[i]=Lr[e].shallow.indexOf(i)>=0?s:Or(s)}return r}throw new Error("can't deserialize object of type "+typeof t)}class Vr{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const Ur=t=>t>=12352&&t<=12447,Nr=t=>t>=12448&&t<=12543,qr=t=>t>=19968&&t<=40959,$r=t=>t>=44032&&t<=55215;function jr(t){for(const e of t)if(Zr(e.charCodeAt(0)))return!0;return!1}function Zr(t){return!(746!==t&&747!==t&&(t<4352||!((t=>t>=12704&&t<=12735)(t)||(t=>t>=12544&&t<=12591)(t)||(t=>t>=65072&&t<=65103)(t)&&!(t>=65097&&t<=65103)||(t=>t>=63744&&t<=64255)(t)||(t=>t>=13056&&t<=13311)(t)||(t=>t>=11904&&t<=12031)(t)||(t=>t>=12736&&t<=12783)(t)||!(!(t=>t>=12288&&t<=12351)(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||(t=>t>=13312&&t<=19903)(t)||qr(t)||(t=>t>=12800&&t<=13055)(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||$r(t)||Ur(t)||(t=>t>=12272&&t<=12287)(t)||(t=>t>=12688&&t<=12703)(t)||(t=>t>=12032&&t<=12255)(t)||(t=>t>=12784&&t<=12799)(t)||Nr(t)&&12540!==t||!(!(t=>t>=65280&&t<=65519)(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)||!(!(t=>t>=65104&&t<=65135)(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||(t=>t>=65040&&t<=65055)(t)||(t=>t>=19904&&t<=19967)(t)||(t=>t>=40960&&t<=42127)(t)||(t=>t>=42128&&t<=42191)(t))))}function Gr(t){return t>=1424&&t<=2303||(t=>t>=64336&&t<=65023)(t)||(t=>t>=65136&&t<=65279)(t)}function Xr(t,e){return!(!e&&Gr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function Wr(t){for(const e of t)if(Gr(e.charCodeAt(0)))return!0;return!1}const Hr="deferred",Kr="loading",Yr="loaded";let Jr=null,Qr="unavailable",ts=null;const es=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(Qr="error"),Jr&&Jr(t)};function is(){rs.fire(new ut("pluginStateChange",{pluginStatus:Qr,pluginURL:ts}))}const rs=new dt,ss=function(){return Qr},ns=function(){if(Qr!==Hr||!ts)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Qr=Kr,is(),ts&&et({url:ts},(t=>{t?es(t):(Qr=Yr,is())}))},as={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Qr===Yr||null!=as.applyArabicShaping,isLoading:()=>Qr===Kr,setState(t){Qr=t.pluginStatus,ts=t.pluginURL},isParsed:()=>null!=as.applyArabicShaping,getPluginURL:()=>ts};class os{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 Vr,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!Xr(i.charCodeAt(0),e))return!1;return!0}(t,as.isLoaded())}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),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class ls{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Di(t))return new Xi(t,e);if(qi(t)){const i=Gi(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=jt.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class cs{constructor(t){this.property=t,this.value=new ls(t,void 0)}transitioned(t,e){return new us(this.property,this.value,e,u({},t.transition,this.transition),t.now)}untransitioned(){return new us(this.property,this.value,null,{},0)}}class hs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return y(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new cs(this._values[t].property)),this._values[t].value=new ls(this._values[t].property,null===e?void 0:y(e))}getTransition(t){return y(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new cs(this._values[t].property)),this._values[t].transition=y(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new ps(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new ps(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class us{constructor(t,e,i,r,s){this.property=t,this.value=e,this.begin=s+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,s=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(r<this.begin)return n.possiblyEvaluate(t,e,i);{const a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(t,e,i),s,function(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(a))}}return s}}class ps{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new fs(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class ds{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return y(this._values[t].value)}setValue(t,e){this._values[t]=new ls(this._values[t].property,null===e?void 0:y(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new fs(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}}class ms{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class _s{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=Fe[this.specification.type];return r?r(t,e,i):t}}class gs{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new ms(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new ms(this,{kind:"constant",value:void 0},t.parameters);const r=Fe[this.specification.type];return r?new ms(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,s,n){return"constant"===t.kind?t.value:t.evaluate(e,i,r,s,n)}}class ys extends gs{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new ms(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r),n="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,a=this._calculate(n,n,n,e);return new ms(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new ms(this,{kind:"constant",value:i},e)}return new ms(this,t.expression,e)}evaluate(t,e,i,r,s,n){if("source"===t.kind){const a=t.evaluate(e,i,r,s,n);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class xs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new os(Math.floor(e.zoom-1),e)),t.expression.evaluate(new os(Math.floor(e.zoom),e)),t.expression.evaluate(new os(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class vs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class bs{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new ls(i,void 0),s=this.defaultTransitionablePropertyValues[e]=new cs(i);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Br("DataDrivenProperty",gs),Br("DataConstantProperty",_s),Br("CrossFadedDataDrivenProperty",ys),Br("CrossFadedProperty",xs),Br("ColorRampProperty",vs);const ws="-transition";class Ts extends dt{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=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 ds(e.layout)),e.paint)){this._transitionablePaint=new hs(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 fs(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(kr,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(ws)?this._transitionablePaint.getTransition(t.slice(0,-ws.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Pr,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(ws))return this._transitionablePaint.setTransition(t.slice(0,-ws.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||s||r||this._handleOverridablePaintPropertyUpdate(t,n,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&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),g(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&Mr(this,t.call(Er,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:mt,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 ms&&Ci(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Is={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ss{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function As(t,e=1){let i=0,r=0;return{members:t.map((t=>{const s=Is[t.type].BYTES_PER_ELEMENT,n=i=Es(i,Math.max(e,s)),a=t.components||1;return r=Math.max(r,s),i+=s*a,{name:t.name,type:t.type,components:a,offset:n}})),size:Es(i,Math.max(r,e)),alignment:e}}function Es(t,e){return Math.ceil(t/e)*e}class Cs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Cs.prototype.bytesPerElement=4,Br("StructArrayLayout2i4",Cs);class Ps extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=s,t}}Ps.prototype.bytesPerElement=8,Br("StructArrayLayout4i8",Ps);class ks extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}ks.prototype.bytesPerElement=12,Br("StructArrayLayout2i4i12",ks);class Ms extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=s,this.uint8[l+6]=n,this.uint8[l+7]=a,t}}Ms.prototype.bytesPerElement=8,Br("StructArrayLayout2i4ub8",Ms);class Ds extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Ds.prototype.bytesPerElement=8,Br("StructArrayLayout2f8",Ds);class Ls extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,s,n,a,o,l,c)}emplace(t,e,i,r,s,n,a,o,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=n,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Ls.prototype.bytesPerElement=20,Br("StructArrayLayout10ui20",Ls);class Bs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,s,n,a,o,l,c,h,u)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=s,this.uint16[d+4]=n,this.uint16[d+5]=a,this.uint16[d+6]=o,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,t}}Bs.prototype.bytesPerElement=24,Br("StructArrayLayout4i4ui4i24",Bs);class Rs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}Rs.prototype.bytesPerElement=12,Br("StructArrayLayout3f12",Rs);class Fs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Fs.prototype.bytesPerElement=4,Br("StructArrayLayout1ul4",Fs);class Os extends Ss{_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,i,r,s,n,a,o,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,s,n,a,o,l)}emplace(t,e,i,r,s,n,a,o,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=s,this.int16[h+4]=n,this.int16[h+5]=a,this.uint32[u+3]=o,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}Os.prototype.bytesPerElement=20,Br("StructArrayLayout6i1ul2ui20",Os);class Vs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}Vs.prototype.bytesPerElement=12,Br("StructArrayLayout2i2i2i12",Vs);class Us extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,s)}emplace(t,e,i,r,s,n){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[o+6]=s,this.int16[o+7]=n,t}}Us.prototype.bytesPerElement=16,Br("StructArrayLayout2f1f2i16",Us);class Ns extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=12*t,a=3*t;return this.uint8[n+0]=e,this.uint8[n+1]=i,this.float32[a+1]=r,this.float32[a+2]=s,t}}Ns.prototype.bytesPerElement=12,Br("StructArrayLayout2ub2f12",Ns);class qs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=r,t}}qs.prototype.bytesPerElement=6,Br("StructArrayLayout3ui6",qs);class $s extends Ss{_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,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=s,this.uint32[x+2]=n,this.uint32[x+3]=a,this.uint32[x+4]=o,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=p,this.uint8[v+36]=d,this.uint8[v+37]=m,this.uint8[v+38]=f,this.uint32[x+10]=_,this.int16[y+22]=g,t}}$s.prototype.bytesPerElement=48,Br("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",$s);class js extends Ss{_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,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,z,S,A){const E=this.length;return this.resize(E+1),this.emplace(E,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,z,S,A)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,z,S,A,E){const C=34*t,P=17*t;return this.int16[C+0]=e,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=s,this.int16[C+4]=n,this.int16[C+5]=a,this.int16[C+6]=o,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=p,this.uint16[C+12]=d,this.uint16[C+13]=m,this.uint16[C+14]=f,this.uint16[C+15]=_,this.uint16[C+16]=g,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[P+12]=I,this.float32[P+13]=z,this.float32[P+14]=S,this.float32[P+15]=A,this.float32[P+16]=E,t}}js.prototype.bytesPerElement=68,Br("StructArrayLayout8i15ui1ul4f68",js);class Zs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Zs.prototype.bytesPerElement=4,Br("StructArrayLayout1f4",Zs);class Gs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,t}}Gs.prototype.bytesPerElement=6,Br("StructArrayLayout3i6",Gs);class Xs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,t}}Xs.prototype.bytesPerElement=8,Br("StructArrayLayout1ul2ui8",Xs);class Ws extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Ws.prototype.bytesPerElement=4,Br("StructArrayLayout2ui4",Ws);class Hs extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Hs.prototype.bytesPerElement=2,Br("StructArrayLayout1ui2",Hs);class Ks extends Ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=s,t}}Ks.prototype.bytesPerElement=16,Br("StructArrayLayout4f16",Ks);class Ys extends zs{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 k(this.anchorPointX,this.anchorPointY)}}Ys.prototype.size=20;class Js extends Os{get(t){return new Ys(this,t)}}Br("CollisionBoxArray",Js);class Qs extends zs{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]}}Qs.prototype.size=48;class tn extends $s{get(t){return new Qs(this,t)}}Br("PlacedSymbolArray",tn);class en extends zs{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 textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}en.prototype.size=68;class rn extends js{get(t){return new en(this,t)}}Br("SymbolInstanceArray",rn);class sn extends Zs{getoffsetX(t){return this.float32[1*t+0]}}Br("GlyphOffsetArray",sn);class nn extends Gs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Br("SymbolLineVertexArray",nn);class an extends zs{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]}}an.prototype.size=8;class on extends Xs{get(t){return new an(this,t)}}Br("FeatureIndexArray",on);class ln extends Cs{}class cn extends Ps{}class hn extends Cs{}class un extends Cs{}class pn extends ks{}class dn extends Ms{}class mn extends Ds{}class fn extends Ls{}class _n extends Bs{}class gn extends Rs{}class yn extends Fs{}class xn extends Vs{}class vn extends Us{}class bn extends Ns{}class wn extends qs{}class Tn extends qs{}class In extends Ws{}class zn extends Hs{}const Sn=As([{name:"a_pos",components:2,type:"Int16"}],4),{members:An}=Sn;class En{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let s=this.segments[this.segments.length-1];return t>En.MAX_VERTEX_ARRAY_LENGTH&&v(`Max vertices per segment is ${En.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!s||s.vertexLength+t>En.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==r)&&(s={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(s.sortKey=r),this.segments.push(s)),s}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,i,r){return new En([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function Cn(t,e){return 256*(t=l(Math.floor(t),0,255))+l(Math.floor(e),0,255)}En.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Br("SegmentVector",En);const Pn=As([{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 kn={exports:{}},Mn={exports:{}};!function(t){t.exports=function(t,e){var i,r,s,n,a,o,l,c;for(r=t.length-(i=3&t.length),s=e,a=3432918353,o=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,s=27492+(65535&(n=5*(65535&(s=(s^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}(Mn);var Dn={exports:{}};!function(t){t.exports=function(t,e){for(var i,r=t.length,s=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:s^=(255&t.charCodeAt(n+2))<<16;case 2:s^=(255&t.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}(Dn);var Ln=Mn.exports,Bn=Dn.exports;kn.exports=Ln,kn.exports.murmur3=Ln,kn.exports.murmur2=Bn;var Rn=kn.exports;class Fn{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(On(t)),this.positions.push(e,i,r)}getPositions(t){const e=On(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Vn(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Fn;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function On(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Rn(String(t))}function Vn(t,e,i,r){for(;i<r;){const s=t[i+r>>1];let n=i-1,a=r+1;for(;;){do{n++}while(t[n]<s);do{a--}while(t[a]>s);if(n>=a)break;Un(t,n,a),Un(e,3*n,3*a),Un(e,3*n+1,3*a+1),Un(e,3*n+2,3*a+2)}a-i<r-a?(Vn(t,e,i,a),i=a+1):(Vn(t,e,a+1,r),r=a)}}function Un(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Br("FeaturePositionMap",Fn);class Nn{constructor(t,e){this.gl=t.gl,this.location=e}}class qn extends Nn{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}}class $n extends Nn{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class jn extends Nn{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}}class Zn extends Nn{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}}class Gn extends Nn{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Xn extends Nn{constructor(t,e){super(t,e),this.current=jt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Wn=new Float32Array(16);class Hn extends Nn{constructor(t,e){super(t,e),this.current=Wn}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}}function Kn(t){return[Cn(255*t.r,255*t.g),Cn(255*t.b,255*t.a)]}class Yn{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Xn(t,e):new $n(t,e)}}class Jn{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,i,r){const s="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;s&&t.set(s)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new Gn(t,e):new $n(t,e)}}class Qn{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,s){const n=this.paintVertexArray.length,a=this.expression.evaluate(new os(0),e,{},r,[],s);this.paintVertexArray.resize(t),this._setPaintValue(n,t,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=Kn(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class ta{constructor(t,e,i,r,s,n){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,s){const n=this.expression.evaluate(new os(this.zoom),e,{},r,[],s),a=this.expression.evaluate(new os(this.zoom+1),e,{},r,[],s),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,n,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:this.zoom},i,r),n=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,s,n)}_setPaintValue(t,e,i,r){if("color"===this.type){const s=Kn(i),n=Kn(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,s[0],s[1],n[0],n[1])}else{for(let s=t;s<e;s++)this.paintVertexArray.emplace(s,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=l(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new $n(t,e)}}class ea{constructor(t,e,i,r,s,n){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,s){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],s)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:s,mid:n,max:a}=i,o=r[s],l=r[n],c=r[a];if(o&&l&&c)for(let i=t;i<e;i++)this.zoomInPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],o.tl[0],o.tl[1],o.br[0],o.br[1],l.pixelRatio,o.pixelRatio),this.zoomOutPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],c.tl[0],c.tl[1],c.br[0],c.br[1],l.pixelRatio,c.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Pn.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Pn.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ia{constructor(t,e,i){this.binders={},this._buffers=[];const r=[];for(const s in t.paint._values){if(!i(s))continue;const n=t.paint.get(s);if(!(n instanceof ms&&Ci(n.property.specification)))continue;const a=sa(s,t.type),o=n.value,l=n.property.specification.type,c=n.property.useIntegerZoom,h=n.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===o.kind)this.binders[s]=u?new Jn(o.value,a):new Yn(o.value,a,l),r.push(`/u_${s}`);else if("source"===o.kind||u){const i=na(s,l,"source");this.binders[s]=u?new ea(o,l,c,e,i,t.id):new Qn(o,a,l,i),r.push(`/a_${s}`)}else{const t=na(s,l,"composite");this.binders[s]=new ta(o,a,l,c,e,t),r.push(`/z_${s}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Qn||e instanceof ta?e.maxValue:0}populatePaintArrays(t,e,i,r,s){for(const n in this.binders){const a=this.binders[n];(a instanceof Qn||a instanceof ta||a instanceof ea)&&a.populatePaintArray(t,e,i,r,s)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Jn&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,s){let n=!1;for(const a in t){const o=e.getPositions(a);for(const e of o){const o=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof Qn||l instanceof ta||l instanceof ea)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,o,t[a],s),n=!0}}}}return n}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Yn||i instanceof Jn)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Qn||i instanceof ta)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof ea)for(let e=0;e<Pn.members.length;e++)t.push(Pn.members[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Yn||i instanceof Jn||i instanceof ta)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Yn||s instanceof Jn||s instanceof ta)for(const n of s.uniformNames)if(e[n]){const a=s.getBinding(t,e[n],n);i.push({name:n,property:r,binding:a})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:s,binding:n}of e)this.binders[s].setUniform(n,r,i.get(s),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof ea){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Qn||i instanceof ta)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Qn||i instanceof ta||i instanceof ea)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Qn||e instanceof ta||e instanceof ea)&&e.destroy()}}}class ra{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new ia(r,e,i);this.needsUpload=!1,this._featureMap=new Fn,this._bufferOffset=0}populatePaintArrays(t,e,i,r,s,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,s,n);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r)||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 sa(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 na(t,e,i){const r={color:{source:Ds,composite:Ks},number:{source:Zs,composite:Ds}},s=function(t){return{"line-pattern":{source:fn,composite:fn},"fill-pattern":{source:fn,composite:fn},"fill-extrusion-pattern":{source:fn,composite:fn}}[t]}(t);return s&&s[i]||r[e][i]}Br("ConstantBinder",Yn),Br("CrossFadedConstantBinder",Jn),Br("SourceExpressionBinder",Qn),Br("CrossFadedCompositeBinder",ea),Br("CompositeExpressionBinder",ta),Br("ProgramConfiguration",ia,{omit:["_buffers"]}),Br("ProgramConfigurationSet",ra);var aa=8192;const oa=Math.pow(2,14)-1,la=-oa-1;function ca(t){const e=aa/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],s=Math.round(i.x*e),n=Math.round(i.y*e);i.x=l(s,la,oa),i.y=l(n,la,oa),(s<i.x||s>i.x+1||n<i.y||n>i.y+1)&&v("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function ha(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?ca(t):[]}}function ua(t,e,i,r,s){t.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}class pa{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 hn,this.indexArray=new Tn,this.segments=new En,this.programConfigurations=new ra(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],s=[];let n=null,a=!1;"circle"===r.type&&(n=r.layout.get("circle-sort-key"),a=!n.isConstant());for(const{feature:e,id:r,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ha(e,t);if(!this.layers[0]._featureFilter.filter(new os(this.zoom),c,i))continue;const h=a?n.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:ca(e),patterns:{},sortKey:h};s.push(u)}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:s,index:n,sourceLayerIndex:a}=r,o=t[n].feature;this.addFeature(r,s,n,i),e.featureIndex.insert(o,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,An),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,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=aa||r<0||r>=aa)continue;const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),n=s.vertexLength;ua(this.layoutVertexArray,i,r,-1,-1),ua(this.layoutVertexArray,i,r,1,-1),ua(this.layoutVertexArray,i,r,1,1),ua(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(n,n+1,n+2),this.indexArray.emplaceBack(n,n+3,n+2),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function da(t,e){for(let i=0;i<t.length;i++)if(wa(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(wa(t,e[i]))return!0;return!!ga(t,e)}function ma(t,e,i){return!!wa(t,e)||!!xa(e,t,i)}function fa(t,e){if(1===t.length)return ba(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(wa(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(ba(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(ga(t,e[i]))return!0;return!1}function _a(t,e,i){if(t.length>1){if(ga(t,e))return!0;for(let r=0;r<e.length;r++)if(xa(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(xa(t[r],e,i))return!0;return!1}function ga(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)if(ya(r,s,e[t],e[t+1]))return!0}return!1}function ya(t,e,i,r){return b(t,i,r)!==b(e,i,r)&&b(t,e,i)!==b(t,e,r)}function xa(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(va(t,e[i-1],e[i])<r)return!0;return!1}function va(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function ba(t,e){let i,r,s,n=!1;for(let a=0;a<t.length;a++){i=t[a];for(let t=0,a=i.length-1;t<i.length;a=t++)r=i[t],s=i[a],r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function wa(t,e){let i=!1;for(let r=0,s=t.length-1;r<t.length;s=r++){const n=t[r],a=t[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i)}return i}function Ta(t,e,i){const r=i[0],s=i[2];if(t.x<r.x&&e.x<r.x||t.x>s.x&&e.x>s.x||t.y<r.y&&e.y<r.y||t.y>s.y&&e.y>s.y)return!1;const n=b(t,e,i[0]);return n!==b(t,e,i[1])||n!==b(t,e,i[2])||n!==b(t,e,i[3])}function Ia(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function za(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Sa(t,e,i,r,s){if(!e[0]&&!e[1])return t;const n=k.convert(e)._mult(s);"viewport"===i&&n._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(n));return a}Br("CircleBucket",pa,{omit:["layers"]});const Aa=new bs({"circle-sort-key":new gs(mt.layout_circle["circle-sort-key"])});var Ea={paint:new bs({"circle-radius":new gs(mt.paint_circle["circle-radius"]),"circle-color":new gs(mt.paint_circle["circle-color"]),"circle-blur":new gs(mt.paint_circle["circle-blur"]),"circle-opacity":new gs(mt.paint_circle["circle-opacity"]),"circle-translate":new _s(mt.paint_circle["circle-translate"]),"circle-translate-anchor":new _s(mt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new _s(mt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new _s(mt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new gs(mt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new gs(mt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new gs(mt.paint_circle["circle-stroke-opacity"])}),layout:Aa},Ca=1e-6,Pa="undefined"!=typeof Float32Array?Float32Array:Array;function ka(){var t=new Pa(16);return Pa!=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 Ma(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 Da(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],m=e[12],f=e[13],_=e[14],g=e[15],y=i*o-r*a,x=i*l-s*a,v=i*c-n*a,b=r*l-s*o,w=r*c-n*o,T=s*c-n*l,I=h*f-u*m,z=h*_-p*m,S=h*g-d*m,A=u*_-p*f,E=u*g-d*f,C=p*g-d*_,P=y*C-x*E+v*A+b*S-w*z+T*I;return P?(t[0]=(o*C-l*E+c*A)*(P=1/P),t[1]=(s*E-r*C-n*A)*P,t[2]=(f*T-_*w+g*b)*P,t[3]=(p*w-u*T-d*b)*P,t[4]=(l*S-a*C-c*z)*P,t[5]=(i*C-s*S+n*z)*P,t[6]=(_*v-m*T-g*x)*P,t[7]=(h*T-p*v+d*x)*P,t[8]=(a*E-o*S+c*I)*P,t[9]=(r*S-i*E-n*I)*P,t[10]=(m*w-f*v+g*y)*P,t[11]=(u*v-h*w-d*y)*P,t[12]=(o*z-a*A-l*I)*P,t[13]=(i*A-r*z+s*I)*P,t[14]=(f*x-m*b-_*y)*P,t[15]=(h*b-u*x+p*y)*P,t):null}function La(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],f=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*o+b*u+w*f,t[1]=x*s+v*l+b*p+w*_,t[2]=x*n+v*c+b*d+w*g,t[3]=x*a+v*h+b*m+w*y,t[4]=(x=i[4])*r+(v=i[5])*o+(b=i[6])*u+(w=i[7])*f,t[5]=x*s+v*l+b*p+w*_,t[6]=x*n+v*c+b*d+w*g,t[7]=x*a+v*h+b*m+w*y,t[8]=(x=i[8])*r+(v=i[9])*o+(b=i[10])*u+(w=i[11])*f,t[9]=x*s+v*l+b*p+w*_,t[10]=x*n+v*c+b*d+w*g,t[11]=x*a+v*h+b*m+w*y,t[12]=(x=i[12])*r+(v=i[13])*o+(b=i[14])*u+(w=i[15])*f,t[13]=x*s+v*l+b*p+w*_,t[14]=x*n+v*c+b*d+w*g,t[15]=x*a+v*h+b*m+w*y,t}function Ba(t,e,i){var r,s,n,a,o,l,c,h,u,p,d,m,f=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*f+e[4]*_+e[8]*g+e[12],t[13]=e[1]*f+e[5]*_+e[9]*g+e[13],t[14]=e[2]*f+e[6]*_+e[10]*g+e[14],t[15]=e[3]*f+e[7]*_+e[11]*g+e[15]):(s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],t[0]=r=e[0],t[1]=s,t[2]=n,t[3]=a,t[4]=o,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=m,t[12]=r*f+o*_+u*g+e[12],t[13]=s*f+l*_+p*g+e[13],t[14]=n*f+c*_+d*g+e[14],t[15]=a*f+h*_+m*g+e[15]),t}function Ra(t,e,i){var r=i[0],s=i[1],n=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Fa(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=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]=n*s+c*r,t[1]=a*s+h*r,t[2]=o*s+u*r,t[3]=l*s+p*r,t[4]=c*s-n*r,t[5]=h*s-a*r,t[6]=u*s-o*r,t[7]=p*s-l*r,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Oa=function(t,e,i,r,s,n,a){var o=1/(e-i),l=1/(r-s),c=1/(n-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*o,t[13]=(s+r)*l,t[14]=(a+n)*c,t[15]=1,t},Va=La;function Ua(t){var e=new Pa(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}var Na,qa=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t};function $a(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3];return t[0]=i[0]*r+i[4]*s+i[8]*n+i[12]*a,t[1]=i[1]*r+i[5]*s+i[9]*n+i[13]*a,t[2]=i[2]*r+i[6]*s+i[10]*n+i[14]*a,t[3]=i[3]*r+i[7]*s+i[11]*n+i[15]*a,t}Na=new Pa(3),Pa!=Float32Array&&(Na[0]=0,Na[1]=0,Na[2]=0),function(){var t=new Pa(4);Pa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var ja=function(t){var e=t[0],i=t[1];return e*e+i*i};function Za(t,e){const i=$a([],[t.x,t.y,0,1],e);return new k(i[0]/i[3],i[1]/i[3])}!function(){var t=new Pa(2);Pa!=Float32Array&&(t[0]=0,t[1]=0)}();class Ga extends pa{}Br("HeatmapBucket",Ga,{omit:["layers"]});var Xa={paint:new bs({"heatmap-radius":new gs(mt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new gs(mt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _s(mt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new vs(mt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _s(mt.paint_heatmap["heatmap-opacity"])})};function Wa(t,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*r}`)}else s=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=s,t}function Ha(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const s=Wa({},{width:e,height:i},r);Ka(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=s.data}function Ka(t,e,i,r,s,n){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;for(let l=0;l<s.height;l++){const c=((i.y+l)*t.width+i.x)*n,h=((r.y+l)*e.width+r.x)*n;for(let t=0;t<s.width*n;t++)o[h+t]=a[c+t]}return e}class Ya{constructor(t,e){Wa(this,t,1,e)}resize(t){Ha(this,t,1)}clone(){return new Ya({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){Ka(t,e,i,r,s,1)}}class Ja{constructor(t,e){Wa(this,t,4,e)}resize(t){Ha(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ja({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){Ka(t,e,i,r,s,4)}}function Qa(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,s=t.image||new Ja({width:i,height:r}),n=(i,r,n)=>{e[t.evaluationKey]=n;const a=t.expression.evaluate(e);s.data[i+r+0]=Math.floor(255*a.r/a.a),s.data[i+r+1]=Math.floor(255*a.g/a.a),s.data[i+r+2]=Math.floor(255*a.b/a.a),s.data[i+r+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,s=0;e<r;++e,s+=4*i)for(let r=0,a=0;r<i;r++,a+=4){const o=r/(i-1),{start:l,end:c}=t.clips[e];n(s,a,l*(1-o)+c*o)}else for(let t=0,e=0;t<i;t++,e+=4)n(0,e,t/(i-1));return s}Br("AlphaImage",Ya),Br("RGBAImage",Ja);var to={paint:new bs({"hillshade-illumination-direction":new _s(mt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new _s(mt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new _s(mt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new _s(mt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new _s(mt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new _s(mt.paint_hillshade["hillshade-accent-color"])})};const eo=As([{name:"a_pos",components:2,type:"Int16"}],4),{members:io}=eo;var ro={exports:{}};function so(t,e,i){i=i||2;var r,s,n,a,o,l,c,h=e&&e.length,u=h?e[0]*i:t.length,p=no(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,i,r){var s,n,a,o=[];for(s=0,n=e.length;s<n;s++)(a=no(t,e[s]*r,s<n-1?e[s+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),o.push(go(a));for(o.sort(po),s=0;s<o.length;s++)i=ao(i=mo(o[s],i),i.next);return i}(t,e,p,i)),t.length>80*i){r=n=t[0],s=a=t[1];for(var m=i;m<u;m+=i)(o=t[m])<r&&(r=o),(l=t[m+1])<s&&(s=l),o>n&&(n=o),l>a&&(a=l);c=0!==(c=Math.max(n-r,a-s))?1/c:0}return oo(p,d,i,r,s,c),d}function no(t,e,i,r,s){var n,a;if(s===Po(t,e,i,r)>0)for(n=e;n<i;n+=r)a=Ao(n,t[n],t[n+1],a);else for(n=i-r;n>=e;n-=r)a=Ao(n,t[n],t[n+1],a);return a&&bo(a,a.next)&&(Eo(a),a=a.next),a}function ao(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!bo(r,r.next)&&0!==vo(r.prev,r,r.next))r=r.next;else{if(Eo(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function oo(t,e,i,r,s,n,a){if(t){!a&&n&&function(t,e,i,r){var s=t;do{null===s.z&&(s.z=_o(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,a,o,l,c=1;do{for(i=t,t=null,n=null,a=0;i;){for(a++,r=i,o=0,e=0;e<c&&(o++,r=r.nextZ);e++);for(l=c;o>0||l>0&&r;)0!==o&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,c*=2}while(a>1)}(s)}(t,r,s,n);for(var o,l,c=t;t.prev!==t.next;)if(o=t.prev,l=t.next,n?co(t,r,s,n):lo(t))e.push(o.i/i),e.push(t.i/i),e.push(l.i/i),Eo(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?oo(t=ho(ao(t),e,i),e,i,r,s,n,2):2===a&&uo(t,e,i,r,s,n):oo(ao(t),e,i,r,s,n,1);break}}}function lo(t){var e=t.prev,i=t,r=t.next;if(vo(e,i,r)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(yo(e.x,e.y,i.x,i.y,r.x,r.y,s.x,s.y)&&vo(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function co(t,e,i,r){var s=t.prev,n=t,a=t.next;if(vo(s,n,a)>=0)return!1;for(var o=s.x>n.x?s.x>a.x?s.x:a.x:n.x>a.x?n.x:a.x,l=s.y>n.y?s.y>a.y?s.y:a.y:n.y>a.y?n.y:a.y,c=_o(s.x<n.x?s.x<a.x?s.x:a.x:n.x<a.x?n.x:a.x,s.y<n.y?s.y<a.y?s.y:a.y:n.y<a.y?n.y:a.y,e,i,r),h=_o(o,l,e,i,r),u=t.prevZ,p=t.nextZ;u&&u.z>=c&&p&&p.z<=h;){if(u!==t.prev&&u!==t.next&&yo(s.x,s.y,n.x,n.y,a.x,a.y,u.x,u.y)&&vo(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,p!==t.prev&&p!==t.next&&yo(s.x,s.y,n.x,n.y,a.x,a.y,p.x,p.y)&&vo(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;u&&u.z>=c;){if(u!==t.prev&&u!==t.next&&yo(s.x,s.y,n.x,n.y,a.x,a.y,u.x,u.y)&&vo(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;p&&p.z<=h;){if(p!==t.prev&&p!==t.next&&yo(s.x,s.y,n.x,n.y,a.x,a.y,p.x,p.y)&&vo(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function ho(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!bo(s,n)&&wo(s,r,r.next,n)&&zo(s,n)&&zo(n,s)&&(e.push(s.i/i),e.push(r.i/i),e.push(n.i/i),Eo(r),Eo(r.next),r=t=n),r=r.next}while(r!==t);return ao(r)}function uo(t,e,i,r,s,n){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&xo(a,o)){var l=So(a,o);return a=ao(a,a.next),l=ao(l,l.next),oo(a,e,i,r,s,n),void oo(l,e,i,r,s,n)}o=o.next}a=a.next}while(a!==t)}function po(t,e){return t.x-e.x}function mo(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,a=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var o=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=s&&o>a){if(a=o,o===s){if(n===r.y)return r;if(n===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(s===a)return i;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{s>=r.x&&r.x>=h&&s!==r.x&&yo(n<u?s:a,n,h,u,n<u?a:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),zo(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&fo(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=So(i,t),s=ao(i,i.next);return ao(r,r.next),e===i?s:e}function fo(t,e){return vo(t.prev,t,e.prev)<0&&vo(e.next,t,t.next)<0}function _o(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function go(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function yo(t,e,i,r,s,n,a,o){return(s-a)*(e-o)-(t-a)*(n-o)>=0&&(t-a)*(r-o)-(i-a)*(e-o)>=0&&(i-a)*(n-o)-(s-a)*(r-o)>=0}function xo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&wo(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(zo(t,e)&&zo(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(vo(t.prev,t,e.prev)||vo(t,e.prev,e))||bo(t,e)&&vo(t.prev,t,t.next)>0&&vo(e.prev,e,e.next)>0)}function vo(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function bo(t,e){return t.x===e.x&&t.y===e.y}function wo(t,e,i,r){var s=Io(vo(t,e,i)),n=Io(vo(t,e,r)),a=Io(vo(i,r,t)),o=Io(vo(i,r,e));return s!==n&&a!==o||!(0!==s||!To(t,i,e))||!(0!==n||!To(t,r,e))||!(0!==a||!To(i,t,r))||!(0!==o||!To(i,e,r))}function To(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Io(t){return t>0?1:t<0?-1:0}function zo(t,e){return vo(t.prev,t,t.next)<0?vo(t,e,t.next)>=0&&vo(t,t.prev,e)>=0:vo(t,e,t.prev)<0||vo(t,t.next,e)<0}function So(t,e){var i=new Co(t.i,t.x,t.y),r=new Co(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Ao(t,e,i,r){var s=new Co(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Eo(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 Co(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Po(t,e,i,r){for(var s=0,n=e,a=i-r;n<i;n+=r)s+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return s}ro.exports=so,ro.exports.default=so,so.deviation=function(t,e,i,r){var s=e&&e.length,n=Math.abs(Po(t,0,s?e[0]*i:t.length,i));if(s)for(var a=0,o=e.length;a<o;a++)n-=Math.abs(Po(t,e[a]*i,a<o-1?e[a+1]*i:t.length,i));var l=0;for(a=0;a<r.length;a+=3){var c=r[a]*i,h=r[a+1]*i,u=r[a+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===n&&0===l?0:Math.abs((l-n)/n)},so.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var a=0;a<e;a++)i.vertices.push(t[s][n][a]);s>0&&i.holes.push(r+=t[s-1].length)}return i};var ko=ro.exports;function Mo(t,e,i,r,s){Do(t,e,i||0,r||t.length-1,s||Bo)}function Do(t,e,i,r,s){for(;r>i;){if(r-i>600){var n=r-i+1,a=e-i+1,o=Math.log(n),l=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*l*(n-l)/n)*(a-n/2<0?-1:1);Do(t,e,Math.max(i,Math.floor(e-a*l/n+c)),Math.min(r,Math.floor(e+(n-a)*l/n+c)),s)}var h=t[e],u=i,p=r;for(Lo(t,i,e),s(t[r],h)>0&&Lo(t,i,r);u<p;){for(Lo(t,u,p),u++,p--;s(t[u],h)<0;)u++;for(;s(t[p],h)>0;)p--}0===s(t[i],h)?Lo(t,i,p):Lo(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function Lo(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Bo(t,e){return t<e?-1:t>e?1:0}function Ro(t,e){const i=t.length;if(i<=1)return[t];const r=[];let s,n;for(let e=0;e<i;e++){const i=w(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===n&&(n=i<0),n===i<0?(s&&r.push(s),s=[t[e]]):s.push(t[e]))}if(s&&r.push(s),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Mo(r[t],e,1,r[t].length-1,Fo),r[t]=r[t].slice(0,e));return r}function Fo(t,e){return e.area-t.area}function Oo(t,e,i){const r=i.patternDependencies;let s=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(s=!0);const n=e.constantOr(null);n&&(s=!0,r[n.to]=!0,r[n.from]=!0)}return s}function Vo(t,e,i,r,s){const n=s.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},s.availableImages),o=e.evaluate({zoom:r},i,{},s.availableImages),l=e.evaluate({zoom:r+1},i,{},s.availableImages);t=t&&t.name?t.name:t,o=o&&o.name?o.name:o,l=l&&l.name?l.name:l,n[t]=!0,n[o]=!0,n[l]=!0,i.patterns[a.id]={min:t,mid:o,max:l}}}return i}class Uo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new un,this.indexArray=new Tn,this.indexArray2=new In,this.programConfigurations=new ra(t.layers,t.zoom),this.segments=new En,this.segments2=new En,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Oo("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=ha(a,t);if(!this.layers[0]._featureFilter.filter(new os(this.zoom),h,i))continue;const u=s?r.evaluate(h,{},i,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:ca(a),patterns:{},sortKey:u};n.push(p)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=Vo("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,io),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,i,r,s){for(const t of Ro(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,s=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(s.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),s.push(e[0].x),s.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),s.push(e[t].x),s.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const a=ko(s,n);for(let t=0;t<a.length;t+=3)this.indexArray.emplaceBack(r+a[t],r+a[t+1],r+a[t+2]);i.vertexLength+=e,i.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}}Br("FillBucket",Uo,{omit:["layers","patternFeatures"]});const No=new bs({"fill-sort-key":new gs(mt.layout_fill["fill-sort-key"])});var qo={paint:new bs({"fill-antialias":new _s(mt.paint_fill["fill-antialias"]),"fill-opacity":new gs(mt.paint_fill["fill-opacity"]),"fill-color":new gs(mt.paint_fill["fill-color"]),"fill-outline-color":new gs(mt.paint_fill["fill-outline-color"]),"fill-translate":new _s(mt.paint_fill["fill-translate"]),"fill-translate-anchor":new _s(mt.paint_fill["fill-translate-anchor"]),"fill-pattern":new ys(mt.paint_fill["fill-pattern"])}),layout:No};const $o=As([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),jo=As([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Zo}=$o;var Go={},Xo=k,Wo=Ho;function Ho(t,e,i,r,s){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=s,t.readFields(Ko,this,e)}function Ko(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],s=e._values[t.readVarint()];e.properties[r]=s}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Yo(t){for(var e,i,r=0,s=0,n=t.length,a=n-1;s<n;a=s++)r+=((i=t[a]).x-(e=t[s]).x)*(e.y+i.y);return r}Ho.types=["Unknown","Point","LineString","Polygon"],Ho.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,s=0,n=0,a=0,o=[];t.pos<i;){if(s<=0){var l=t.readVarint();r=7&l,s=l>>3}if(s--,1===r||2===r)n+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&o.push(e),e=[]),e.push(new Xo(n,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&o.push(e),o},Ho.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,s=0,n=0,a=1/0,o=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(s+=t.readSVarint())<a&&(a=s),s>o&&(o=s),(n+=t.readSVarint())<l&&(l=n),n>c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,o,c]},Ho.prototype.toGeoJSON=function(t,e,i){var r,s,n=this.extent*Math.pow(2,i),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),c=Ho.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+a)/n-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+o)/n)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,s=[],n=0;n<e;n++){var a=Yo(t[n]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&s.push(i),i=[t[n]]):i.push(t[n]))}return i&&s.push(i),s}(l),r=0;r<l.length;r++)for(s=0;s<l[r].length;s++)h(l[r][s])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var Jo=Wo,Qo=tl;function tl(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(el,this,e),this.length=this._features.length}function el(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}tl.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 Jo(this._pbf,e,this.extent,this._keys,this._values)};var il=Qo;function rl(t,e,i){if(3===t){var r=new il(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}Go.VectorTile=function(t,e){this.layers=t.readFields(rl,{},e)},Go.VectorTileFeature=Wo,Go.VectorTileLayer=Qo;const sl=Go.VectorTileFeature.types,nl=Math.pow(2,13);function al(t,e,i,r,s,n,a,o){t.emplaceBack(e,i,2*Math.floor(r*nl)+a,s*nl*2,n*nl*2,Math.round(o))}class ol{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 pn,this.centroidVertexArray=new ln,this.indexArray=new Tn,this.programConfigurations=new ra(t.layers,t.zoom),this.segments=new En,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=Oo("fill-extrusion",this.layers,e);for(const{feature:r,id:s,index:n,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ha(r,t);if(!this.layers[0]._featureFilter.filter(new os(this.zoom),o,i))continue;const l={id:s,sourceLayerIndex:a,index:n,geometry:t?o.geometry:ca(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(Vo("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,n,i,{}),e.featureIndex.insert(r,l.geometry,n,a,this.index,!0)}}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}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,Zo),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,jo.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,i,r,s){const n={x:0,y:0,vertexCount:0};for(const i of Ro(e,500)){let e=0;for(const t of i)e+=t.length;let r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of i){if(0===t.length)continue;if(cl(t))continue;let e=0;for(let i=0;i<t.length;i++){const s=t[i];if(i>=1){const a=t[i-1];if(!ll(s,a)){r.vertexLength+4>En.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(a)._perp()._unit(),i=a.dist(s);e+i>32768&&(e=0),al(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),al(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),n.x+=2*s.x,n.y+=2*s.y,n.vertexCount+=2,e+=i,al(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),al(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),n.x+=2*a.x,n.y+=2*a.y,n.vertexCount+=2;const o=r.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>En.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==sl[t.type])continue;const s=[],a=[],o=r.vertexLength;for(const t of i)if(0!==t.length){t!==i[0]&&a.push(s.length/2);for(let e=0;e<t.length;e++){const i=t[e];al(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),n.x+=i.x,n.y+=i.y,n.vertexCount+=1,s.push(i.x),s.push(i.y)}}const l=ko(s,a);for(let t=0;t<l.length;t+=3)this.indexArray.emplaceBack(o+l[t],o+l[t+2],o+l[t+1]);r.primitiveLength+=l.length/3,r.vertexLength+=e}for(let t=0;t<n.vertexCount;t++)this.centroidVertexArray.emplaceBack(Math.floor(n.x/n.vertexCount),Math.floor(n.y/n.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}}function ll(t,e){return t.x===e.x&&(t.x<0||t.x>aa)||t.y===e.y&&(t.y<0||t.y>aa)}function cl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>aa))||t.every((t=>t.y<0))||t.every((t=>t.y>aa))}Br("FillExtrusionBucket",ol,{omit:["layers","features"]});var hl={paint:new bs({"fill-extrusion-opacity":new _s(mt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new gs(mt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _s(mt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _s(mt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ys(mt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new gs(mt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new gs(mt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _s(mt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function ul(t,e){return t.x*e.x+t.y*e.y}function pl(t,e){if(1===t.length){let i=0;const r=e[i++];let s;for(;!s||r.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){const n=e[i],a=t[0],o=s.sub(r),l=n.sub(r),c=a.sub(r),h=ul(o,o),u=ul(o,l),p=ul(l,l),d=ul(c,o),m=ul(c,l),f=h*p-u*u,_=(p*d-u*m)/f,g=(h*m-u*d)/f,y=r.z*(1-_-g)+s.z*_+n.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const dl=As([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:ml}=dl,fl=As([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:_l}=fl,gl=Go.VectorTileFeature.types,yl=Math.cos(Math.PI/180*37.5),xl=Math.pow(2,14)/.5;class vl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new dn,this.layoutVertexArray2=new mn,this.indexArray=new Tn,this.programConfigurations=new ra(t.layers,t.zoom),this.segments=new En,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Oo("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ha(e,t);if(!this.layers[0]._featureFilter.filter(new os(this.zoom),c,i))continue;const h=s?r.evaluate(c,{},i):void 0,u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:ca(e),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=Vo("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}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,_l)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ml),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,i,r,s){const n=this.layers[0].layout,a=n.get("line-join").evaluate(t,{}),o=n.get("line-cap"),l=n.get("line-miter-limit"),c=n.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,o,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}addLine(t,e,i,r,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a="Polygon"===gl[e.type];let o=t.length;for(;o>=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l<o-1&&t[l].equals(t[l+1]);)l++;if(o<(a?3:2))return;"bevel"===i&&(s=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*o,this.layoutVertexArray,this.indexArray);let u,p,d,m,f;this.e1=this.e2=-1,a&&(u=t[o-2],f=t[l].sub(u)._unit()._perp());for(let e=l;e<o;e++){if(d=e===o-1?a?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;f&&(m=f),u&&(p=u),u=t[e],f=d?d.sub(u)._unit()._perp():m,m=m||f;let _=m.add(f);0===_.x&&0===_.y||_._unit();const g=m.x*f.x+m.y*f.y,y=_.x*f.x+_.y*f.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<yl&&p&&d,w=m.x*f.y-m.y*f.x>0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}const T=p&&d;let I=T?i:a?"butt":r;if(T&&"round"===I&&(x<n?I="miter":x<=2&&(I="fakeround")),"miter"===I&&x>s&&(I="bevel"),"bevel"===I&&(x>2&&(I="flipbevel"),x<s&&(I="miter")),p&&this.updateDistance(p,u),"miter"===I)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===I){if(x>100)_=f.mult(-1);else{const t=x*m.add(f).mag()/m.sub(f).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===I||"fakeround"===I){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,m,e,i,h),"fakeround"===I){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=f.sub(m)._mult(i)._add(m)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}d&&this.addCurrentVertex(u,f,-e,-i,h)}else if("butt"===I)this.addCurrentVertex(u,_,0,0,h);else if("square"===I){const t=p?1:-1;this.addCurrentVertex(u,_,t,t,h)}else"round"===I&&(p&&(this.addCurrentVertex(u,m,0,0,h),this.addCurrentVertex(u,m,1,1,h,!0)),d&&(this.addCurrentVertex(u,f,-1,-1,h,!0),this.addCurrentVertex(u,f,0,0,h)));if(b&&e<o-1){const t=u.dist(d);if(t>2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,s,n=!1){const a=e.y*r-e.x,o=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,s),this.addHalfVertex(t,a,o,n,!0,-r,s),this.distance>xl/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,i,r,s,n))}addHalfVertex({x:t,y:e},i,r,s,n,a,o){const l=.5*(this.lineClips?this.scaledDistance*(xl-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?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()}}Br("LineBucket",vl,{omit:["layers","patternFeatures"]});const bl=new bs({"line-cap":new _s(mt.layout_line["line-cap"]),"line-join":new gs(mt.layout_line["line-join"]),"line-miter-limit":new _s(mt.layout_line["line-miter-limit"]),"line-round-limit":new _s(mt.layout_line["line-round-limit"]),"line-sort-key":new gs(mt.layout_line["line-sort-key"])});var wl={paint:new bs({"line-opacity":new gs(mt.paint_line["line-opacity"]),"line-color":new gs(mt.paint_line["line-color"]),"line-translate":new _s(mt.paint_line["line-translate"]),"line-translate-anchor":new _s(mt.paint_line["line-translate-anchor"]),"line-width":new gs(mt.paint_line["line-width"]),"line-gap-width":new gs(mt.paint_line["line-gap-width"]),"line-offset":new gs(mt.paint_line["line-offset"]),"line-blur":new gs(mt.paint_line["line-blur"]),"line-dasharray":new xs(mt.paint_line["line-dasharray"]),"line-pattern":new ys(mt.paint_line["line-pattern"]),"line-gradient":new vs(mt.paint_line["line-gradient"])}),layout:bl};const Tl=new class extends gs{possiblyEvaluate(t,e){return e=new os(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=u({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(wl.paint.properties["line-width"].specification);function Il(t,e){return e>0?e+2*t:t}Tl.useIntegerZoom=!0;const zl=As([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Sl=As([{name:"a_projected_pos",components:3,type:"Float32"}],4);As([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Al=As([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);As([{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 El=As([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Cl=As([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Pl(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),t}(t.text,e,i)})),t}As([{name:"triangle",components:3,type:"Uint16"}]),As([{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"}]),As([{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),As([{type:"Float32",name:"offsetX"}]),As([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const kl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Ml=Bl,Dl=function(t,e,i,r,s){var n,a,o=8*s-r-1,l=(1<<o)-1,c=l>>1,h=-7,u=i?s-1:0,p=i?-1:1,d=t[e+u];for(u+=p,n=d&(1<<-h)-1,d>>=-h,h+=o;h>0;n=256*n+t[e+u],u+=p,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=r;h>0;a=256*a+t[e+u],u+=p,h-=8);if(0===n)n=1-c;else{if(n===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),n-=c}return(d?-1:1)*a*Math.pow(2,n-r)},Ll=function(t,e,i,r,s,n){var a,o,l,c=8*n-s-1,h=(1<<c)-1,u=h>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:n-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(a++,l/=2),a+u>=h?(o=0,a=h):a+u>=1?(o=(e*l-1)*Math.pow(2,s),a+=u):(o=e*Math.pow(2,u-1)*Math.pow(2,s),a=0));s>=8;t[i+d]=255&o,d+=m,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;t[i+d]=255&a,d+=m,a/=256,c-=8);t[i+d-m]|=128*f};function Bl(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Bl.Varint=0,Bl.Fixed64=1,Bl.Bytes=2,Bl.Fixed32=5;var Rl,Fl=4294967296,Ol=1/Fl,Vl="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Ul(t){return t.type===Bl.Bytes?t.readVarint()+t.pos:t.pos+1}function Nl(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function ql(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var s=i.pos-1;s>=t;s--)i.buf[s+r]=i.buf[s]}function $l(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function jl(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function Zl(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function Gl(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function Xl(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function Wl(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function Hl(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Kl(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function Yl(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Jl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Ql(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function tc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function ec(t,e,i){1===t&&i.readMessage(ic,e)}function ic(t,e,i){if(3===t){const{id:t,bitmap:r,width:s,height:n,left:a,top:o,advance:l}=i.readMessage(rc,{});e.push({id:t,bitmap:new Ya({width:s+6,height:n+6},r),metrics:{width:s,height:n,left:a,top:o,advance:l}})}}function rc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function sc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:s,h:n,fill:e/(s*n)||0}}Bl.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),s=r>>3,n=this.pos;this.type=7&r,t(s,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Jl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=tc(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Jl(this.buf,this.pos)+Jl(this.buf,this.pos+4)*Fl;return this.pos+=8,t},readSFixed64:function(){var t=Jl(this.buf,this.pos)+tc(this.buf,this.pos+4)*Fl;return this.pos+=8,t},readFloat:function(){var t=Dl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Dl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,s,n=i.buf;if(r=(112&(s=n[i.pos++]))>>4,s<128)return Nl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<3,s<128)return Nl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<10,s<128)return Nl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<17,s<128)return Nl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<24,s<128)return Nl(t,r,e);if(r|=(1&(s=n[i.pos++]))<<31,s<128)return Nl(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Vl?function(t,e,i){return Vl.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",s=e;s<i;){var n,a,o,l=t[s],c=null,h=l>239?4:l>223?3:l>191?2:1;if(s+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(n=t[s+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===h?(a=t[s+2],128==(192&(n=t[s+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&n)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(a=t[s+2],o=t[s+3],128==(192&(n=t[s+1]))&&128==(192&a)&&128==(192&o)&&((c=(15&l)<<18|(63&n)<<12|(63&a)<<6|63&o)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),s+=h}return r}(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!==Bl.Bytes)return t.push(this.readVarint(e));var i=Ul(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Bl.Bytes)return t.push(this.readSVarint());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Bl.Bytes)return t.push(this.readBoolean());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Bl.Bytes)return t.push(this.readFloat());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Bl.Bytes)return t.push(this.readDouble());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Bl.Bytes)return t.push(this.readFixed32());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Bl.Bytes)return t.push(this.readSFixed32());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Bl.Bytes)return t.push(this.readFixed64());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Bl.Bytes)return t.push(this.readSFixed64());var e=Ul(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Bl.Varint)for(;this.buf[this.pos++]>127;);else if(e===Bl.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Bl.Fixed32)this.pos+=4;else{if(e!==Bl.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;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Ql(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Ql(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Ql(this.buf,-1&t,this.pos),Ql(this.buf,Math.floor(t*Ol),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Ql(this.buf,-1&t,this.pos),Ql(this.buf,Math.floor(t*Ol),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((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)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,s,n=0;n<e.length;n++){if((r=e.charCodeAt(n))>55295&&r<57344){if(!s){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):s=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,s=r;continue}r=s-55296<<10|r-56320|65536,s=null}else s&&(t[i++]=239,t[i++]=191,t[i++]=189,s=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&ql(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Ll(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Ll(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 i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&ql(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,Bl.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,$l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,jl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Xl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Zl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Gl,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Wl,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Hl,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Kl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Yl,e)},writeBytesField:function(t,e){this.writeTag(t,Bl.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Bl.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Bl.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Bl.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Bl.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Bl.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Bl.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Bl.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Bl.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Bl.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class nc{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:s,content:n}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=s,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}function ac(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function oc(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new os(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let s=0;for(;s<e.length&&e[s]<=t;)s++;s=Math.max(0,s-1);let n=s;for(;n<e.length&&e[n]<t+1;)n++;n=Math.min(e.length-1,n);const a=e[s],o=e[n];return"composite"===i.kind?{kind:"composite",minZoom:a,maxZoom:o,interpolationType:r}:{kind:"camera",minZoom:a,maxZoom:o,minSize:i.evaluate(new os(a)),maxSize:i.evaluate(new os(o)),interpolationType:r}}}function lc(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return"source"===t.kind?r/128:"composite"===t.kind?Re(r/128,s/128,i):e}function cc(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:s,minZoom:n,maxZoom:a}=t,o=s?l(ei.interpolationFactor(s,e,n,a),0,1):0;"camera"===t.kind?r=Re(t.minSize,t.maxSize,o):i=o}return{uSizeT:i,uSize:r}}Br("ImagePosition",nc),Br("ImageAtlas",class{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const s=[];this.addImages(t,i,s),this.addImages(e,r,s);const{w:n,h:a}=sc(s),o=new Ja({width:n||1,height:a||1});for(const e in t){const r=t[e],s=i[e].paddedRect;Ja.copy(r.data,o,{x:0,y:0},{x:s.x+1,y:s.y+1},r.data)}for(const t in e){const i=e[t],s=r[t].paddedRect,n=s.x+1,a=s.y+1,l=i.data.width,c=i.data.height;Ja.copy(i.data,o,{x:0,y:0},{x:n,y:a},i.data),Ja.copy(i.data,o,{x:0,y:c-1},{x:n,y:a-1},{width:l,height:1}),Ja.copy(i.data,o,{x:0,y:0},{x:n,y:a+c},{width:l,height:1}),Ja.copy(i.data,o,{x:l-1,y:0},{x:n-1,y:a},{width:1,height:c}),Ja.copy(i.data,o,{x:0,y:0},{x:n+l,y:a},{width:1,height:c})}this.image=o,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const s=t[r],n={x:0,y:0,w:s.data.width+2,h:s.data.height+2};i.push(n),e[r]=new nc(n,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,s]=t.tl;i.update(e.data,void 0,{x:r,y:s})}}),function(t){t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly"}(Rl||(Rl={}));class hc extends k{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new hc(this.x,this.y,this.angle,this.segment)}}Br("Anchor",hc);const uc=Number.POSITIVE_INFINITY;function pc(t,e){return e[1]!==uc?function(t,e,i){let r=0,s=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,s]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const s=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=s-7;break;case"bottom-right":case"bottom-left":r=7-s;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}const dc=Go.VectorTileFeature.types,mc=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function fc(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=o?Math.min(32640,Math.round(o[0])):0,m=o?Math.min(32640,Math.round(o[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*s),n,a,(d<<1)+(l?1:0),m,16*c,16*h,256*u,256*p)}function _c(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function gc(t){for(const e of t.sections)if(Wr(e.text))return!0;return!1}class yc{constructor(t){this.layoutVertexArray=new _n,this.indexArray=new Tn,this.programConfigurations=t,this.segments=new En,this.dynamicLayoutVertexArray=new gn,this.opacityVertexArray=new yn,this.placedSymbolArray=new tn}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,zl.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Sl.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,mc,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Br("SymbolBuffers",yc);class xc{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new En,this.collisionVertexArray=new bn}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Al.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Br("CollisionBuffers",xc);class vc{constructor(t){this.collisionBoxArray=t.collisionBoxArray,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.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ma([]),this.placementViewportMatrix=Ma([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=oc(this.zoom,e["text-size"]),this.iconSizeData=oc(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap="never"!==zc(i,"text-overlap","text-allow-overlap")||"never"!==zc(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>Rl[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new yc(new ra(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new yc(new ra(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new sn,this.lineVertexArray=new nn,this.symbolInstances=new rn}calculateGlyphDependencies(t,e,i,r,s){for(let n=0;n<t.length;n++)if(e[t.charCodeAt(n)]=!0,(i||r)&&s){const i=kl[t.charAt(n)];i&&(e[i.charCodeAt(0)]=!0)}}populate(t,e,i){const r=this.layers[0],s=r.layout,n=s.get("text-font"),a=s.get("text-field"),o=s.get("icon-image"),l=("constant"!==a.value.kind||a.value.value instanceof Xt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),c="constant"!==o.value.kind||!!o.value.value||Object.keys(o.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!l&&!c)return;const u=e.iconDependencies,p=e.glyphDependencies,d=e.availableImages,m=new os(this.zoom);for(const{feature:e,id:a,index:o,sourceLayerIndex:f}of t){const t=r._featureFilter.needGeometry,_=ha(e,t);if(!r._featureFilter.filter(m,_,i))continue;let g,y;if(t||(_.geometry=ca(e)),l){const t=r.getValueAndResolveTokens("text-field",_,i,d),e=Xt.factory(t);gc(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ss()||this.hasRTLText&&as.isParsed())&&(g=Pl(e,r,_))}if(c){const t=r.getValueAndResolveTokens("icon-image",_,i,d);y=t instanceof Wt?t:Wt.fromString(t)}if(!g&&!y)continue;const x=this.sortFeaturesByKey?h.evaluate(_,{},i):void 0;if(this.features.push({id:a,text:g,icon:y,index:o,sourceLayerIndex:f,geometry:_.geometry,properties:e.properties,type:dc[e.type],sortKey:x}),y&&(u[y.name]=!0),g){const t=n.evaluate(_,{},i).join(","),e="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Rl.vertical)>=0;for(const i of g.sections)if(i.image)u[i.image.name]=!0;else{const r=jr(g.toString()),s=i.fontStack||t,n=p[s]=p[s]||{};this.calculateGlyphDependencies(i.text,n,e,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let s=0;function n(e){r.push(t[e]),s++}function a(t,e,s){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(s[0]),n}function o(t,i,s){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=s[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){n(c);continue}const d=l(p,u),m=l(p,u,!0);if(d in i&&m in e&&i[d]!==e[m]){const t=o(d,m,u),s=a(d,m,r[t].geometry);delete e[d],delete i[m],i[l(p,r[s].geometry,!0)]=s,r[t].geometry=null}else d in i?a(d,m,u):m in e?o(d,m,u):(n(c),e[d]=s-1,i[m]=s-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const s={};for(let r=t.segment+1;r<e.length;r++)s[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,s,n,a,o,l,c,h,u){const p=t.indexArray,d=t.layoutVertexArray,m=t.segments.prepareSegment(4*e.length,d,p,this.canOverlap?n.sortKey:void 0),f=this.glyphOffsetArray.length,_=m.vertexLength,g=this.allowVerticalPlacement&&a===Rl.vertical?Math.PI/2:0,y=n.text&&n.text.sections;for(let r=0;r<e.length;r++){const{tl:s,tr:a,bl:l,br:c,tex:h,pixelOffsetTL:f,pixelOffsetBR:_,minFontScaleX:x,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=e[r],I=m.vertexLength,z=b[1];fc(d,o.x,o.y,s.x,z+s.y,h.x,h.y,i,w,f.x,f.y,x,v),fc(d,o.x,o.y,a.x,z+a.y,h.x+h.w,h.y,i,w,_.x,f.y,x,v),fc(d,o.x,o.y,l.x,z+l.y,h.x,h.y+h.h,i,w,f.x,_.y,x,v),fc(d,o.x,o.y,c.x,z+c.y,h.x+h.w,h.y+h.h,i,w,_.x,_.y,x,v),_c(t.dynamicLayoutVertexArray,o,g),p.emplaceBack(I,I+1,I+2),p.emplaceBack(I+1,I+2,I+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),r!==e.length-1&&T===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(d.length,n,n.index,{},u,y&&y[T])}t.placedSymbolArray.emplaceBack(o.x,o.y,f,this.glyphOffsetArray.length-f,_,l,c,o.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],a,0,!1,0,h)}_addCollisionDebugVertex(t,e,i,r,s,n){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,s,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(t,e,i,r,s,n,a){const o=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),l=o.vertexLength,c=s.layoutVertexArray,h=s.collisionVertexArray,u=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(c,h,n,u,p,new k(t,e)),this._addCollisionDebugVertex(c,h,n,u,p,new k(i,e)),this._addCollisionDebugVertex(c,h,n,u,p,new k(i,r)),this._addCollisionDebugVertex(c,h,n,u,p,new k(t,r)),o.vertexLength+=4;const d=s.indexArray;d.emplaceBack(l,l+1),d.emplaceBack(l+1,l+2),d.emplaceBack(l+2,l+3),d.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let s=t;s<e;s++){const t=this.collisionBoxArray.get(s);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new xc(xn,El.members,In),this.iconCollisionBox=new xc(xn,El.members,In);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,s,n,a,o,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<s;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=n;e<a;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=o;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],s=[],n=[];for(let t=0;t<this.symbolInstances.length;++t){n.push(t);const a=this.symbolInstances.get(t);r.push(0|Math.round(e*a.anchorX+i*a.anchorY)),s.push(a.featureIndex)}return n.sort(((t,e)=>r[t]-r[e]||s[e]-s[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Br("SymbolBucket",vc,{omit:["layers","collisionBoxArray","features","compareText"]}),vc.MAX_GLYPHS=65535,vc.addDynamicAttributes=_c;const bc=new bs({"symbol-placement":new _s(mt.layout_symbol["symbol-placement"]),"symbol-spacing":new _s(mt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _s(mt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new gs(mt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _s(mt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _s(mt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new _s(mt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new _s(mt.layout_symbol["icon-ignore-placement"]),"icon-optional":new _s(mt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _s(mt.layout_symbol["icon-rotation-alignment"]),"icon-size":new gs(mt.layout_symbol["icon-size"]),"icon-text-fit":new _s(mt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _s(mt.layout_symbol["icon-text-fit-padding"]),"icon-image":new gs(mt.layout_symbol["icon-image"]),"icon-rotate":new gs(mt.layout_symbol["icon-rotate"]),"icon-padding":new _s(mt.layout_symbol["icon-padding"]),"icon-keep-upright":new _s(mt.layout_symbol["icon-keep-upright"]),"icon-offset":new gs(mt.layout_symbol["icon-offset"]),"icon-anchor":new gs(mt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _s(mt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _s(mt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _s(mt.layout_symbol["text-rotation-alignment"]),"text-field":new gs(mt.layout_symbol["text-field"]),"text-font":new gs(mt.layout_symbol["text-font"]),"text-size":new gs(mt.layout_symbol["text-size"]),"text-max-width":new gs(mt.layout_symbol["text-max-width"]),"text-line-height":new _s(mt.layout_symbol["text-line-height"]),"text-letter-spacing":new gs(mt.layout_symbol["text-letter-spacing"]),"text-justify":new gs(mt.layout_symbol["text-justify"]),"text-radial-offset":new gs(mt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _s(mt.layout_symbol["text-variable-anchor"]),"text-anchor":new gs(mt.layout_symbol["text-anchor"]),"text-max-angle":new _s(mt.layout_symbol["text-max-angle"]),"text-writing-mode":new _s(mt.layout_symbol["text-writing-mode"]),"text-rotate":new gs(mt.layout_symbol["text-rotate"]),"text-padding":new _s(mt.layout_symbol["text-padding"]),"text-keep-upright":new _s(mt.layout_symbol["text-keep-upright"]),"text-transform":new gs(mt.layout_symbol["text-transform"]),"text-offset":new gs(mt.layout_symbol["text-offset"]),"text-allow-overlap":new _s(mt.layout_symbol["text-allow-overlap"]),"text-overlap":new _s(mt.layout_symbol["text-overlap"]),"text-ignore-placement":new _s(mt.layout_symbol["text-ignore-placement"]),"text-optional":new _s(mt.layout_symbol["text-optional"])});var wc={paint:new bs({"icon-opacity":new gs(mt.paint_symbol["icon-opacity"]),"icon-color":new gs(mt.paint_symbol["icon-color"]),"icon-halo-color":new gs(mt.paint_symbol["icon-halo-color"]),"icon-halo-width":new gs(mt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new gs(mt.paint_symbol["icon-halo-blur"]),"icon-translate":new _s(mt.paint_symbol["icon-translate"]),"icon-translate-anchor":new _s(mt.paint_symbol["icon-translate-anchor"]),"text-opacity":new gs(mt.paint_symbol["text-opacity"]),"text-color":new gs(mt.paint_symbol["text-color"],{runtimeType:St,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new gs(mt.paint_symbol["text-halo-color"]),"text-halo-width":new gs(mt.paint_symbol["text-halo-width"]),"text-halo-blur":new gs(mt.paint_symbol["text-halo-blur"]),"text-translate":new _s(mt.paint_symbol["text-translate"]),"text-translate-anchor":new _s(mt.paint_symbol["text-translate-anchor"])}),layout:bc};class Tc{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:wt,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}}Br("FormatSectionOverride",Tc,{omit:["defaultValue"]});class Ic extends Ts{constructor(t){super(t,wc)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const s=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||qi(n.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new vc(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of wc.paint.overridableProperties){if(!Ic.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Tc(e),r=new Ni(i,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new ji("source",r):new Zi("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new ms(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Ic.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=wc.paint.properties[e];let s=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof Xt)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{s||(e instanceof Qt&&Yt(e.value)===Pt?n(e.value.sections):e instanceof re?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}function zc(t,e,i){let r="never";const s=t.get(e);return s?r=s:t.get(i)&&(r="always"),r}var Sc={paint:new bs({"background-color":new _s(mt.paint_background["background-color"]),"background-pattern":new xs(mt.paint_background["background-pattern"]),"background-opacity":new _s(mt.paint_background["background-opacity"])})},Ac={paint:new bs({"raster-opacity":new _s(mt.paint_raster["raster-opacity"]),"raster-hue-rotate":new _s(mt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _s(mt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _s(mt.paint_raster["raster-brightness-max"]),"raster-saturation":new _s(mt.paint_raster["raster-saturation"]),"raster-contrast":new _s(mt.paint_raster["raster-contrast"]),"raster-resampling":new _s(mt.paint_raster["raster-resampling"]),"raster-fade-duration":new _s(mt.paint_raster["raster-fade-duration"])})};class Ec extends Ts{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(){}}const Cc={circle:class extends Ts{constructor(t){super(t,Ea)}createBucket(t){return new pa(t)}queryRadius(t){const e=t;return Ia("circle-radius",this,e)+Ia("circle-stroke-width",this,e)+za(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a,o){const l=Sa(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),n.angle,a),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e){return t.map((t=>Za(t,e)))}(l,o),p=h?c*a:c;for(const t of r)for(const e of t){const t=h?e:Za(e,o);let i=p;const r=$a([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r[3]),ma(u,t,i))return!0}return!1}},heatmap:class extends Ts{constructor(t){super(t,Xa),this._updateColorRamp()}createBucket(t){return new Ga(t)}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Qa({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}},hillshade:class extends Ts{constructor(t){super(t,to)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}},fill:class extends Ts{constructor(t){super(t,qo)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Uo(t)}queryRadius(){return za(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a){return fa(Sa(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),n.angle,a),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Ts{constructor(t){super(t,hl)}createBucket(t){return new ol(t)}queryRadius(){return za(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,s,n,a,o){const l=Sa(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),n.angle,a),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e,i,r){const s=[];for(const i of t){const t=[i.x,i.y,0,1];$a(t,t,e),s.push(new k(t[0]/t[3],t[1]/t[3]))}return s}(l,o),p=function(t,e,i,r){const s=[],n=[],a=r[8]*e,o=r[9]*e,l=r[10]*e,c=r[11]*e,h=r[8]*i,u=r[9]*i,p=r[10]*i,d=r[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x,n=s.y,m=r[0]*e+r[4]*n+r[12],f=r[1]*e+r[5]*n+r[13],_=r[2]*e+r[6]*n+r[14],g=r[3]*e+r[7]*n+r[15],y=_+l,x=g+c,v=m+h,b=f+u,w=_+p,T=g+d,I=new k((m+a)/x,(f+o)/x);I.z=y/x,t.push(I);const z=new k(v/T,b/T);z.z=w/T,i.push(z)}s.push(t),n.push(i)}return[s,n]}(r,h,c,o);return function(t,e,i){let r=1/0;fa(i,e)&&(r=pl(i,e[0]));for(let s=0;s<e.length;s++){const n=e[s],a=t[s];for(let t=0;t<n.length-1;t++){const e=n[t],s=[e,n[t+1],a[t+1],a[t],e];da(i,s)&&(r=Math.min(r,pl(i,s)))}}return r!==1/0&&r}(p[0],p[1],u)}},line:class extends Ts{constructor(t){super(t,wl),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof Be,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"]=Tl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new vl(t)}queryRadius(t){const e=t,i=Il(Ia("line-width",this,e),Ia("line-gap-width",this,e)),r=Ia("line-offset",this,e);return i/2+Math.abs(r)+za(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a){const o=Sa(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),n.angle,a),l=a/2*Il(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[];for(let r=0;r<t.length;r++){const s=t[r],n=[];for(let t=0;t<s.length;t++){const i=s[t-1],r=s[t],a=s[t+1],o=0===t?new k(0,0):r.sub(i)._unit()._perp(),l=t===s.length-1?new k(0,0):a.sub(r)._unit()._perp(),c=o._add(l)._unit(),h=c.x*l.x+c.y*l.y;0!==h&&c._mult(1/h),n.push(c._mult(e)._add(r))}i.push(n)}return i}(r,c*a)),function(t,e,i){for(let r=0;r<e.length;r++){const s=e[r];if(t.length>=3)for(let e=0;e<s.length;e++)if(wa(t,s[e]))return!0;if(_a(t,s,i))return!0}return!1}(o,r,l)}isTileClipped(){return!0}},symbol:Ic,background:class extends Ts{constructor(t){super(t,Sc)}},raster:class extends Ts{constructor(t){super(t,Ac)}}};function Pc(t){return"custom"===t.type?new Ec(t):new Cc[t.type](t)}class kc{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:s}=t,n=!(this.size&&this.size[0]===r&&this.size[1]===s||i),{context:a}=this,{gl:o}=a;if(this.useMipmap=Boolean(e&&e.useMipmap),o.bindTexture(o.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA&&(!e||!1!==e.premultiply)),n)this.size=[r,s],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||C(t)?o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,o.UNSIGNED_BYTE,t):o.texImage2D(o.TEXTURE_2D,0,this.format,r,s,0,this.format,o.UNSIGNED_BYTE,t.data);else{const{x:e,y:n}=i||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||C(t)?o.texSubImage2D(o.TEXTURE_2D,0,e,n,o.RGBA,o.UNSIGNED_BYTE,t):o.texSubImage2D(o.TEXTURE_2D,0,e,n,r,s,o.RGBA,o.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.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 Mc(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class Dc extends dt{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new Ja({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0;return this._validateStretch(e.stretchX,e.data&&e.data.width)||(this.fire(new pt(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,e.data&&e.data.height)||(this.fire(new pt(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new pt(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(t,e){const i={};for(const e of t){this.images[e]||this.fire(new ut("styleimagemissing",{id:e}));const t=this.images[e];t?i[e]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:v(`Image "${e}" 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.`)}e(null,i)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const e=this.patterns[t],i=this.getImage(t);if(!i)return null;if(e&&e.position.version===i.version)return e.position;if(e)e.position.version=i.version;else{const e={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new nc(e,i);this.patterns[t]={bin:e,position:r}}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 kc(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:e,h:i}=sc(t),r=this.atlasImage;r.resize({width:e||1,height:i||1});for(const t in this.patterns){const{bin:e}=this.patterns[t],i=e.x+1,s=e.y+1,n=this.images[t].data,a=n.width,o=n.height;Ja.copy(n,r,{x:0,y:0},{x:i,y:s},{width:a,height:o}),Ja.copy(n,r,{x:0,y:o-1},{x:i,y:s-1},{width:a,height:1}),Ja.copy(n,r,{x:0,y:0},{x:i,y:s+o},{width:a,height:1}),Ja.copy(n,r,{x:a-1,y:0},{x:i-1,y:s},{width:1,height:o}),Ja.copy(n,r,{x:0,y:0},{x:i+a,y:s},{width:1,height:o})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];Mc(t)&&this.updateImage(e,t)}}}const Lc=1e20;function Bc(t,e,i,r,s,n,a,o,l){for(let c=e;c<e+r;c++)Rc(t,i*n+c,n,s,a,o,l);for(let c=i;c<i+s;c++)Rc(t,c*n+e,1,r,a,o,l)}function Rc(t,e,i,r,s,n,a){n[0]=0,a[0]=-Lc,a[1]=Lc,s[0]=t[e];for(let o=1,l=0,c=0;o<r;o++){s[o]=t[e+o*i];const r=o*o;do{const t=n[l];c=(s[o]-s[t]+r-t*t)/(o-t)/2}while(c<=a[l]&&--l>-1);l++,n[l]=o,a[l]=c,a[l+1]=Lc}for(let o=0,l=0;o<r;o++){for(;a[l+1]<o;)l++;const r=n[l],c=o-r;t[e+o*i]=s[r]+c*c}}class Fc{constructor(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});h(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let s=r.glyphs[e];if(void 0!==s)return void i(null,{stack:t,id:e,glyph:s});if(s=this._tinySDF(r,t,e),s)return r.glyphs[e]=s,void i(null,{stack:t,id:e,glyph:s});const n=Math.floor(e/256);if(256*n>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[n])return void i(null,{stack:t,id:e,glyph:s});let a=r.requests[n];a||(a=r.requests[n]=[],Fc.loadGlyphRange(t,n,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[n]=!0}for(const i of a)i(t,e);delete r.requests[n]}))),a.push(((r,s)=>{r?i(r):s&&i(null,{stack:t,id:e,glyph:s[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:s}of i)(t[e]||(t[e]={}))[r]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};e(null,t)}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(qr(t)||$r(t)||Ur(t)||Nr(t))}_tinySDF(t,e,i){const r=this.localIdeographFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(i))return;let s=t.tinySDF;if(!s){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),s=t.tinySDF=new Fc.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:r,fontWeight:i})}const n=s.draw(String.fromCharCode(i));return{id:i,bitmap:new Ya({width:n.width||30,height:n.height||30},n.data),metrics:{width:n.glyphWidth||24,height:n.glyphHeight||24,left:n.glyphLeft||0,top:n.glyphTop-27||-8,advance:n.glyphAdvance||24}}}}Fc.loadGlyphRange=function(t,e,i,r,s){const n=256*e,a=n+255,o=r.transformRequest(i.replace("{fontstack}",t).replace("{range}",`${n}-${a}`),H.Glyphs);et(o,((t,e)=>{if(t)s(t);else if(e){const t={};for(const i of function(t){return new Ml(t).readFields(ec,[])}(e))t[i.id]=i;s(null,t)}}))},Fc.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:n="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const o=this.size=t+4*e,l=this._createCanvas(o),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${n} ${t}px ${s}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:n}=this.ctx.measureText(t),a=Math.ceil(i),o=Math.min(this.size-this.buffer,Math.ceil(n-s)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=o+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return d;const{ctx:m,buffer:f,gridInner:_,gridOuter:g}=this;m.clearRect(f,f,o,l),m.fillText(t,f,f+a);const y=m.getImageData(f,f,o,l);g.fill(Lc,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<o;e++){const i=y.data[4*(t*o+e)+3]/255;if(0===i)continue;const r=(t+f)*c+e+f;if(1===i)g[r]=0,_[r]=Lc;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}Bc(g,0,0,c,h,c,this.f,this.v,this.z),Bc(_,f,f,o,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};const Oc=new bs({anchor:new _s(mt.light.anchor),position:new class{constructor(){this.specification=mt.light.position}possiblyEvaluate(t,e){return function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Re(t.x,e.x,i),y:Re(t.y,e.y,i),z:Re(t.z,e.z,i)}}},color:new _s(mt.light.color),intensity:new _s(mt.light.intensity)}),Vc="-transition";class Uc extends dt{constructor(t){super(),this._transitionable=new hs(Oc),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,e={}){if(!this._validate(Cr,t,e))for(const e in t){const i=t[e];e.endsWith(Vc)?this._transitionable.setTransition(e.slice(0,-Vc.length),i):this._transitionable.setValue(e,i)}}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,e,i){return(!i||!1!==i.validate)&&Mr(this,t.call(Er,u({value:e,style:{glyphs:!0,sprite:!0},styleSpec:mt})))}}class Nc{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 i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}getDashRanges(t,e,i){const r=[];let s=t.length%2==1?-t[t.length-1]*i:0,n=t[0]*i,a=!0;r.push({left:s,right:n,isDash:a,zeroLength:0===t[0]});let o=t[0];for(let e=1;e<t.length;e++){a=!a;const l=t[e];s=o*i,o+=l,n=o*i,r.push({left:s,right:n,isDash:a,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const s=this.width*(this.nextRow+i+e);let n=0,a=t[n];for(let o=0;o<this.width;o++){o/a.right>1&&(a=t[++n]);const l=Math.abs(o-a.left),c=Math.abs(o-a.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(a.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[s+o]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let s=0,n=t[s];for(let e=0;e<this.width;e++){e/n.right>1&&(n=t[++s]);const i=Math.abs(e-n.left),a=Math.abs(e-n.right),o=Math.min(i,a);this.data[r+e]=Math.max(0,Math.min(255,(n.isDash?o:-o)+128))}}addDash(t,e){const i=e?7:0,r=2*i+1;if(this.nextRow+r>this.height)return v("LineAtlas out of space"),null;let s=0;for(let e=0;e<t.length;e++)s+=t[e];if(0!==s){const r=this.width/s,n=this.getDashRanges(t,this.width,r);e?this.addRoundDash(n,r,i):this.addRegularDash(n)}const n={y:(this.nextRow+i+.5)/this.height,height:2*i/this.height,width:s};return this.nextRow+=r,this.dirty=!0,n}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}class qc{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}class $c{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=m();const i=this.workerPool.acquire(this.id);for(let t=0;t<i.length;t++){const r=new $c.Actor(i[t],e,this.id);r.name=`Worker ${t}`,this.actors.push(r)}}broadcast(t,e,i){h(this.actors,((i,r)=>{i.send(t,e,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function jc(t,e,i){const r=function(e,r){if(e)return i(e);if(r){const e=p(u(r,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(e.vectorLayers=r.vector_layers,e.vectorLayerIds=e.vectorLayers.map((t=>t.id))),i(null,e)}};return t.url?tt(e.transformRequest(t.url,H.Source),r):P.frame((()=>r(null,t)))}$c.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},f(["receive","process"],this),this.invoker=new qc(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=T()?t:window}send(t,e,i,r,s=!1){const n=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(this.callbacks[n]=i);const a=E(this.globalScope)?void 0:[];return this.target.postMessage({id:n,type:t,hasCallback:!!i,targetMapId:r,mustQueue:s,sourceMapId:this.mapId,data:Fr(e,a)},a),{cancel:()=>{i&&delete this.callbacks[n],this.target.postMessage({id:n,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){delete this.tasks[i];const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t()}else T()||e.mustQueue?(this.tasks[i]=e,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,e)}process(){if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Or(e.error)):i(null,Or(e.data)))}else{let i=!1;const r=E(this.globalScope)?void 0:[],s=e.hasCallback?(e,s)=>{i=!0,delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Fr(e):null,data:Fr(s,r)},r)}:t=>{i=!0};let n=null;const a=Or(e.data);if(this.parent[e.type])n=this.parent[e.type](e.sourceMapId,a,s);else if(this.parent.getWorkerSource){const t=e.type.split(".");n=this.parent.getWorkerSource(e.sourceMapId,t[0],a.source)[t[1]](a,s)}else s(new Error(`Could not find function ${e.type}`));!i&&n&&n.cancel&&(this.cancelCallbacks[t]=n.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}};const Zc=6371008.8;class Gc{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 Gc(c(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,i=this.lat*e,r=t.lat*e,s=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Zc*Math.acos(Math.min(s,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Xc(new Gc(this.lng-i,this.lat-e),new Gc(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Gc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Gc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Gc(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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Xc{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):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 Gc?new Gc(t.lng,t.lat):Gc.convert(t),this}setSouthWest(t){return this._sw=t instanceof Gc?new Gc(t.lng,t.lat):Gc.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,s;if(t instanceof Gc)r=t,s=t;else{if(!(t instanceof Xc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Xc.convert(t)):this.extend(Gc.convert(t)):this;if(r=t._sw,s=t._ne,!r||!s)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(s.lng,i.lng),i.lat=Math.max(s.lat,i.lat)):(this._sw=new Gc(r.lng,r.lat),this._ne=new Gc(s.lng,s.lat)),this}getCenter(){return new Gc((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 Gc(this.getWest(),this.getNorth())}getSouthEast(){return new Gc(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:e,lat:i}=Gc.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return t instanceof Xc?t:t?new Xc(t):t}}const Wc=2*Math.PI*Zc;function Hc(t){return Wc*Math.cos(t*Math.PI/180)}function Kc(t){return(180+t)/360}function Yc(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Jc(t,e){return t/Hc(e)}function Qc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class th{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Gc.convert(t);return new th(Kc(i.lng),Yc(i.lat),Jc(e,i.lat))}toLngLat(){return new Gc(360*this.x-180,Qc(this.y))}toAltitude(){return this.z*Hc(Qc(this.y))}meterInMercatorCoordinateUnits(){return 1/Wc*(t=Qc(this.y),1/Math.cos(t*Math.PI/180));var t}}class eh{constructor(t,e,i){this.bounds=Xc.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||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 e=Math.pow(2,t.z),i=Math.floor(Kc(this.bounds.getWest())*e),r=Math.floor(Yc(this.bounds.getNorth())*e),s=Math.ceil(Kc(this.bounds.getEast())*e),n=Math.ceil(Yc(this.bounds.getSouth())*e);return t.x>=i&&t.x<s&&t.y>=r&&t.y<n}}class ih extends dt{constructor(t,e,i,r){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,u(this,p(e,["url","scheme","tileSize","promoteId"])),this._options=u({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}load(){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this._tileJSONRequest=jc(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t?this.fire(new pt(t)):e&&(u(this,e),e.bounds&&(this.tileBounds=new eh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),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}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return u({},this._options)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:this.map._requestManager.transformRequest(i,H.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};function s(i,r){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),q(this.dispatcher),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state?"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",r,s.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class rh extends dt{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=u({type:"raster"},e),u(this,p(e,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this._tileJSONRequest=jc(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new pt(t)):e&&(u(this,e),e.bounds&&(this.tileBounds=new eh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return u({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=at(this.map._requestManager.transformRequest(i,H.Tile),((i,r,s)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(r){this.map._refreshExpiredTiles&&t.setExpiryData(s);const i=this.map.painter.context,n=i.gl;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new kc(i,r,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),i.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",q(this.dispatcher),e(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let sh;function nh(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class ah{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=ch(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(n=this.y,a=this.z,o=nh(256*(s=this.x),256*(n=Math.pow(2,a)-n-1),a),l=nh(256*(s+1),256*(n+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var s,n,a,o,l;const c=function(t,e,i){let r,s="";for(let n=t;n>0;n--)r=1<<n-1,s+=(e&r?1:0)+(i&r?2:0);return s}(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"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}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 k((t.x*e-this.x)*aa,(t.y*e-this.y)*aa)}toString(){return`${this.z}/${this.x}/${this.y}`}}class oh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=ch(t,e.z,e.z,e.x,e.y)}}class lh{constructor(t,e,i,r,s){this.overscaledZ=t,this.wrap=e,this.canonical=new ah(i,+r,+s),this.key=ch(e,t,i,r,s)}clone(){return new lh(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){const e=this.canonical.z-t;return t>this.canonical.z?new lh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new lh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){const i=this.canonical.z-t;return t>this.canonical.z?ch(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):ch(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new lh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new lh(e,this.wrap,e,i,r),new lh(e,this.wrap,e,i+1,r),new lh(e,this.wrap,e,i,r+1),new lh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new lh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new lh(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new oh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new th(t.x-this.wrap,t.y))}}function ch(t,e,i,r,s){(t*=2)<0&&(t=-1*t-1);const n=1<<i;return(n*n*t+n*s+r).toString(36)+i.toString(36)+e.toString(36)}Br("CanonicalTileID",ah),Br("OverscaledTileID",lh,{omit:["posMatrix"]}),Br("DEMData",class{constructor(t,e,i){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void v(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const r=this.dim=e.height-2;this.data=new Uint32Array(e.data.buffer),this.encoding=i||"mapbox";for(let t=0;t<r;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(r,t)]=this.data[this._idx(r-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,r)]=this.data[this._idx(t,r-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(r,-1)]=this.data[this._idx(r-1,0)],this.data[this._idx(-1,r)]=this.data[this._idx(0,r-1)],this.data[this._idx(r,r)]=this.data[this._idx(r-1,r-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<r;t++)for(let e=0;e<r;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(i[r],i[r+1],i[r+2])}getUnpackVector(){return"terrarium"===this.encoding?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}getPixels(){return new Ja({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,s=e*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=s-1;break;case 1:s=r+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const o=-e*this.dim,l=-i*this.dim;for(let e=n;e<a;e++)for(let i=r;i<s;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+o,e+l)]}});class hh extends rh{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=u({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function r(i,r){i&&(t.state="errored",e(i)),r&&(t.dem=r,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",e(null))}t.request=at(this.map._requestManager.transformRequest(i,H.Tile),function(i,s){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData(s),delete s.cacheControl,delete s.expires;const e=C(s)&&(null==sh&&(sh="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),sh)?s:P.getImageData(s,1),i={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:e,encoding:this.encoding};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",i,r.bind(this)))}}.bind(this)),t.neighboringTiles=this._getNeighboringTiles(t.tileID)}_getNeighboringTiles(t){const e=t.canonical,i=Math.pow(2,e.z),r=(e.x-1+i)%i,s=0===e.x?t.wrap-1:t.wrap,n=(e.x+1+i)%i,a=e.x+1===i?t.wrap+1:t.wrap,o={};return o[new lh(t.overscaledZ,s,e.z,r,e.y).key]={backfilled:!1},o[new lh(t.overscaledZ,a,e.z,n,e.y).key]={backfilled:!1},e.y>0&&(o[new lh(t.overscaledZ,s,e.z,r,e.y-1).key]={backfilled:!1},o[new lh(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},o[new lh(t.overscaledZ,a,e.z,n,e.y-1).key]={backfilled:!1}),e.y+1<i&&(o[new lh(t.overscaledZ,s,e.z,r,e.y+1).key]={backfilled:!1},o[new lh(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},o[new lh(t.overscaledZ,a,e.z,n,e.y+1).key]={backfilled:!1}),o}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})}}class uh extends dt{constructor(t,e,i,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=i.getActor(),this.setEventedParent(r),this._data=e.data,this._options=u({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const s=aa/this.tileSize;this.workerOptions=u({source:this.id,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(void 0!==e.buffer?e.buffer:128)*s,tolerance:(void 0!==e.tolerance?e.tolerance:.375)*s,extent:aa,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:void 0!==e.clusterMaxZoom?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:aa,radius:(e.clusterRadius||50)*s,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}load(){this._updateWorkerData("metadata")}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData("content"),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(t){const e=u({},this.workerOptions),i=this._data;"string"==typeof i?(e.request=this.map._requestManager.transformRequest(P.resolveURL(i),H.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(i),this._pendingLoads++,this.fire(new ut("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,e,((e,i)=>{if(this._pendingLoads--,this._removed||i&&i.abandoned)return void this.fire(new ut("dataabort",{dataType:"source",sourceDataType:t}));let r=null;if(i&&i.resourceTiming&&i.resourceTiming[this.id]&&(r=i.resourceTiming[this.id].slice(0)),e)return void this.fire(new pt(e));const s={dataType:"source",sourceDataType:t};this._collectResourceTiming&&r&&r.length>0&&u(s,{resourceTiming:r}),this.fire(new ut("data",s))}))}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";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.request=this.actor.send(i,r,((r,s)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(s,this.map.painter,"reloadTile"===i),e(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return u({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var ph=As([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class dh extends dt{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t,e){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this.url=this.options.url,at(this.map._requestManager.transformRequest(this.url,H.Image),((i,r)=>{this._loaded=!0,i?this.fire(new pt(i)):r&&(this.image=r,t&&(this.coordinates=t),e&&e(),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}setCoordinates(t){this.coordinates=t;const e=t.map(th.fromLngLat);this.tileID=function(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);const n=Math.max(r-e,s-i),a=Math.max(0,Math.floor(-Math.log(n)/Math.LN2)),o=Math.pow(2,a);return new ah(a,Math.floor((e+r)/2*o),Math.floor((i+s)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;const i=e.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new cn,this._boundsArray.emplaceBack(i[0].x,i[0].y,0,0),this._boundsArray.emplaceBack(i[1].x,i[1].y,aa,0),this._boundsArray.emplaceBack(i[3].x,i[3].y,0,aa),this._boundsArray.emplaceBack(i[2].x,i[2].y,aa,aa),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,ph.members)),this.boundsSegments||(this.boundsSegments=En.simpleSegment(0,0,4,2)),this.texture||(this.texture=new kc(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class mh extends dh{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,H.Source).url);!function(t,e){const i=window.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=window.document.createElement("source");it(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}}(this.urls,((t,e)=>{this._loaded=!0,t?this.fire(new pt(t)):e&&(this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new pt(new ft(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.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,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,ph.members)),this.boundsSegments||(this.boundsSegments=En.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new kc(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class fh extends dh{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?Array.isArray(e.coordinates)&&4===e.coordinates.length&&!e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new pt(new ft(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new pt(new ft(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new pt(new ft(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"==typeof e.canvas||e.canvas instanceof HTMLCanvasElement||this.fire(new pt(new ft(`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 pt(new ft(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}load(){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 pt(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 e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,ph.members)),this.boundsSegments||(this.boundsSegments=En.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new kc(e,this.canvas,i.RGBA,{premultiply:!0});for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}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 _h={vector:ih,raster:rh,"raster-dem":hh,geojson:uh,video:mh,image:dh,canvas:fh};function gh(t,e){const i=ka();return Ba(i,i,[1,1,0]),Ra(i,i,[.5*t.width,.5*t.height,1]),La(i,i,t.calculatePosMatrix(e.toUnwrapped()))}function yh(t,e,i,r,s,n){const a=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(s&&s.layers,e,t.id),o=n.maxPitchScaleFactor(),l=t.tilesIn(r,o,a);l.sort(xh);const c=[];for(const r of l)c.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,s,n,o,gh(t.transform,r.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,s=r.wrappedTileID,n=i[s]=i[s]||{};for(const i in t){const r=t[i],s=n[i]=n[i]||{},a=e[i]=e[i]||[];for(const t of r)s[t.featureIndex]||(s[t.featureIndex]=!0,a.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function xh(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class vh{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}class bh{constructor(t,e,i,r,s){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=s}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}}function wh(t,e,i,r,s){return _(t,((t,n)=>{const a=e instanceof fs?e.get(n):null;return a&&a.evaluate?a.evaluate(i,r,s):a}))}function Th(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return{minX:e,minY:i,maxX:r,maxY:s}}function Ih(t,e){return e-t}Br("FeatureIndex",class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Dr(aa,16,0),this.grid3D=new Dr(aa,16,0),this.featureIndexArray=new on,this.promoteId=e}insert(t,e,i,r,s,n){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,s);const o=n?this.grid3D:this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<aa&&r[1]<aa&&r[2]>=0&&r[3]>=0&&o.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Go.VectorTile(new Ml(this.rawTileData)).layers,this.sourceLayerCoder=new vh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const s=t.params||{},n=aa/t.tileSize/t.scale,a=rr(s.filter),o=t.queryGeometry,l=t.queryPadding*n,c=Th(o),h=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),u=Th(t.cameraQueryGeometry),p=this.grid3D.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l,((e,i,r,s)=>function(t,e,i,r,s){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&s>=n.y)return!0;const n=[new k(e,i),new k(e,s),new k(r,s),new k(r,i)];if(t.length>2)for(const e of n)if(wa(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Ta(t[e],t[e+1],n))return!0;return!1}(t.cameraQueryGeometry,e-l,i-l,r+l,s+l)));for(const t of p)h.push(t);h.sort(Ih);const d={};let m;for(let l=0;l<h.length;l++){const c=h[l];if(c===m)continue;m=c;const u=this.featureIndexArray.get(c);let p=null;this.loadMatchingFeature(d,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,a,s.layers,s.availableImages,e,i,r,((e,i,r)=>(p||(p=ca(e)),i.queryIntersectsFeature(o,e,r,p,this.z,t.transform,n,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,i,r,s,n,a,o,l,c,h){const p=this.bucketLayerIDs[e];if(n&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(n,p))return;const d=this.sourceLayerCoder.decode(i),m=this.vtLayers[d].feature(r);if(s.needGeometry){const t=ha(m,!0);if(!s.filter(new os(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new os(this.tileID.overscaledZ),m))return;const f=this.getId(m,d);for(let e=0;e<p.length;e++){const i=p[e];if(n&&n.indexOf(i)<0)continue;const s=o[i];if(!s)continue;let d={};f&&c&&(d=c.getState(s.sourceLayer||"_geojsonTileLayer",f));const _=u({},l[i]);_.paint=wh(_.paint,s.paint,m,d,a),_.layout=wh(_.layout,s.layout,m,d,a);const g=!h||h(m,s,d);if(!g)continue;const y=new bh(m,this.z,this.x,this.y,f);y.layer=_;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:r,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,s,n,a,o){const l={};this.loadVTLayers();const c=rr(s);for(const s of t)this.loadMatchingFeature(l,i,r,s,c,n,a,o,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}},{omit:["rawTileData","sourceLayerCoder"]});class zh{constructor(t,e){this.tileID=t,this.uid=m(),this.uses=0,this.tileSize=e,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;e<P.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.textures.forEach((e=>t.saveTileTexture(e))),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(t,e,i){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof vc){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof vc&&e.hasRTLText){this.hasRTLText=!0,as.isLoading()||as.isLoaded()||"deferred"!==ss()||ns();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new Js}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new kc(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new kc(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,s,n,a,o,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:s,scale:n,tileSize:this.tileSize,pixelPosMatrix:c,transform:o,params:a,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),s=e?e.sourceLayer:"",n=r._geojsonTileLayer||r[s];if(!n)return;const a=rr(e&&e.filter),{z:o,x:l,y:c}=this.tileID.canonical,h={z:o,x:l,y:c};for(let e=0;e<n.length;e++){const r=n.feature(e);if(a.needGeometry){const t=ha(r,!0);if(!a.filter(new os(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new os(this.tileID.overscaledZ),r))continue;const u=i.getId(r,s),p=new bh(r,o,l,c,u);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=I(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const i=this.latestFeatureIndex.loadVTLayers();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const s=this.buckets[r],n=s.layers[0].sourceLayer||"_geojsonTileLayer",a=i[n],o=t[n];if(!a||!o||0===Object.keys(o).length)continue;s.update(o,a,this.imageAtlas&&this.imageAtlas.patternPositions||{});const l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(s)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<P.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=P.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class Sh{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const s={value:e,timeout:void 0};if(void 0!==i&&(s.timeout=setTimeout((()=>{this.remove(t,s)}),i)),this.data[r].push(s),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][r];return this.data[i].splice(r,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Ah{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},u(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=u({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),u(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},u(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class Eh extends dt{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=function(t,e,i,r){const s=new _h[e.type](t,e,i,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return f(["load","abort","unload","serialize","prepare"],s),s}(t,e,i,this),this._tiles={},this._cache=new Sh(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ah}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize: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;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,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,(()=>{})),this._source.fire(new ut("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 i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Ch).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,s=new k(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),n=new k(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||n.y-s.y||n.x-s.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Ch).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)return t.state="errored",void(404!==r.status?this._source.fire(new pt(r,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=P.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new ut("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const s=e[r];if(t.neighboringTiles&&t.neighboringTiles[s]){const e=this.getTileByID(s);i(t,e),i(e,t)}}function i(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,s=Math.pow(2,t.tileID.canonical.z),n=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const s in this._tiles){let n=this._tiles[s];if(r[s]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(a=t)}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const e=Math.ceil(t.width/this._source.tileSize)+1,i=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*i*5),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t])}}update(t,e){if(this.transform=t,this.terrain=e,!this._sourceLoaded||this._paused)return;let i;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new lh(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=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:e}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[];const r=t.coveringZoomLevel(this._source),s=Math.max(r-Eh.maxOverzooming,this._source.minzoom),n=Math.max(r+Eh.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of i)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}i=i.concat(Object.values(t))}const a=this._updateRetainedTiles(i,r);if(Ph(this._source.type)){const t={},o={},l=Object.keys(a);for(const e of l){const i=a[e],r=this._tiles[e];if(!r||r.fadeEndTime&&r.fadeEndTime<=P.now())continue;const n=this.findLoadedParent(i,s);n&&(this._addTile(n.tileID),t[n.tileID.key]=n.tileID),o[e]=i}this._retainLoadedChildren(o,r,n,a);for(const e in t)a[e]||(this._coveredTiles[e]=!0,a[e]=t[e]);if(e){const t={},e={};for(const r of i)this._tiles[r.key].hasData()?t[r.key]=r:e[r.key]=r;for(const i in e){const r=e[i].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=a[r[0].key]=r[0],t[r[1].key]=a[r[1].key]=r[1],t[r[2].key]=a[r[2].key]=r[2],t[r[3].key]=a[r[3].key]=r[3],delete e[i])}for(const i in e){const r=this.findLoadedParent(e[i],this._source.minzoom);if(r){t[r.tileID.key]=a[r.tileID.key]=r.tileID;for(const e in t)t[e].isChildOf(r.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}for(const t in a)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,a);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){const i={},r={},s=Math.max(e-Eh.maxOverzooming,this._source.minzoom),n=Math.max(e+Eh.maxUnderzooming,this._source.minzoom),a={};for(const r of t){const t=this._addTile(r);i[r.key]=r,t.hasData()||e<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,e,n,i);for(const n of t){let t=this._tiles[n.key];if(t.hasData())continue;if(e+1>this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let e=n.overscaledZ-1;e>=s;--e){const s=n.scaledTo(e);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&a&&(t=this._addTile(s)),t&&(i[s.key]=s,a=t.wasRequested(),t.hasData()))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=e;return e||(e=new zh(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))),e.uses++,this._tiles[t.key]=e,i||this._source.fire(new ut("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,e,i){const r=[],s=this.transform;if(!s)return r;const n=i?s.getCameraQueryGeometry(t):t,a=t.map((t=>s.pointCoordinate(t,this.terrain))),o=n.map((t=>s.pointCoordinate(t,this.terrain))),l=this.getIds();let c=1/0,h=1/0,u=-1/0,p=-1/0;for(const t of o)c=Math.min(c,t.x),h=Math.min(h,t.y),u=Math.max(u,t.x),p=Math.max(p,t.y);for(let t=0;t<l.length;t++){const i=this._tiles[l[t]];if(i.holdingForFade())continue;const n=i.tileID,d=Math.pow(2,s.zoom-i.tileID.overscaledZ),m=e*i.queryPadding*aa/i.tileSize/d,f=[n.getTilePoint(new th(c,h)),n.getTilePoint(new th(u,p))];if(f[0].x-m<aa&&f[0].y-m<aa&&f[1].x+m>=0&&f[1].y+m>=0){const t=a.map((t=>n.getTilePoint(t))),e=o.map((t=>n.getTilePoint(t)));r.push({tile:i,tileID:n,queryGeometry:t,cameraQueryGeometry:e,scale:d})}}return r}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(Ph(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=P.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function Ch(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Ph(t){return"raster"===t||"image"===t||"video"===t}Eh.maxOverzooming=10,Eh.maxUnderzooming=3;const kh="mapboxgl_preloaded_worker_pool";class Mh{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Mh.workerCount;)this.workers.push(new Worker(_f.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[kh]}numActive(){return Object.keys(this.active).length}}const Dh=Math.floor(P.hardwareConcurrency/2);let Lh;function Bh(){return Lh||(Lh=new Mh),Lh}Mh.workerCount=Math.max(Math.min(Dh,6),1);var Rh=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Fh(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return Rh.forEach((t=>{t in e&&(i[t]=e[t])})),i}function Oh(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Fh(t[i],e[t[i].ref]));return t}const Vh={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function Uh(t,e,i){i.push({command:Vh.addSource,args:[t,e[t]]})}function Nh(t,e,i){e.push({command:Vh.removeSource,args:[t]}),i[t]=!0}function qh(t,e,i,r){Nh(t,i,r),Uh(t,e,i)}function $h(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;return!0}function jh(t,e,i,r,s,a){let o;for(o in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,o)&&(n(t[o],e[o])||i.push({command:a,args:[r,o,e[o],s]}));for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(n(t[o],e[o])||i.push({command:a,args:[r,o,e[o],s]}))}function Zh(t){return t.id}function Gh(t,e){return t[e.id]=e,t}class Xh{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=l(t,0,1);let e=1,i=this._distances[e];const r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];const s=e-1,n=this._distances[s],a=i-n,o=a>0?(r-n)/a:0;return this.points[s].mult(1-o).add(this.points[e].mult(o))}}function Wh(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class Hh{constructor(t,e,i){const r=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,s,n){this.boxCells[s].push(n)}_insertCircleCell(t,e,i,r,s,n){this.circleCells[s].push(n)}_query(t,e,i,r,s,n,a){if(i<0||t>this.width||r<0||e>this.height)return[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)o.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];o.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,o,{hitTest:s,overlapMode:n,seenUids:{box:{},circle:{}}},a);return o}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,s,n){return this._query(t,e,i,r,!0,s,n).length>0}hitTestCircle(t,e,i,r,s){const n=t-i,a=t+i,o=e-i,l=e+i;if(a<0||n>this.width||l<0||o>this.height)return!1;const c=[];return this._forEachCell(n,o,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),c.length>0}_queryCell(t,e,i,r,s,n,a,o){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const s=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,p=this.boxKeys[a];if(t<=s[u+2]&&e<=s[u+3]&&i>=s[u+0]&&r>=s[u+1]&&(!o||o(p))&&(!c||!Wh(h,p.overlapMode))&&(n.push({key:p,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),c))return!0}}const p=this.circleCells[s];if(null!==p){const s=this.circles;for(const a of p)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,p=this.circleKeys[a];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,r)&&(!o||o(p))&&(!c||!Wh(h,p.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(n.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,s,n,a,o){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!o||o(r))&&!Wh(h,r.overlapMode))return n.push(!0),!0}}const p=this.circleCells[s];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!o||o(r))&&!Wh(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(s.call(this,t,e,i,r,this.xCellCount*l+p,n,a,o))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,i,r,s,n){const a=r-t,o=s-e,l=i+n;return l*l>a*a+o*o}_circleAndRectCollide(t,e,i,r,s,n,a){const o=(n-r)/2,l=Math.abs(t-(r+o));if(l>o+i)return!1;const c=(a-s)/2,h=Math.abs(e-(s+c));if(h>c+i)return!1;if(l<=o||h<=c)return!0;const u=l-o,p=h-c;return u*u+p*p<=i*i}}function Kh(t,e,i,r,s){const n=ka();return e?(Ra(n,n,[1/s,1/s,1]),i||Fa(n,n,r.angle)):La(n,r.labelPlaneMatrix,t),n}function Yh(t,e,i,r,s){if(e){const e=function(t){var e=new Pa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}(t);return Ra(e,e,[s,s,1]),i||Fa(e,e,-r.angle),e}return r.glCoordMatrix}function Jh(t,e,i){let r;i?(r=[t.x,t.y,i(t.x,t.y),1],$a(r,r,e)):(r=[t.x,t.y,0,1],cu(r,r,e));const s=r[3];return{point:new k(r[0]/s,r[1]/s),signedDistanceFromCamera:s}}function Qh(t,e){return.5+t/e*.5}function tu(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function eu(t,e,i,r,s,n,a,o,l,c){const h=r?t.textSizeData:t.iconSizeData,u=cc(h,i.transform.zoom),p=[256/i.width*2+1,256/i.height*2+1],d=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;d.clear();const m=t.lineVertexArray,f=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,_=i.transform.width/i.transform.height;let g=!1;for(let r=0;r<f.length;r++){const y=f.get(r);if(y.hidden||y.writingMode===Rl.vertical&&!g){lu(y.numGlyphs,d);continue}let x;if(g=!1,c?(x=[y.anchorX,y.anchorY,c(y.anchorX,y.anchorY),1],$a(x,x,e)):(x=[y.anchorX,y.anchorY,0,1],cu(x,x,e)),!tu(x,p)){lu(y.numGlyphs,d);continue}const v=Qh(i.transform.cameraToCenterDistance,x[3]),b=lc(h,u,y),w=a?b/v:b*v,T=new k(y.anchorX,y.anchorY),I=Jh(T,s,c).point,z={},S=su(y,w,!1,o,e,s,n,t.glyphOffsetArray,m,d,I,T,z,_,l,c);g=S.useVertical,(S.notEnoughRoom||g||S.needsFlipping&&su(y,w,!0,o,e,s,n,t.glyphOffsetArray,m,d,I,T,z,_,l,c).notEnoughRoom)&&lu(y.numGlyphs,d)}r?t.text.dynamicLayoutVertexBuffer.updateData(d):t.icon.dynamicLayoutVertexBuffer.updateData(d)}function iu(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=o.glyphStartIndex+o.numGlyphs,m=o.lineStartIndex,f=o.lineStartIndex+o.lineLength,_=e.getoffsetX(o.glyphStartIndex),g=e.getoffsetX(d-1),y=au(t*_,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);if(!y)return null;const x=au(t*g,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);return x?{first:y,last:x}:null}function ru(t,e,i,r){return t===Rl.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:(t===Rl.vertical?e.y<i.y:e.x>i.x)?{needsFlipping:!0}:null}function su(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f){const _=e/24,g=t.lineOffsetX*_,y=t.lineOffsetY*_;let x;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,s=t.lineStartIndex,c=t.lineStartIndex+t.lineLength,v=iu(_,o,g,y,i,h,u,t,l,n,p,m,f);if(!v)return{notEnoughRoom:!0};const b=Jh(v.first.point,a,f).point,w=Jh(v.last.point,a,f).point;if(r&&!i){const e=ru(t.writingMode,b,w,d);if(e)return e}x=[v.first];for(let r=t.glyphStartIndex+1;r<e-1;r++)x.push(au(_*o.getoffsetX(r),g,y,i,h,u,t.segment,s,c,l,n,p,m,f));x.push(v.last)}else{if(r&&!i){const e=Jh(u,s,f).point,i=t.lineStartIndex+t.segment+1,r=new k(l.getx(i),l.gety(i)),n=Jh(r,s,f),a=n.signedDistanceFromCamera>0?n.point:nu(u,r,e,1,s,f),o=ru(t.writingMode,e,a,d);if(o)return o}const e=au(_*o.getoffsetX(t.glyphStartIndex),g,y,i,h,u,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,l,n,p,m,f);if(!e)return{notEnoughRoom:!0};x=[e]}for(const t of x)_c(c,t.point,t.angle);return{}}function nu(t,e,i,r,s,n){const a=Jh(t.add(t.sub(e)._unit()),s,n).point,o=i.sub(a);return i.add(o._mult(r/o.mag()))}function au(t,e,i,r,s,n,a,o,l,c,h,u,p,d){const m=r?t-e:t+e;let f=m>0?1:-1,_=0;r&&(f*=-1,_=Math.PI),f<0&&(_+=Math.PI);let g=f>0?o+a:o+a+1,y=s,x=s,v=0,b=0;const w=Math.abs(m),T=[];for(;v+b<=w;){if(g+=f,g<o||g>=l)return null;if(x=y,T.push(y),y=u[g],void 0===y){const t=new k(c.getx(g),c.gety(g)),e=Jh(t,h,d);if(e.signedDistanceFromCamera>0)y=u[g]=e.point;else{const e=g-f;y=nu(0===v?n:new k(c.getx(e),c.gety(e)),t,x,w-v+1,h,d)}}v+=b,b=x.dist(y)}const I=(w-v)/b,z=y.sub(x),S=z.mult(I)._add(x);S._add(z._unit()._perp()._mult(i*f));const A=_+Math.atan2(y.y-x.y,y.x-x.x);return T.push(S),{point:S,angle:p?A:0,path:T}}const ou=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function lu(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(ou,3*t)}}function cu(t,e,i){const r=e[0],s=e[1];return t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t[3]=i[3]*r+i[7]*s+i[15],t}const hu=100;class uu{constructor(t,e=new Hh(t.width+200,t.height+200,25),i=new Hh(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+hu,this.screenBottomBoundary=t.height+hu,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,s,n){const a=this.projectAndGetPerspectiveRatio(r,t.anchorPointX,t.anchorPointY,n),o=i*a.perspectiveRatio,l=t.x1*o+a.point.x,c=t.y1*o+a.point.y,h=t.x2*o+a.point.x,u=t.y2*o+a.point.y;return!this.isInsideGrid(l,c,h,u)||"always"!==e&&this.grid.hitTest(l,c,h,u,e,s)||a.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[l,c,h,u],offscreen:this.isOffscreen(l,c,h,u)}}placeCollisionCircles(t,e,i,r,s,n,a,o,l,c,h,u,p,d){const m=[],f=new k(e.anchorX,e.anchorY),_=Jh(f,n,d),g=Qh(this.transform.cameraToCenterDistance,_.signedDistanceFromCamera),y=(c?s/g:s*g)/24,x=Jh(f,a,d).point,v=iu(y,r,e.lineOffsetX*y,e.lineOffsetY*y,!1,x,f,e,i,a,{},!1,d);let b=!1,w=!1,T=!0;if(v){const e=.5*u*g+p,i=new k(-100,-100),r=new k(this.screenRightBoundary,this.screenBottomBoundary),s=new Xh,n=v.first,a=v.last;let c=[];for(let t=n.path.length-1;t>=1;t--)c.push(n.path[t]);for(let t=1;t<a.path.length;t++)c.push(a.path[t]);const f=2.5*e;if(o){const t=c.map((t=>Jh(t,o,d)));c=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(c.length>0){const t=c[0].clone(),e=c[0].clone();for(let i=1;i<c.length;i++)t.x=Math.min(t.x,c[i].x),t.y=Math.min(t.y,c[i].y),e.x=Math.max(e.x,c[i].x),e.y=Math.max(e.y,c[i].y);_=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[c]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:function(t,e,i,r,s){const n=[];for(let a=0;a<t.length;a++){const o=t[a];let l;for(let t=0;t<o.length-1;t++){let a=o[t],c=o[t+1];a.x<e&&c.x<e||(a.x<e?a=new k(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x<e&&(c=new k(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y<i&&c.y<i||(a.y<i?a=new k(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y<i&&(c=new k(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),a.x>=r&&c.x>=r||(a.x>=r?a=new k(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=r&&(c=new k(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=s&&c.y>=s||(a.y>=s?a=new k(a.x+(s-a.y)/(c.y-a.y)*(c.x-a.x),s)._round():c.y>=s&&(c=new k(a.x+(s-a.y)/(c.y-a.y)*(c.x-a.x),s)._round()),l&&a.equals(l[l.length-1])||(l=[a],n.push(l)),l.push(c)))))}}return n}([c],i.x,i.y,r.x,r.y)}for(const i of _){s.reset(i,.25*e);let r=0;r=s.length<=.5*e?1:Math.ceil(s.paddedLength/f)+1;for(let i=0;i<r;i++){const n=i/Math.max(r-1,1),a=s.lerp(n),o=a.x+hu,c=a.y+hu;m.push(o,c,e,0);const u=o-e,p=c-e,d=o+e,f=c+e;if(T=T&&this.isOffscreen(u,p,d,f),w=w||this.isInsideGrid(u,p,d,f),"always"!==t&&this.grid.hitTestCircle(o,c,e,t,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||g<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const e=[];let i=1/0,r=1/0,s=-1/0,n=-1/0;for(const a of t){const t=new k(a.x+hu,a.y+hu);i=Math.min(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.x),n=Math.max(n,t.y),e.push(t)}const a=this.grid.query(i,r,s,n).concat(this.ignoredGrid.query(i,r,s,n)),o={},l={};for(const t of a){const i=t.key;void 0===o[i.bucketInstanceId]&&(o[i.bucketInstanceId]={}),o[i.bucketInstanceId][i.featureIndex]||da(e,[new k(t.x1,t.y1),new k(t.x2,t.y1),new k(t.x2,t.y2),new k(t.x1,t.y2)])&&(o[i.bucketInstanceId][i.featureIndex]=!0,void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]=[]),l[i.bucketInstanceId].push(i.featureIndex))}return l}insertCollisionBox(t,e,i,r,s,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,s,n){const a=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e};for(let e=0;e<t.length;e+=4)a.insertCircle(o,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r){let s;return r?(s=[e,i,r(e,i),1],$a(s,s,t)):(s=[e,i,0,1],cu(s,s,t)),{point:new k((s[0]/s[3]+1)/2*this.transform.width+hu,(-s[1]/s[3]+1)/2*this.transform.height+hu),perspectiveRatio:.5+this.transform.cameraToCenterDistance/s[3]*.5}}isOffscreen(t,e,i,r){return i<hu||t>=this.screenRightBoundary||r<hu||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=Ma([]);return Ba(t,t,[-100,-100,0]),t}}function pu(t,e,i){return e*(aa/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}class du{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class mu{constructor(t,e,i,r,s){this.text=new du(t?t.text:null,e,i,s),this.icon=new du(t?t.icon:null,e,r,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class fu{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class _u{constructor(){this.invProjMatrix=ka(),this.viewportMatrix=ka(),this.circles=[]}}class gu{constructor(t,e,i,r,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=s}}class yu{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 xu(t,e,i,r,s){const{horizontalAlign:n,verticalAlign:a}=ac(t),o=-(n-.5)*e,l=-(a-.5)*i,c=pc(t,r);return new k(o+c[0]*s,l+c[1]*s)}function vu(t,e,i,r,s,n){const{x1:a,x2:o,y1:l,y2:c,anchorPointX:h,anchorPointY:u}=t,p=new k(e,i);return r&&p._rotate(s?n:-n),{x1:a+p.x,y1:l+p.y,x2:o+p.x,y2:c+p.y,anchorPointX:h,anchorPointY:u}}class bu{constructor(t,e,i,r,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new uu(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new yu(r),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,e,i,r){const s=i.getBucket(e),n=i.latestFeatureIndex;if(!s||!n||e.id!==s.layerIds[0])return;const a=i.collisionBoxArray,o=s.layers[0].layout,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/aa,h=this.transform.calculatePosMatrix(i.tileID.toUnwrapped()),u="map"===o.get("text-pitch-alignment"),p="map"===o.get("text-rotation-alignment"),d=pu(i,1,this.transform.zoom),m=Kh(h,u,p,this.transform,d);let f=null;if(u){const t=Yh(h,u,p,this.transform,d);f=La([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[s.bucketInstanceId]=new gu(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);const _={bucket:s,layout:o,posMatrix:h,textLabelPlaneMatrix:m,labelToScreenMatrix:f,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:cc(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s,parameters:_})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:_})}attemptAnchorPlacement(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f){const _=[u.textOffset0,u.textOffset1],g=xu(t,i,r,_,s),y=this.collisionIndex.placeCollisionBox(vu(e,g.x,g.y,n,a,this.transform.angle),h,o,l,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(vu(m,g.x,g.y,n,a,this.transform.angle),h,o,l,c.predicate,f).box.length)&&y.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:_,width:i,height:r,anchor:t,textBoxScale:s,prevAnchor:e},this.markUsedJustification(p,t,u,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,u),this.placedOrientations[u.crossTileID]=d),{shift:g,placedGlyphBoxes:y}}}placeLayerBucketPart(t,e,i){const{bucket:r,layout:s,posMatrix:n,textLabelPlaneMatrix:a,labelToScreenMatrix:o,textPixelRatio:l,holdingForFade:c,collisionBoxArray:h,partiallyEvaluatedTextSize:u,collisionGroup:p}=t.parameters,d=s.get("text-optional"),m=s.get("icon-optional"),f=zc(s,"text-overlap","text-allow-overlap"),_="always"===f,g=zc(s,"icon-overlap","icon-allow-overlap"),y="always"===g,x="map"===s.get("text-rotation-alignment"),v="map"===s.get("text-pitch-alignment"),b="none"!==s.get("icon-text-fit"),w="viewport-y"===s.get("symbol-z-order"),T=_&&(y||!r.hasIconData()||m),I=y&&(_||!r.hasTextData()||d);!r.collisionArrays&&h&&r.deserializeCollisionBoxes(h);const z=(t,h)=>{if(e[t.crossTileID])return;if(c)return void(this.placements[t.crossTileID]=new fu(!1,!1,!1));let y=!1,w=!1,z=!0,S=null,A={box:null,offscreen:null},E={box:null,offscreen:null},C=null,P=null,k=null,M=0,D=0,L=0;h.textFeatureIndex?M=h.textFeatureIndex:t.useRuntimeCollisionCircles&&(M=t.featureIndex),h.verticalTextFeatureIndex&&(D=h.verticalTextFeatureIndex);const B=this.retainedQueryData[r.bucketInstanceId].tileID,R=this.terrain?(t,e)=>this.terrain.getElevation(B,t,e):null;for(const t of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const e=h[t];e&&(e.elevation=R?R(e.anchorPointX,e.anchorPointY):0)}const F=h.textBox;if(F){const e=e=>{let i=Rl.horizontal;if(r.allowVerticalPlacement&&!e&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(r,i,t))}return i},i=(e,i)=>{if(r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&h.verticalTextBox){for(const t of r.writingModes)if(t===Rl.vertical?(A=i(),E=A):A=e(),A&&A.box&&A.box.length)break}else A=e()};if(s.get("text-variable-anchor")){let a=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];a.indexOf(e.anchor)>0&&(a=a.filter((t=>t!==e.anchor)),a.unshift(e.anchor))}const o=(e,i,s)=>{const o=e.x2-e.x1,c=e.y2-e.y1,h=t.textBoxScale,u=b&&"never"===g?i:null;let d={box:[],offscreen:!1};const m="never"!==f?2*a.length:a.length;for(let i=0;i<m;++i){const m=this.attemptAnchorPlacement(a[i%a.length],e,o,c,h,x,v,l,n,p,i>=a.length?f:"never",t,r,s,u,R);if(m&&(d=m.placedGlyphBoxes,d&&d.box&&d.box.length)){y=!0,S=m.shift;break}}return d};i((()=>o(F,h.iconBox,Rl.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&!(A&&A.box&&A.box.length)&&t.numVerticalGlyphVertices>0&&e?o(e,h.verticalIconBox,Rl.vertical):{box:null,offscreen:null}})),A&&(y=A.box,z=A.offscreen);const c=e(A&&A.box);if(!y&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(r,e.anchor,t,c))}}else{const s=(e,i)=>{const s=this.collisionIndex.placeCollisionBox(e,f,l,n,p.predicate,R);return s&&s.box&&s.box.length&&(this.markUsedOrientation(r,i,t),this.placedOrientations[t.crossTileID]=i),s};i((()=>s(F,Rl.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?s(e,Rl.vertical):{box:null,offscreen:null}})),e(A&&A.box&&A.box.length)}}if(C=A,y=C&&C.box&&C.box.length>0,z=C&&C.offscreen,t.useRuntimeCollisionCircles){const e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),l=lc(r.textSizeData,u,e),c=s.get("text-padding");P=this.collisionIndex.placeCollisionCircles(f,e,r.lineVertexArray,r.glyphOffsetArray,l,n,a,o,i,v,p.predicate,t.collisionCircleDiameter,c,R),y=_||P.circles.length>0&&!P.collisionDetected,z=z&&P.offscreen}if(h.iconFeatureIndex&&(L=h.iconFeatureIndex),h.iconBox){const t=t=>{const e=b&&S?vu(t,S.x,S.y,x,v,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,g,l,n,p.predicate,R)};E&&E.box&&E.box.length&&h.verticalIconBox?(k=t(h.verticalIconBox),w=k.box.length>0):(k=t(h.iconBox),w=k.box.length>0),z=z&&k.offscreen}const O=d||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,V=m||0===t.numIconVertices;if(O||V?V?O||(w=w&&y):y=w&&y:w=y=w&&y,y&&C&&C.box&&this.collisionIndex.insertCollisionBox(C.box,f,s.get("text-ignore-placement"),r.bucketInstanceId,E&&E.box&&D?D:M,p.ID),w&&k&&this.collisionIndex.insertCollisionBox(k.box,g,s.get("icon-ignore-placement"),r.bucketInstanceId,L,p.ID),P&&(y&&this.collisionIndex.insertCollisionCircles(P.circles,f,s.get("text-ignore-placement"),r.bucketInstanceId,M,p.ID),i)){const t=r.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new _u);for(let t=0;t<P.circles.length;t+=4)e.circles.push(P.circles[t+0]),e.circles.push(P.circles[t+1]),e.circles.push(P.circles[t+2]),e.circles.push(P.collisionDetected?1:0)}this.placements[t.crossTileID]=new fu(y||T,w||I,z||r.justReloaded),e[t.crossTileID]=!0};if(w){const t=r.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];z(r.symbolInstances.get(i),r.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)z(r.symbolInstances.get(e),r.collisionArrays[e]);if(i&&r.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[r.bucketInstanceId];Da(t.invProjMatrix,n),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}r.justReloaded=!1}markUsedJustification(t,e,i,r){let s;s=r===Rl.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(e)];const n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const e of n)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:i.crossTileID)}markUsedOrientation(t,e,i){const r=e===Rl.horizontal||e===Rl.horizontalOnly?e:0,s=e===Rl.vertical?e:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of n)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=s)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},n=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=s[t];n?(this.opacities[t]=new mu(n,r,e.text,e.icon),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new mu(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new mu(e,r,!1,!1);s.isHidden()||(this.opacities[t]=s,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in a)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=a[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,s=new mu(null,0,!1,!1,!0),n=r.get("text-allow-overlap"),a=r.get("icon-allow-overlap"),o=r.get("text-variable-anchor"),l="map"===r.get("text-rotation-alignment"),c="map"===r.get("text-pitch-alignment"),h="none"!==r.get("icon-text-fit"),u=new mu(null,0,n&&(a||!t.hasIconData()||r.get("icon-optional")),a&&(n||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const p=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};for(let i=0;i<t.symbolInstances.length;i++){const r=t.symbolInstances.get(i),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:a,crossTileID:d}=r;let m=this.opacities[d];e[d]?m=s:m||(m=u,this.opacities[d]=m),e[d]=!0;const f=r.numIconVertices>0,_=this.placedOrientations[r.crossTileID],g=_===Rl.vertical,y=_===Rl.horizontal||_===Rl.horizontalOnly;if(n>0||a>0){const e=Pu(m.text);p(t.text,n,g?ku:e),p(t.text,a,y?ku:e);const i=m.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||g?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||y?1:0);const s=this.variableOffsets[r.crossTileID];s&&this.markUsedJustification(t,s.anchor,r,_);const o=this.placedOrientations[r.crossTileID];o&&(this.markUsedJustification(t,"left",r,o),this.markUsedOrientation(t,o,r))}if(f){const e=Pu(m.icon),i=!(h&&r.verticalPlacedIconSymbolIndex&&g);r.placedIconSymbolIndex>=0&&(p(t.icon,r.numIconVertices,i?e:ku),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=m.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(p(t.icon,r.numVerticalIconVertices,i?ku:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=m.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const e=t.collisionArrays[i];if(e){let i=new k(0,0);if(e.textBox||e.verticalTextBox){let r=!0;if(o){const t=this.variableOffsets[d];t?(i=xu(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),l&&i._rotate(c?this.transform.angle:-this.transform.angle)):r=!1}e.textBox&&wu(t.textCollisionBox.collisionVertexArray,m.text.placed,!r||g,i.x,i.y),e.verticalTextBox&&wu(t.textCollisionBox.collisionVertexArray,m.text.placed,!r||y,i.x,i.y)}const r=Boolean(!y&&e.verticalIconBox);e.iconBox&&wu(t.iconCollisionBox.collisionVertexArray,m.icon.placed,r,h?i.x:0,h?i.y:0),e.verticalIconBox&&wu(t.iconCollisionBox.collisionVertexArray,m.icon.placed,!r,h?i.x:0,h?i.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.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.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function wu(t,e,i,r,s){t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0)}const Tu=Math.pow(2,25),Iu=Math.pow(2,24),zu=Math.pow(2,17),Su=Math.pow(2,16),Au=Math.pow(2,9),Eu=Math.pow(2,8),Cu=Math.pow(2,1);function Pu(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Tu+e*Iu+i*zu+e*Su+i*Au+e*Eu+i*Cu+e}const ku=0;class Mu{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,i,r,s){const n=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(n,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<n.length;)if(e.placeLayerBucketPart(n[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,s())return!0;return!1}}class Du{constructor(t,e,i,r,s,n,a,o){this.placement=new bu(t,e,n,a,o),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=P.now(),s=()=>{const t=P.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Mu(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}class Lu{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),s=r.key;this.indexedSymbolInstances[s]||(this.indexedSymbolInstances[s]=[]),this.indexedSymbolInstances[s].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(t,e){const i=.03125/Math.pow(2,e.canonical.z-this.tileID.canonical.z);return{x:Math.floor((e.canonical.x*aa+t.anchorX)*i),y:Math.floor((e.canonical.y*aa+t.anchorY)*i)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let s=0;s<t.length;s++){const n=t.get(s);if(n.crossTileID)continue;const a=this.indexedSymbolInstances[n.key];if(!a)continue;const o=this.getScaledCoordinates(n,e);for(const t of a)if(Math.abs(t.coord.x-o.x)<=r&&Math.abs(t.coord.y-o.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,n.crossTileID=t.crossTileID;break}}}}class Bu{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ru{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 i=this.indexes[t],r={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),r[s.tileID.key]=s}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){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;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const s=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in s){const n=s[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=s[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const s=e.symbolInstances.get(t);s.crossTileID||(s.crossTileID=i.generate(),r[s.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Lu(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const s in r)t[r[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[s]),delete r[s],e=!0)}return e}}class Fu{constructor(){this.layerIndexes={},this.crossTileIDs=new Bu,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Ru);let s=!1;const n={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),n[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(s=!0),s}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var Ou=As([{name:"a_pos",type:"Int16",components:2}]);class Vu extends dt{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=150,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const t in this._tiles){const e=this._tiles[t];e.textures.forEach((t=>t.destroy())),e.textures=[]}}update(t,e){this.sourceCache.update(t,e),this._renderableTilesKeys=[];for(const i of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e}))this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.posMatrix=new Float64Array(16),Oa(i.posMatrix,0,aa,0,aa,0,1),this._tiles[i.key]=new zh(i,this.tileSize))}removeOutdated(t){const e={};for(const t of this._renderableTilesKeys)e[t]=!0;for(this.renderHistory=this.renderHistory.filter(((t,e)=>this.renderHistory.indexOf(t)===e));this.renderHistory.length>this.renderHistorySize;){const i=this.sourceCache._tiles[this.renderHistory.shift()];i&&!e[i.tileID.key]&&(i.clearTextures(t),delete this.sourceCache._tiles[i.tileID.key])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const e={};for(const i of this._renderableTilesKeys){const r=this._tiles[i].tileID;if(r.canonical.equals(t.canonical)){const r=t.clone();r.posMatrix=new Float64Array(16),Oa(r.posMatrix,0,aa,0,aa,0,1),e[i]=r}else if(r.canonical.isChildOf(t.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=r.canonical.z-t.canonical.z,a=r.canonical.x-(r.canonical.x>>n<<n),o=r.canonical.y-(r.canonical.y>>n<<n),l=aa>>n;Oa(s.posMatrix,0,l,0,l,0,1),Ba(s.posMatrix,s.posMatrix,[-a*l,-o*l,0]),e[i]=s}else if(t.canonical.isChildOf(r.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=t.canonical.z-r.canonical.z,a=t.canonical.x-(t.canonical.x>>n<<n),o=t.canonical.y-(t.canonical.y>>n<<n),l=aa>>n;Oa(s.posMatrix,0,aa,0,aa,0,1),Ba(s.posMatrix,s.posMatrix,[a*l,o*l,0]),Ra(s.posMatrix,s.posMatrix,[1/2**n,1/2**n,0]),e[i]=s}}return e}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let s=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!s||!s.dem)&&e)for(;r>i.minzoom&&(!s||!s.dem);)s=this.sourceCache.getTileByID(t.scaledTo(r--).key);return s}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeLoaded>=t))}}class Uu{constructor(t,e,i){this.style=t,this.sourceCache=new Vu(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.elevationOffset="number"==typeof i.elevationOffset?i.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(t,e,i,r=8192){if(!(e>=0&&e<r&&i>=0&&i<r))return this.elevationOffset;let s=0;const n=this.getTerrainData(t);if(n.tile&&n.tile.dem){const t=function(t,e,i){var r=e[0],s=e[1];return t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t}([],[e/r*aa,i/r*aa],n.u_terrain_matrix),a=[t[0]*n.tile.dem.dim,t[1]*n.tile.dem.dim],o=[Math.floor(a[0]),Math.floor(a[1])],l=n.tile.dem.get(o[0],o[1]),c=n.tile.dem.get(o[0],o[1]+1),h=n.tile.dem.get(o[0]+1,o[1]),u=n.tile.dem.get(o[0]+1,o[1]+1);s=Re(Re(l,c,a[0]-o[0]),Re(h,u,a[0]-o[0]),a[1]-o[1])}return s}rememberForRerender(t,e){for(const i in this.sourceCache._tiles){const r=this.sourceCache._tiles[i];(r.tileID.equals(e)||r.tileID.isChildOf(e))&&(t===this.sourceCache.sourceCache.id&&(r.timeLoaded=Date.now()),this._rerender[t]=this._rerender[t]||{},this._rerender[t][r.tileID.key]=!0)}}needsRerender(t,e){return this._rerender[t]&&this._rerender[t][e.key]}clearRerenderCache(){this._rerender={}}getElevation(t,e,i,r=8192){return(this.getDEMElevation(t,e,i,r)+this.elevationOffset)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const t=this.style.map.painter.context,e=new Ja({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new kc(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new kc(t,new Ja({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Ma([])}const e=this.sourceCache.getSourceTile(t,!0);if(e&&e.dem&&(!e.demTexture||e.needsTerrainPrepare)){const t=this.style.map.painter.context;e.demTexture=this.style.map.painter.getTileTexture(e.dem.stride),e.demTexture?e.demTexture.update(e.dem.getPixels(),{premultiply:!1}):e.demTexture=new kc(t,e.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),e.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),e.needsTerrainPrepare=!1}const i=e&&e+e.tileID.key+t.key;if(i&&!this._demMatrixCache[i]){const i=this.sourceCache.sourceCache._source.maxzoom;let r=t.canonical.z-e.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=i?r=t.canonical.z-i:v("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=t.canonical.x-(t.canonical.x>>r<<r),n=t.canonical.y-(t.canonical.y>>r<<r),a=function(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}(new Float64Array(16),[1/(aa<<r),1/(aa<<r),0]);Ba(a,a,[s*aa,n*aa,0]),this._demMatrixCache[t.key]={matrix:a,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:e&&e.dem&&e.dem.dim||1,u_terrain_matrix:i?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:e&&e.dem&&e.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_offset:this.elevationOffset,u_terrain_exaggeration:this.exaggeration,texture:(e&&e.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:e}}getRTTFramebuffer(){const t=this.style.map.painter;if(!this._rttFramebuffer){const e=this.sourceCache.tileSize*this.qualityFactor;this._rttFramebuffer=t.context.createFramebuffer(e,e,!0),this._rttFramebuffer.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,e,e))}return this._rttFramebuffer}getFramebuffer(t){const e=this.style.map.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new kc(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new kc(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.style.map.painter.context;if(this._coordsTexture)return this._coordsTexture;const e=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,i=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,i+=4)e[i+0]=255&r,e[i+1]=255&t,e[i+2]=r>>8<<4|t>>8,e[i+3]=0;const i=new Ja({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(e.buffer)),r=new kc(t,i,t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){const e=new Uint8Array(4),i=this.style.map.painter,r=i.context,s=r.gl;r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),s.readPixels(t.x,i.height/devicePixelRatio-t.y-1,1,1,s.RGBA,s.UNSIGNED_BYTE,e),r.bindFramebuffer.set(null);const n=e[0]+(e[2]>>4<<8),a=e[1]+((15&e[2])<<8),o=this.coordsIndex[255-e[3]],l=o&&this.sourceCache.getTileByID(o);if(!l)return null;const c=this._coordsTextureSize,h=(1<<l.tileID.canonical.z)*c;return new th((l.tileID.canonical.x*c+n)/h,(l.tileID.canonical.y*c+a)/h,this.getElevation(l.tileID,n,a,c))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.style.map.painter.context,e=new ln,i=new Tn,r=this.meshSize,s=aa/r,n=r*r;for(let t=0;t<=r;t++)for(let i=0;i<=r;i++)e.emplaceBack(i*s,t*s);for(let t=0;t<n;t+=r+1)for(let e=0;e<r;e++)i.emplaceBack(e+t,r+e+t+1,r+e+t+2),i.emplaceBack(e+t,r+e+t+2,e+t+1);return this._mesh={indexBuffer:t.createIndexBuffer(i),vertexBuffer:t.createVertexBuffer(e,Ou.members),segments:En.simpleSegment(0,0,e.length,i.length)},this._mesh}}const Nu=(t,e)=>Mr(t,e&&e.filter((t=>"source.canvas"!==t.identifier))),qu=p(Vh,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),$u=p(Vh,["setCenter","setZoom","setBearing","setPitch"]),ju=function(){const t={},e=mt.$version;for(const i in mt.$root){const r=mt.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t}();class Zu extends dt{constructor(t,e={}){super(),this.map=t,this.dispatcher=new $c(Bh(),this),this.imageManager=new Dc,this.imageManager.setEventedParent(this),this.glyphManager=new Fc(t._requestManager,e.localIdeographFontFamily),this.lineAtlas=new Nc(256,512),this.crossTileSymbolIndex=new Fu,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new Vr,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Y());const i=this;this._rtlTextPluginCallback=Zu.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,e)=>{if(es(t),e&&e.every((t=>t)))for(const t in i.sourceCaches)i.sourceCaches[t].reload()}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,e={}){this.fire(new ut("dataloading",{dataType:"style"}));const i="boolean"!=typeof e.validate||e.validate,r=this.map._requestManager.transformRequest(t,H.Style);this._request=tt(r,((t,e)=>{this._request=null,t?this.fire(new pt(t)):e&&this._load(e,i)}))}loadJSON(t,e={}){this.fire(new ut("dataloading",{dataType:"style"})),this._request=P.frame((()=>{this._request=null,this._load(t,!1!==e.validate)}))}loadEmpty(){this.fire(new ut("dataloading",{dataType:"style"})),this._load(ju,!1)}_load(t,e){if(e&&Nu(this,Er(t)))return;this._loaded=!0,this.stylesheet=t;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});t.sprite?this._loadSprite(t.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(t.glyphs);const i=Oh(this.stylesheet.layers);this._order=i.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let t of i)t=Pc(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Uc(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new ut("data",{dataType:"style"})),this.fire(new ut("style.load"))}_loadSprite(t){this._spriteRequest=function(t,e,i,r){let s,n,a;const o=i>1?"@2x":"";let l=tt(e.transformRequest(e.normalizeSpriteURL(t,o,".json"),H.SpriteJSON),((t,e)=>{l=null,a||(a=t,s=e,h())})),c=at(e.transformRequest(e.normalizeSpriteURL(t,o,".png"),H.SpriteImage),((t,e)=>{c=null,a||(a=t,n=e,h())}));function h(){if(a)r(a);else if(s&&n){const t=P.getImageData(n),e={};for(const i in s){const{width:r,height:n,x:a,y:o,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:p}=s[i],d=new Ja({width:r,height:n});Ja.copy(t,d,{x:a,y:o},{x:0,y:0},{width:r,height:n}),e[i]={data:d,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:p}}r(null,e)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,this.map.getPixelRatio(),((t,e)=>{if(this._spriteRequest=null,t)this.fire(new pt(t));else if(e)for(const t in e)this.imageManager.addImage(t,e[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new ut("data",{dataType:"style"}))}))}_validateLayer(t){const e=this.sourceCaches[t.source];if(!e)return;const i=t.sourceLayer;if(!i)return;const r=e.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new pt(new Error(`Source layer "${i}" does not exist on source "${r.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()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.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 e=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const i={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];i[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in i){const e=this.sourceCaches[t];i[t]!==e.used&&e.fire(new ut("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.z=t.zoom,e&&this.fire(new ut("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={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(t){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),t){const e=this.sourceCaches[t.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);this.terrain=new Uu(this,e,t),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=t=>{t.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=e=>{e.tile&&(e.sourceId===t.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(e.sourceId,e.tile.tileID)):"geojson"===e.source.type&&this.terrain.rememberForRerender(e.sourceId,e.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new ut("terrain",{terrain:t}))}setState(t){if(this._checkLoaded(),Nu(this,Er(t)))return!1;(t=y(t)).layers=Oh(t.layers);const e=function(t,e){if(!t)return[{command:Vh.setStyle,args:[e]}];let i=[];try{if(!n(t.version,e.version))return[{command:Vh.setStyle,args:[e]}];n(t.center,e.center)||i.push({command:Vh.setCenter,args:[e.center]}),n(t.zoom,e.zoom)||i.push({command:Vh.setZoom,args:[e.zoom]}),n(t.bearing,e.bearing)||i.push({command:Vh.setBearing,args:[e.bearing]}),n(t.pitch,e.pitch)||i.push({command:Vh.setPitch,args:[e.pitch]}),n(t.sprite,e.sprite)||i.push({command:Vh.setSprite,args:[e.sprite]}),n(t.glyphs,e.glyphs)||i.push({command:Vh.setGlyphs,args:[e.glyphs]}),n(t.transition,e.transition)||i.push({command:Vh.setTransition,args:[e.transition]}),n(t.light,e.light)||i.push({command:Vh.setLight,args:[e.light]});const r={},s=[];!function(t,e,i,r){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||Nh(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?n(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&$h(t,e,s)?i.push({command:Vh.setGeoJSONSourceData,args:[s,e[s].data]}):qh(s,e,i,r)):Uh(s,e,i))}(t.sources,e.sources,s,r);const a=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:Vh.removeLayer,args:[t.id]}):a.push(t)})),i=i.concat(s),function(t,e,i){e=e||[];const r=(t=t||[]).map(Zh),s=e.map(Zh),a=t.reduce(Gh,{}),o=e.reduce(Gh,{}),l=r.slice(),c=Object.create(null);let h,u,p,d,m,f,_;for(h=0,u=0;h<r.length;h++)p=r[h],Object.prototype.hasOwnProperty.call(o,p)?u++:(i.push({command:Vh.removeLayer,args:[p]}),l.splice(l.indexOf(p,u),1));for(h=0,u=0;h<s.length;h++)p=s[s.length-1-h],l[l.length-1-h]!==p&&(Object.prototype.hasOwnProperty.call(a,p)?(i.push({command:Vh.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-u),1)):u++,f=l[l.length-h],i.push({command:Vh.addLayer,args:[o[p],f]}),l.splice(l.length-h,0,p),c[p]=!0);for(h=0;h<s.length;h++)if(p=s[h],d=a[p],m=o[p],!c[p]&&!n(d,m))if(n(d.source,m.source)&&n(d["source-layer"],m["source-layer"])&&n(d.type,m.type)){for(_ in jh(d.layout,m.layout,i,p,null,Vh.setLayoutProperty),jh(d.paint,m.paint,i,p,null,Vh.setPaintProperty),n(d.filter,m.filter)||i.push({command:Vh.setFilter,args:[p,m.filter]}),n(d.minzoom,m.minzoom)&&n(d.maxzoom,m.maxzoom)||i.push({command:Vh.setLayerZoomRange,args:[p,m.minzoom,m.maxzoom]}),d)Object.prototype.hasOwnProperty.call(d,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?jh(d[_],m[_],i,p,_.slice(6),Vh.setPaintProperty):n(d[_],m[_])||i.push({command:Vh.setLayerProperty,args:[p,_,m[_]]}));for(_ in m)Object.prototype.hasOwnProperty.call(m,_)&&!Object.prototype.hasOwnProperty.call(d,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?jh(d[_],m[_],i,p,_.slice(6),Vh.setPaintProperty):n(d[_],m[_])||i.push({command:Vh.setLayerProperty,args:[p,_,m[_]]}))}else i.push({command:Vh.removeLayer,args:[p]}),f=l[l.lastIndexOf(p)+1],i.push({command:Vh.addLayer,args:[m,f]})}(a,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:Vh.setStyle,args:[e]}]}return i}(this.serialize(),t).filter((t=>!(t.command in $u)));if(0===e.length)return!1;const i=e.filter((t=>!(t.command in qu)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((t=>t.command)).join(", ")}.`);return e.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=t,!0}addImage(t,e){if(this.getImage(t))return this.fire(new pt(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,e),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 pt(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("setImages",this._availableImages),this.fire(new ut("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(Er.source,`sources.${t}`,e,null,i))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const r=this.sourceCaches[t]=new Eh(t,e,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:this.loaded(),source:r.serialize(),sourceId:t}))),r.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 e in this._layers)if(this._layers[e].source===t)return this.fire(new pt(new Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));const e=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],e.fire(new ut("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),e.setEventedParent(null),e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,e,i={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new pt(new Error(`Layer "${r}" already exists on this map.`)));let s;if("custom"===t.type){if(Nu(this,function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e}(t)))return;s=Pc(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=u(t=y(t),{source:r})),this._validate(Er.layer,`layers.${r}`,t,{arrayIndex:-1},i))return;s=Pc(t),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[s.id]=s.serialize()}const n=e?this._order.indexOf(e):this._order.length;if(e&&-1===n)this.fire(new pt(new Error(`Cannot add layer "${r}" before non-existing layer "${e}".`)));else{if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=s,this._removedLayers[r]&&s.source&&"custom"!==s.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.sourceCaches[s.source].pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map)}}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new pt(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;const i=this._order.indexOf(t);this._order.splice(i,1);const r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new pt(new Error(`Cannot move layer "${t}" before non-existing layer "${e}".`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const e=this._layers[t];if(!e)return void this.fire(new pt(new Error(`Cannot remove non-existing layer "${t}".`)));e.setEventedParent(null);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,e,i){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===e&&r.maxzoom===i||(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new pt(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,e,i={}){this._checkLoaded();const r=this.getLayer(t);if(r){if(!n(r.filter,e))return null==e?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Er.filter,`layers.${r.id}.filter`,e,null,i)||(r.filter=y(e),this._updateLayer(r)))}else this.fire(new pt(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return y(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?n(s.getLayoutProperty(e),i)||(s.setLayoutProperty(e,i,r),this._updateLayer(s)):this.fire(new pt(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){const i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new pt(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?n(s.getPaintProperty(e),i)||(s.setPaintProperty(e,i,r)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new pt(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();const i=t.source,r=t.sourceLayer,s=this.sourceCaches[i];if(void 0===s)return void this.fire(new pt(new Error(`The source '${i}' does not exist in the map's style.`)));const n=s.getSource().type;"geojson"===n&&r?this.fire(new pt(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==n||r?(void 0===t.id&&this.fire(new pt(new Error("The feature id parameter must be provided."))),s.setFeatureState(r,t.id,e)):this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,e){this._checkLoaded();const i=t.source,r=this.sourceCaches[i];if(void 0===r)return void this.fire(new pt(new Error(`The source '${i}' does not exist in the map's style.`)));const s=r.getSource().type,n="vector"===s?t.sourceLayer:void 0;"vector"!==s||n?e&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new pt(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,t.id,e):this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const e=t.source,i=t.sourceLayer,r=this.sourceCaches[e];if(void 0!==r)return"vector"!==r.getSource().type||i?(void 0===t.id&&this.fire(new pt(new Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id)):void this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new pt(new Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return u({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return g({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:_(this.sourceCaches,(t=>t.serialize())),layers:this._serializeLayers(this._order)},(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._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){const n=this._order[s];if(e(n)){i[n]=s;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let n=this._order.length-1;n>=0;n--){const a=this._order[n];if(e(a))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<n)break;s.push(e),r.pop()}else for(const e of t){const t=e[a];if(t)for(const e of t)s.push(e.feature)}}return s}queryRenderedFeatures(t,e,i){e&&e.filter&&this._validate(Er.filter,"queryRenderedFeatures.filter",e.filter,null,e);const r={};if(e&&e.layers){if(!Array.isArray(e.layers))return this.fire(new pt(new Error("parameters.layers must be an Array."))),[];for(const t of e.layers){const e=this._layers[t];if(!e)return this.fire(new pt(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}const s=[];e.availableImages=this._availableImages;for(const n in this.sourceCaches)e.layers&&!r[n]||s.push(yh(this.sourceCaches[n],this._layers,this._serializedLayers,t,e,i));return this.placement&&s.push(function(t,e,i,r,s,n,a){const o={},l=n.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(a[t]);c.sort(xh);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,s.filter,s.layers,s.availableImages,t);for(const t in r){const e=o[t]=o[t]||[],s=r[t];s.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of s)e.push(t)}}for(const e in o)o[e].forEach((r=>{const s=r.feature,n=i[t[e].source].getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=n}));return o}(this._layers,this._serializedLayers,this.sourceCaches,t,e,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(t,e){e&&e.filter&&this._validate(Er.filter,"querySourceFeatures.filter",e.filter,null,e);const i=this.sourceCaches[t];return i?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],s={};for(let t=0;t<i.length;t++){const n=i[t],a=n.tileID.canonical.key;s[a]||(s[a]=!0,n.querySourceFeatures(r,e))}return r}(i,e):[]}addSourceType(t,e,i){return Zu.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Zu.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const e in t)if(!n(t[e],i[e])){r=!0;break}if(!r)return;const s={now:P.now(),transition:u({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(s)}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&Nu(this,t.call(Er,u({key:e,style:this.serialize(),value:i,styleSpec:mt},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),rs.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,e,i,r,s=!1){let n=!1,a=!1;const o={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!o[i.source]){const t=this.sourceCaches[i.source];o[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,o[i.source],t.center.lng);n=n||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((s=s||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(P.now(),t.zoom))&&(this.pauseablePlacement=new Du(t,this.terrain,this._order,s,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(P.now()),a=!0),n&&this.pauseablePlacement.placement.setStale()),a||n)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,o[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(P.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(t,e,i){return Q(e,i)}}Zu.getSourceType=function(t){return _h[t]},Zu.setSourceType=function(t,e){_h[t]=e},Zu.registerForPluginStateChange=function(t){return t({pluginStatus:Qr,pluginURL:ts}),rs.on("pluginStateChange",t),t};var Gu="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}",Xu={prelude:Wu("#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","#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_offset;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_offset)*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:Wu("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}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:Wu("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}","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);}"),circle:Wu("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}","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);}"),clippingMask:Wu("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Wu("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}","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;}"),heatmapTexture:Wu("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}","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;}"),collisionBox:Wu("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;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Wu("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;}","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);}"),debug:Wu("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);}","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);}"),fill:Wu("#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}","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);}"),fillOutline:Wu("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}","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;}"),fillOutlinePattern:Wu("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}","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;}"),fillPattern:Wu("#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}","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);}"),fillExtrusion:Wu("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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;}"),fillExtrusionPattern:Wu("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}","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 baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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;}"),hillshadePrepare:Wu("#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}","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;}"),hillshade:Wu("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}","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;}"),line:Wu("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}","\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);}"),lineGradient:Wu("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}","\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);}"),linePattern:Wu("#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}","\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;}"),lineSDF:Wu("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}","\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);}"),raster:Wu("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}","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;}"),symbolIcon:Wu("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}","const float PI=3.141592653589793;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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);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));}"),symbolSDF:Wu("#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 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}","const float PI=3.141592653589793;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 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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;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);}"),symbolTextAndIcon:Wu("#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}","const float PI=3.141592653589793;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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;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);}"),terrain:Wu("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",Gu),terrainDepth:Wu("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);}",Gu),terrainCoords:Wu("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);}",Gu)};function Wu(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=n?n.concat(s):s,o={};return{fragmentSource:t=t.replace(i,((t,e,i,r,s)=>(o[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,s)=>{const n="float"===r?"vec2":"vec4",a=s.match(/color/)?"color":n;return o[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class Hu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,s,n,a,o,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===s&&this.boundVertexOffset===n&&this.boundDynamicVertexBuffer===a&&this.boundDynamicVertexBuffer2===o&&this.boundDynamicVertexBuffer3===l?(t.bindVertexArrayOES.set(this.vao),a&&a.bind(),s&&s.dynamicDraw&&s.bind(),o&&o.bind(),l&&l.bind()):this.freshBind(e,i,r,s,n,a,o,l)}freshBind(t,e,i,r,s,n,a,o){let l;const c=t.numAttributes,h=this.context,u=h.gl;if(h.extVertexArrayObject)this.vao&&this.destroy(),this.vao=h.extVertexArrayObject.createVertexArrayOES(),h.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=s,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=a,this.boundDynamicVertexBuffer3=o;else{l=h.currentNumAttributes||0;for(let t=c;t<l;t++)u.disableVertexAttribArray(t)}e.enableAttributes(u,t);for(const e of i)e.enableAttributes(u,t);n&&n.enableAttributes(u,t),a&&a.enableAttributes(u,t),o&&o.enableAttributes(u,t),e.bind(),e.setVertexAttribPointers(u,t,s);for(const e of i)e.bind(),e.setVertexAttribPointers(u,t,s);n&&(n.bind(),n.setVertexAttribPointers(u,t,s)),r&&r.bind(),a&&(a.bind(),a.setVertexAttribPointers(u,t,s)),o&&(o.bind(),o.setVertexAttribPointers(u,t,s)),h.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Ku(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class Yu{constructor(t,e,i,r,s,n,a){const o=t.gl;this.program=o.createProgram();const l=Ku(i.staticAttributes),c=r?r.getBinderAttributes():[],h=l.concat(c),u=Xu.prelude.staticUniforms?Ku(Xu.prelude.staticUniforms):[],p=i.staticUniforms?Ku(i.staticUniforms):[],d=r?r.getBinderUniforms():[],m=u.concat(p).concat(d),f=[];for(const t of m)f.indexOf(t)<0&&f.push(t);const _=r?r.defines():[];n&&_.push("#define OVERDRAW_INSPECTOR;"),a&&_.push("#define TERRAIN3D;");const g=_.concat(Xu.prelude.fragmentSource,i.fragmentSource).join("\n"),y=_.concat(Xu.prelude.vertexSource,i.vertexSource).join("\n"),x=o.createShader(o.FRAGMENT_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(x,g),o.compileShader(x),o.attachShader(this.program,x);const v=o.createShader(o.VERTEX_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(v,y),o.compileShader(v),o.attachShader(this.program,v),this.attributes={};const b={};this.numAttributes=h.length;for(let t=0;t<this.numAttributes;t++)h[t]&&(o.bindAttribLocation(this.program,t,h[t]),this.attributes[h[t]]=t);o.linkProgram(this.program),o.deleteShader(v),o.deleteShader(x);for(let t=0;t<f.length;t++){const e=f[t];if(e&&!b[e]){const t=o.getUniformLocation(this.program,e);t&&(b[e]=t)}}this.fixedUniforms=s(t,b),this.terrainUniforms=((t,e)=>({u_depth:new qn(t,e.u_depth),u_terrain:new qn(t,e.u_terrain),u_terrain_dim:new $n(t,e.u_terrain_dim),u_terrain_matrix:new Hn(t,e.u_terrain_matrix),u_terrain_unpack:new Gn(t,e.u_terrain_unpack),u_terrain_offset:new $n(t,e.u_terrain_offset),u_terrain_exaggeration:new $n(t,e.u_terrain_exaggeration)}))(t,b),this.binderUniforms=r?r.getUniforms(t,b):[]}draw(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(s),t.setCullFace(n),o){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,o.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,o.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(o[t])}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(a[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});const x={[y.LINES]:2,[y.TRIANGLES]:3,[y.LINE_STRIP]:1}[e];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[l]||(r[l]=new Hu)).bind(t,this,c,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,f,_,g),y.drawElements(e,i.primitiveLength*x,y.UNSIGNED_SHORT,i.primitiveOffset*x*2)}}}function Ju(t,e,i){const r=1/pu(i,1,e.transform.tileZoom),s=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,a=n*(i.tileID.canonical.x+i.tileID.wrap*s),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}const Qu=(t,e,i,r)=>{const s=e.style.light,n=s.properties.get("position"),a=[n.x,n.y,n.z],o=function(){var t=new Pa(9);return Pa!=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}();"viewport"===s.properties.get("anchor")&&function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(o,-e.transform.angle),function(t,e,i){var r=e[0],s=e[1],n=e[2];t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8]}(a,a,o);const l=s.properties.get("color");return{u_matrix:t,u_lightpos:a,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r}},tp=(t,e,i,r,s,n,a)=>u(Qu(t,e,i,r),Ju(n,e,a),{u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8}),ep=t=>({u_matrix:t}),ip=(t,e,i,r)=>u(ep(t),Ju(i,e,r)),rp=(t,e)=>({u_matrix:t,u_world:e}),sp=(t,e,i,r,s)=>u(ip(t,e,i,r),{u_world:s}),np=(t,e,i,r)=>{const s=t.transform;let n,a;if("map"===r.paint.get("circle-pitch-alignment")){const t=pu(i,1,s.zoom);n=!0,a=[t,t]}else n=!1,a=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+n,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},ap=(t,e,i)=>{const r=pu(i,1,e.zoom),s=Math.pow(2,e.zoom-i.tileID.overscaledZ),n=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*s),e.pixelsToGLUnits[1]/(r*s)],u_overscale_factor:n}},op=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),lp=t=>({u_matrix:t}),cp=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:pu(e,1,i),u_intensity:r});function hp(t,e){const i=Math.pow(2,e.canonical.z),r=e.canonical.y;return[new th(0,r/i).toLngLat().lat,new th(0,(r+1)/i).toLngLat().lat]}const up=(t,e,i,r)=>{const s=t.transform;return{u_matrix:_p(t,e,i,r),u_ratio:1/pu(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},pp=(t,e,i,r,s)=>u(up(t,e,i,s),{u_image:0,u_image_height:r}),dp=(t,e,i,r,s)=>{const n=t.transform,a=fp(e,n);return{u_matrix:_p(t,e,i,s),u_texsize:e.imageAtlasTexture.size,u_ratio:1/pu(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},mp=(t,e,i,r,s,n)=>{const a=t.lineAtlas,o=fp(e,t.transform),l="round"===i.layout.get("line-cap"),c=a.getDash(r.from,l),h=a.getDash(r.to,l),p=c.width*s.fromScale,d=h.width*s.toScale;return u(up(t,e,i,n),{u_patternscale_a:[o/p,-c.height/2],u_patternscale_b:[o/d,-h.height/2],u_sdfgamma:a.width/(256*Math.min(p,d)*t.pixelRatio)/2,u_image:0,u_tex_y_a:c.y,u_tex_y_b:h.y,u_mix:s.t})};function fp(t,e){return 1/pu(t,1,e.tileZoom)}function _p(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const gp=(t,e,i,r,s)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(a=s.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(n=s.paint.get("raster-contrast"),n>0?1/(1-n):1+n),u_spin_weights:yp(s.paint.get("raster-hue-rotate"))};var n,a};function yp(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const xp=(t,e,i,r,s,n,a,o,l,c)=>{const h=s.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:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:o,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},vp=(t,e,i,r,s,n,a,o,l,c,h)=>{const p=s.transform;return u(xp(t,e,i,r,s,n,a,o,l,c),{u_gamma_scale:r?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+h})},bp=(t,e,i,r,s,n,a,o,l,c)=>u(vp(t,e,i,r,s,n,a,o,!0,l,!0),{u_texsize_icon:c,u_texture_icon:1}),wp=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),Tp=(t,e,i,r,s,n)=>u(function(t,e,i,r){const s=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:a,height:o}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[a,o],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/pu(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,n,i,s),{u_matrix:t,u_opacity:e}),Ip={fillExtrusion:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_lightpos:new Zn(t,e.u_lightpos),u_lightintensity:new $n(t,e.u_lightintensity),u_lightcolor:new Zn(t,e.u_lightcolor),u_vertical_gradient:new $n(t,e.u_vertical_gradient),u_opacity:new $n(t,e.u_opacity)}),fillExtrusionPattern:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_lightpos:new Zn(t,e.u_lightpos),u_lightintensity:new $n(t,e.u_lightintensity),u_lightcolor:new Zn(t,e.u_lightcolor),u_vertical_gradient:new $n(t,e.u_vertical_gradient),u_height_factor:new $n(t,e.u_height_factor),u_image:new qn(t,e.u_image),u_texsize:new jn(t,e.u_texsize),u_pixel_coord_upper:new jn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new jn(t,e.u_pixel_coord_lower),u_scale:new Zn(t,e.u_scale),u_fade:new $n(t,e.u_fade),u_opacity:new $n(t,e.u_opacity)}),fill:(t,e)=>({u_matrix:new Hn(t,e.u_matrix)}),fillPattern:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_texsize:new jn(t,e.u_texsize),u_pixel_coord_upper:new jn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new jn(t,e.u_pixel_coord_lower),u_scale:new Zn(t,e.u_scale),u_fade:new $n(t,e.u_fade)}),fillOutline:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_world:new jn(t,e.u_world)}),fillOutlinePattern:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_world:new jn(t,e.u_world),u_image:new qn(t,e.u_image),u_texsize:new jn(t,e.u_texsize),u_pixel_coord_upper:new jn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new jn(t,e.u_pixel_coord_lower),u_scale:new Zn(t,e.u_scale),u_fade:new $n(t,e.u_fade)}),circle:(t,e)=>({u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_scale_with_map:new qn(t,e.u_scale_with_map),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_extrude_scale:new jn(t,e.u_extrude_scale),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_matrix:new Hn(t,e.u_matrix)}),collisionBox:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_pixels_to_tile_units:new $n(t,e.u_pixels_to_tile_units),u_extrude_scale:new jn(t,e.u_extrude_scale),u_overscale_factor:new $n(t,e.u_overscale_factor)}),collisionCircle:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_inv_matrix:new Hn(t,e.u_inv_matrix),u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_viewport_size:new jn(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new Xn(t,e.u_color),u_matrix:new Hn(t,e.u_matrix),u_overlay:new qn(t,e.u_overlay),u_overlay_scale:new $n(t,e.u_overlay_scale)}),clippingMask:(t,e)=>({u_matrix:new Hn(t,e.u_matrix)}),heatmap:(t,e)=>({u_extrude_scale:new $n(t,e.u_extrude_scale),u_intensity:new $n(t,e.u_intensity),u_matrix:new Hn(t,e.u_matrix)}),heatmapTexture:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_world:new jn(t,e.u_world),u_image:new qn(t,e.u_image),u_color_ramp:new qn(t,e.u_color_ramp),u_opacity:new $n(t,e.u_opacity)}),hillshade:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_latrange:new jn(t,e.u_latrange),u_light:new jn(t,e.u_light),u_shadow:new Xn(t,e.u_shadow),u_highlight:new Xn(t,e.u_highlight),u_accent:new Xn(t,e.u_accent)}),hillshadePrepare:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_dimension:new jn(t,e.u_dimension),u_zoom:new $n(t,e.u_zoom),u_unpack:new Gn(t,e.u_unpack)}),line:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_ratio:new $n(t,e.u_ratio),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_units_to_pixels:new jn(t,e.u_units_to_pixels)}),lineGradient:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_ratio:new $n(t,e.u_ratio),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_units_to_pixels:new jn(t,e.u_units_to_pixels),u_image:new qn(t,e.u_image),u_image_height:new $n(t,e.u_image_height)}),linePattern:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_texsize:new jn(t,e.u_texsize),u_ratio:new $n(t,e.u_ratio),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_image:new qn(t,e.u_image),u_units_to_pixels:new jn(t,e.u_units_to_pixels),u_scale:new Zn(t,e.u_scale),u_fade:new $n(t,e.u_fade)}),lineSDF:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_ratio:new $n(t,e.u_ratio),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_units_to_pixels:new jn(t,e.u_units_to_pixels),u_patternscale_a:new jn(t,e.u_patternscale_a),u_patternscale_b:new jn(t,e.u_patternscale_b),u_sdfgamma:new $n(t,e.u_sdfgamma),u_image:new qn(t,e.u_image),u_tex_y_a:new $n(t,e.u_tex_y_a),u_tex_y_b:new $n(t,e.u_tex_y_b),u_mix:new $n(t,e.u_mix)}),raster:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_tl_parent:new jn(t,e.u_tl_parent),u_scale_parent:new $n(t,e.u_scale_parent),u_buffer_scale:new $n(t,e.u_buffer_scale),u_fade_t:new $n(t,e.u_fade_t),u_opacity:new $n(t,e.u_opacity),u_image0:new qn(t,e.u_image0),u_image1:new qn(t,e.u_image1),u_brightness_low:new $n(t,e.u_brightness_low),u_brightness_high:new $n(t,e.u_brightness_high),u_saturation_factor:new $n(t,e.u_saturation_factor),u_contrast_factor:new $n(t,e.u_contrast_factor),u_spin_weights:new Zn(t,e.u_spin_weights)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new $n(t,e.u_size_t),u_size:new $n(t,e.u_size),u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_pitch:new $n(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new $n(t,e.u_aspect_ratio),u_fade_change:new $n(t,e.u_fade_change),u_matrix:new Hn(t,e.u_matrix),u_label_plane_matrix:new Hn(t,e.u_label_plane_matrix),u_coord_matrix:new Hn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new jn(t,e.u_texsize),u_texture:new qn(t,e.u_texture)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new $n(t,e.u_size_t),u_size:new $n(t,e.u_size),u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_pitch:new $n(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new $n(t,e.u_aspect_ratio),u_fade_change:new $n(t,e.u_fade_change),u_matrix:new Hn(t,e.u_matrix),u_label_plane_matrix:new Hn(t,e.u_label_plane_matrix),u_coord_matrix:new Hn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new jn(t,e.u_texsize),u_texture:new qn(t,e.u_texture),u_gamma_scale:new $n(t,e.u_gamma_scale),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_is_halo:new qn(t,e.u_is_halo)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new $n(t,e.u_size_t),u_size:new $n(t,e.u_size),u_camera_to_center_distance:new $n(t,e.u_camera_to_center_distance),u_pitch:new $n(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new $n(t,e.u_aspect_ratio),u_fade_change:new $n(t,e.u_fade_change),u_matrix:new Hn(t,e.u_matrix),u_label_plane_matrix:new Hn(t,e.u_label_plane_matrix),u_coord_matrix:new Hn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new jn(t,e.u_texsize),u_texsize_icon:new jn(t,e.u_texsize_icon),u_texture:new qn(t,e.u_texture),u_texture_icon:new qn(t,e.u_texture_icon),u_gamma_scale:new $n(t,e.u_gamma_scale),u_device_pixel_ratio:new $n(t,e.u_device_pixel_ratio),u_is_halo:new qn(t,e.u_is_halo)}),background:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_opacity:new $n(t,e.u_opacity),u_color:new Xn(t,e.u_color)}),backgroundPattern:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_opacity:new $n(t,e.u_opacity),u_image:new qn(t,e.u_image),u_pattern_tl_a:new jn(t,e.u_pattern_tl_a),u_pattern_br_a:new jn(t,e.u_pattern_br_a),u_pattern_tl_b:new jn(t,e.u_pattern_tl_b),u_pattern_br_b:new jn(t,e.u_pattern_br_b),u_texsize:new jn(t,e.u_texsize),u_mix:new $n(t,e.u_mix),u_pattern_size_a:new jn(t,e.u_pattern_size_a),u_pattern_size_b:new jn(t,e.u_pattern_size_b),u_scale_a:new $n(t,e.u_scale_a),u_scale_b:new $n(t,e.u_scale_b),u_pixel_coord_upper:new jn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new jn(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new $n(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_texture:new qn(t,e.u_texture)}),terrainDepth:(t,e)=>({u_matrix:new Hn(t,e.u_matrix)}),terrainCoords:(t,e)=>({u_matrix:new Hn(t,e.u_matrix),u_texture:new qn(t,e.u_texture),u_terrain_coords_id:new $n(t,e.u_terrain_coords_id)})};class zp{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Sp={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ap{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const s=this.attributes[r],n=e.attributes[s.name];void 0!==n&&t.vertexAttribPointer(n,s.components,t[Sp[s.type]],!1,this.itemSize,s.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ep{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Cp extends Ep{getDefault(){return jt.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Pp extends Ep{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class kp extends Ep{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Mp extends Ep{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Dp extends Ep{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Lp extends Ep{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Bp extends Ep{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Rp extends Ep{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Fp extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class Op extends Ep{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Vp extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class Up extends Ep{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Np extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class qp extends Ep{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class $p extends Ep{getDefault(){return jt.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class jp extends Ep{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Zp extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Gp extends Ep{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Xp extends Ep{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Wp extends Ep{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Hp extends Ep{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Kp extends Ep{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Yp extends Ep{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Jp extends Ep{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Qp extends Ep{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class td extends Ep{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ed extends Ep{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class id extends Ep{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class rd extends Ep{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class sd extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class nd extends Ep{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class ad extends Ep{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class od extends ad{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class ld extends ad{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class cd{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const s=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new od(t,s),r&&(this.depthAttachment=new ld(t,s))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class hd{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}hd.Replace=[1,0],hd.disabled=new hd(hd.Replace,jt.transparent,[!1,!1,!1,!1]),hd.unblended=new hd(hd.Replace,jt.transparent,[!0,!0,!0,!0]),hd.alphaBlended=new hd([1,771],jt.transparent,[!0,!0,!0,!0]);class ud{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Cp(this),this.clearDepth=new Pp(this),this.clearStencil=new kp(this),this.colorMask=new Mp(this),this.depthMask=new Dp(this),this.stencilMask=new Lp(this),this.stencilFunc=new Bp(this),this.stencilOp=new Rp(this),this.stencilTest=new Fp(this),this.depthRange=new Op(this),this.depthTest=new Vp(this),this.depthFunc=new Up(this),this.blend=new Np(this),this.blendFunc=new qp(this),this.blendColor=new $p(this),this.blendEquation=new jp(this),this.cullFace=new Zp(this),this.cullFaceSide=new Gp(this),this.frontFace=new Xp(this),this.program=new Wp(this),this.activeTexture=new Hp(this),this.viewport=new Kp(this),this.bindFramebuffer=new Yp(this),this.bindRenderbuffer=new Jp(this),this.bindTexture=new Qp(this),this.bindVertexBuffer=new td(this),this.bindElementBuffer=new ed(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new id(this),this.pixelStoreUnpack=new rd(this),this.pixelStoreUnpackPremultiplyAlpha=new sd(this),this.pixelStoreUnpackFlipY=new nd(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new zp(this,t,e)}createVertexBuffer(t,e,i){return new Ap(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,s=r.createRenderbuffer();return this.bindRenderbuffer.set(s),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),s}createFramebuffer(t,e,i){return new cd(this,t,e,i)}clear({color:t,depth:e}){const i=this.gl;let r=0;t&&(r|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),i.clear(r)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){n(t.blendFunction,hd.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class pd{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}pd.ReadOnly=!1,pd.ReadWrite=!0,pd.disabled=new pd(519,pd.ReadOnly,[0,1]);const dd=7680;class md{constructor(t,e,i,r,s,n){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=s,this.pass=n}}md.disabled=new md({func:519,mask:0},0,0,dd,dd,dd);class fd{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}let _d;function gd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=t.useProgram("collisionBox"),h=[];let u=0,p=0;for(let d=0;d<r.length;d++){const m=r[d],f=e.getTile(m),_=f.getBucket(i);if(!_)continue;let g=m.posMatrix;0===s[0]&&0===s[1]||(g=t.translatePosMatrix(m.posMatrix,f,s,n));const y=a?_.textCollisionBox:_.iconCollisionBox,x=_.collisionCircleArray;if(x.length>0){const e=ka(),i=g;Va(e,_.placementInvProjMatrix,t.transform.glCoordMatrix),Va(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:p,transform:i,invTransform:e,coord:m}),u+=x.length/4,p=u}y&&c.draw(o,l.LINES,pd.disabled,md.disabled,t.colorModeForRenderPass(),fd.disabled,ap(g,t.transform,f),t.style.terrain&&t.style.terrain.getTerrainData(m),i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,null,y.collisionVertexBuffer)}if(!a||!h.length)return;const d=t.useProgram("collisionCircle"),m=new vn;m.resize(4*u),m._trim();let f=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],s=t.circleArray[i+1],n=t.circleArray[i+2],a=t.circleArray[i+3];m.emplace(f++,r,s,n,a,0),m.emplace(f++,r,s,n,a,1),m.emplace(f++,r,s,n,a,2),m.emplace(f++,r,s,n,a,3)}(!_d||_d.length<2*u)&&(_d=function(t){const e=2*t,i=new wn;i.resize(e),i._trim();for(let t=0;t<e;t++){const e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));const _=o.createIndexBuffer(_d,!0),g=o.createVertexBuffer(m,Cl.members,!0);for(const e of h){const r={u_matrix:e.transform,u_inv_matrix:e.invTransform,u_camera_to_center_distance:(y=t.transform).cameraToCenterDistance,u_viewport_size:[y.width,y.height]};d.draw(o,l.TRIANGLES,pd.disabled,md.disabled,t.colorModeForRenderPass(),fd.disabled,r,t.style.terrain&&t.style.terrain.getTerrainData(e.coord),i.id,g,_,En.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}var y;g.destroy(),_.destroy()}fd.disabled=new fd(!1,1029,2305),fd.backCCW=new fd(!0,1029,2305);const yd=Ma(new Float32Array(16));function xd(t,e,i,r,s,n){const{horizontalAlign:a,verticalAlign:o}=ac(t),l=-(a-.5)*e,c=-(o-.5)*i,h=pc(t,r);return new k((l/s+h[0])*n,(c/s+h[1])*n)}function vd(t,e,i,r,s,n,a,o,l,c,h){const u=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,d=t.icon.dynamicLayoutVertexArray,m={};p.clear();for(let d=0;d<u.length;d++){const f=u.get(d),_=t.allowVerticalPlacement&&!f.placedOrientation,g=f.hidden||!f.crossTileID||_?null:r[f.crossTileID];if(g){const r=new k(f.anchorX,f.anchorY),u=Jh(r,i?a:n,h),d=Qh(s.cameraToCenterDistance,u.signedDistanceFromCamera);let _=lc(t.textSizeData,l,f)*d/24;i&&(_*=t.tilePixelRatio/o);const{width:y,height:x,anchor:v,textOffset:b,textBoxScale:w}=g,T=xd(v,y,x,b,w,_),I=i?Jh(r.add(T),n,h).point:u.point.add(e?T.rotate(-s.angle):T),z=t.allowVerticalPlacement&&f.placedOrientation===Rl.vertical?Math.PI/2:0;for(let t=0;t<f.numGlyphs;t++)_c(p,I,z);c&&f.associatedIconIndex>=0&&(m[f.associatedIconIndex]={shiftedAnchor:I,angle:z})}else lu(f.numGlyphs,p)}if(c){d.clear();const e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){const i=e.get(t);if(i.hidden)lu(i.numGlyphs,d);else{const e=m[t];if(e)for(let t=0;t<i.numGlyphs;t++)_c(d,e.shiftedAnchor,e.angle);else lu(i.numGlyphs,d)}}t.icon.dynamicLayoutVertexBuffer.updateData(d)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function bd(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function wd(t,e,i,r,s,n,a,o,l,c,h,u){const p=t.context,d=p.gl,m=t.transform,f="map"===o,_="map"===l,g="viewport"!==o&&"point"!==i.layout.get("symbol-placement"),y=f&&!_&&!g,x=!i.layout.get("symbol-sort-key").isConstant();let v=!1;const b=t.depthModeForSublayer(0,pd.ReadOnly),w=i.layout.get("text-variable-anchor"),T=[];for(const o of r){const r=e.getTile(o),l=r.getBucket(i);if(!l)continue;const h=s?l.text:l.icon;if(!h||!h.segments.get().length)continue;const u=h.programConfigurations.get(i.id),p=s||l.sdfIcons,b=s?l.textSizeData:l.iconSizeData,I=_||0!==m.pitch,z=t.useProgram(bd(p,s,l),u),S=cc(b,m.zoom),A=t.style.terrain&&t.style.terrain.getTerrainData(o);let E,C,P,k,M=[0,0],D=null;if(s){if(C=r.glyphAtlasTexture,P=d.LINEAR,E=r.glyphAtlasTexture.size,l.iconsInText){M=r.imageAtlasTexture.size,D=r.imageAtlasTexture;const e="composite"===b.kind||"camera"===b.kind;k=I||t.options.rotating||t.options.zooming||e?d.LINEAR:d.NEAREST}}else{const e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;C=r.imageAtlasTexture,P=p||t.options.rotating||t.options.zooming||e||I?d.LINEAR:d.NEAREST,E=r.imageAtlasTexture.size}const L=pu(r,1,t.transform.zoom),B=Kh(o.posMatrix,_,f,t.transform,L),R=Yh(o.posMatrix,_,f,t.transform,L),F=w&&l.hasTextData(),O="none"!==i.layout.get("icon-text-fit")&&F&&l.hasIconData();if(g){const e=t.style.terrain?(e,i)=>t.style.terrain.getElevation(o,e,i):null,r="map"===i.layout.get("text-rotation-alignment");eu(l,o.posMatrix,t,s,B,R,_,c,r,e)}const V=t.translatePosMatrix(o.posMatrix,r,n,a),U=g||s&&w||O?yd:B,N=t.translatePosMatrix(R,r,n,a,!0),q=p&&0!==i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let $;$=p?l.iconsInText?bp(b.kind,S,y,_,t,V,U,N,E,M):vp(b.kind,S,y,_,t,V,U,N,s,E,!0):xp(b.kind,S,y,_,t,V,U,N,s,E);const j={program:z,buffers:h,uniformValues:$,atlasTexture:C,atlasTextureIcon:D,atlasInterpolation:P,atlasInterpolationIcon:k,isSDF:p,hasHalo:q};if(x&&l.canOverlap){v=!0;const t=h.segments.get();for(const e of t)T.push({segments:new En([e]),sortKey:e.sortKey,state:j,terrainData:A})}else T.push({segments:h.segments,sortKey:0,state:j,terrainData:A})}v&&T.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of T){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 s=r.uniformValues;r.hasHalo&&(s.u_is_halo=1,Td(r.buffers,e.segments,i,t,r.program,b,h,u,s,e.terrainData)),s.u_is_halo=0}Td(r.buffers,e.segments,i,t,r.program,b,h,u,r.uniformValues,e.terrainData)}}function Td(t,e,i,r,s,n,a,o,l,c){const h=r.context;s.draw(h,h.gl.TRIANGLES,n,a,o,fd.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Id(t,e,i,r,s,n,a){const o=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,m,f;a?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=o.LINES):(p=c?"fillPattern":"fill",u=o.TRIANGLES);for(const _ of r){const r=e.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;const y=g.programConfigurations.get(i.id),x=t.useProgram(p,y),v=t.style.terrain&&t.style.terrain.getTerrainData(_);c&&(t.context.activeTexture.set(o.TEXTURE0),r.imageAtlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const b=l.constantOr(null);if(b&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const w=v?_:null,T=t.translatePosMatrix(w?w.posMatrix:_.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){m=g.indexBuffer2,f=g.segments2;const e=[o.drawingBufferWidth,o.drawingBufferHeight];d="fillOutlinePattern"===p&&c?sp(T,t,h,r,e):rp(T,e)}else m=g.indexBuffer,f=g.segments,d=c?ip(T,t,h,r):ep(T);x.draw(t.context,u,s,t.stencilModeForClipping(_),n,fd.disabled,d,v,i.id,g.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,y)}}function zd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.paint.get("fill-extrusion-pattern"),h=c.constantOr(1),u=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity");for(const d of r){const r=e.getTile(d),m=r.getBucket(i);if(!m)continue;const f=t.style.terrain&&t.style.terrain.getTerrainData(d),_=m.programConfigurations.get(i.id),g=t.useProgram(h?"fillExtrusionPattern":"fillExtrusion",_);h&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.updatePaintBuffers(u));const y=c.constantOr(null);if(y&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[y.to.toString()],i=t.patternPositions[y.from.toString()];e&&i&&_.setConstantPatternPositions(e,i)}const x=t.translatePosMatrix(d.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=h?tp(x,t,v,p,d,u,r):Qu(x,t,v,p);g.draw(o,o.gl.TRIANGLES,s,n,a,fd.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,_,t.style.terrain&&m.centroidVertexBuffer)}}function Sd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.terrain&&t.style.terrain.getTerrainData(e);o.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(o,l.TRIANGLES,s,n,a,fd.disabled,((t,e,i,r)=>{const s=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let o=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:hp(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),o],u_shadow:s,u_highlight:n,u_accent:a}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function Ad(t,e,i,r,s,n){const a=t.context,o=a.gl,l=e.dem;if(l&&l.data){const c=l.dim,h=l.stride,u=l.getPixels();if(a.activeTexture.set(o.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||t.getTileTexture(h),e.demTexture){const t=e.demTexture;t.update(u,{premultiply:!1}),t.bind(o.NEAREST,o.CLAMP_TO_EDGE)}else e.demTexture=new kc(a,u,o.RGBA,{premultiply:!1}),e.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);a.activeTexture.set(o.TEXTURE0);let p=e.fbo;if(!p){const t=new kc(a,{width:c,height:c,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),p=e.fbo=a.createFramebuffer(c,c,!0),p.colorAttachment.set(t.texture)}a.bindFramebuffer.set(p.framebuffer),a.viewport.set([0,0,c,c]),t.useProgram("hillshadePrepare").draw(a,o.TRIANGLES,r,s,n,fd.disabled,((t,e)=>{const i=e.stride,r=ka();return Oa(r,0,aa,-8192,0,0,1),Ba(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}})(e.tileID,l),null,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function Ed(t,e,i,r,s,n){const a=r.paint.get("raster-fade-duration");if(!n&&a>0){const r=P.now(),n=(r-t.timeAdded)/a,o=e?(r-e.timeAdded)/a:-1,c=i.getSource(),h=s.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!e||Math.abs(e.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),p=u&&t.refreshedUponExpiration?1:l(u?n:1-o,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),e?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const Cd=new jt(1,0,0,1),Pd=new jt(0,1,0,1),kd=new jt(0,0,1,1),Md=new jt(1,0,1,1),Dd=new jt(0,1,1,1);function Ld(t,e,i,r){Rd(t,0,e+i/2,t.transform.width,i,r)}function Bd(t,e,i,r){Rd(t,e-i/2,0,i,t.transform.height,r)}function Rd(t,e,i,r,s,n){const a=t.context,o=a.gl;o.enable(o.SCISSOR_TEST),o.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,s*t.pixelRatio),a.clear({color:n}),o.disable(o.SCISSOR_TEST)}function Fd(t,e,i){const r=t.context,s=r.gl,n=i.posMatrix,a=t.useProgram("debug"),o=pd.disabled,l=md.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.terrain&&t.style.terrain.getTerrainData(i);r.activeTexture.set(s.TEXTURE0),t.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const p=e.getTileByID(i.key).latestRawTileData,d=Math.floor((p&&p.byteLength||0)/1024),m=e.getTile(i).tileSize,f=512/Math.min(m,512)*(i.overscaledZ/t.transform.zoom)*.5;let _=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${d}kb`),a.draw(r,s.TRIANGLES,o,l,hd.alphaBlended,fd.disabled,op(n,jt.transparent,f),null,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),a.draw(r,s.LINE_STRIP,o,l,c,fd.disabled,op(n,jt.red),u,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Od(t,e,i){const r=t.context,s=r.gl,n=t.colorModeForRenderPass(),a=new pd(s.LEQUAL,pd.ReadWrite,t.depthRangeFor3D),o=t.useProgram("terrain"),l=e.getTerrainMesh(),c=e.getTerrainData(i.tileID);r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]),r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,e.getRTTFramebuffer().colorAttachment.get());const h=t.transform.calculatePosMatrix(i.tileID.toUnwrapped());o.draw(r,s.TRIANGLES,a,md.disabled,n,fd.backCCW,{u_matrix:h,u_texture:0},c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}function Vd(t,e,i,r){const s=t.context,n=i.tileSize*e.qualityFactor;i.textures[r]||(i.textures[r]=t.getTileTexture(n)||new kc(s,{width:n,height:n,data:null},s.gl.RGBA),i.textures[r].bind(s.gl.LINEAR,s.gl.CLAMP_TO_EDGE),0===r&&e.sourceCache.renderHistory.push(i.tileID.key));const a=e.getRTTFramebuffer();a.colorAttachment.set(i.textures[r].texture),s.bindFramebuffer.set(a.framebuffer),s.viewport.set([0,0,n,n])}class Ud{constructor(t){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=t,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=t.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const t=this.painter.style,e=t.terrain;for(const i in t.sourceCaches){this._coordsDescendingInv[i]={};const r=t.sourceCaches[i].getVisibleCoordinates();for(const t of r){const r=e.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[i][t]||(this._coordsDescendingInv[i][t]=[]),this._coordsDescendingInv[i][t].push(r[t])}}for(const e of t._order){const i=t._layers[e],r=i.source;if(this._renderToTexture[i.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}return this._renderableTiles.forEach((t=>{for(const i in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[i][t.tileID.key];r&&r!==t.textureCoords[i]&&t.clearTextures(this.painter),e.needsRerender(i,t.tileID)&&t.clearTextures(this.painter)}this._rerender[t.tileID.key]=!t.textures.length})),e.clearRerenderCache(),e.sourceCache.removeOutdated(this.painter),this}renderLayer(t){const e=t.type,i=this.painter,r=i.style._order,s=i.currentLayer,n=s+1===r.length;if(this._renderToTexture[e]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=e,this._stacks[this._stacks.length-1].push(r[s]),!n))return!0;if(this._renderToTexture[this._prevType]||"hillshade"===e||this._renderToTexture[e]&&n){this._prevType=e;const n=this._stacks.length-1,a=this._stacks[n]||[];for(const t of this._renderableTiles){if(Vd(i,i.style.terrain,t,n),this._rerender[t.tileID.key]){i.context.clear({color:jt.transparent});for(let e=0;e<a.length;e++){const r=i.style._layers[a[e]],s=r.source?this._coordsDescendingInv[r.source][t.tileID.key]:[t.tileID];i._renderTileClippingMasks(r,s),i.renderLayer(i,i.style.sourceCaches[r.source],r,s),r.source&&(t.textureCoords[r.source]=this._coordsDescendingInvStr[r.source][t.tileID.key])}}Od(i,i.style.terrain,t)}if("hillshade"===e){this._stacks.push([r[s]]);for(const e of this._renderableTiles){const r=this._coordsDescendingInv[t.source][e.tileID.key];Vd(i,i.style.terrain,e,this._stacks.length-1),i.context.clear({color:jt.transparent}),i._renderTileClippingMasks(t,r),i.renderLayer(i,i.style.sourceCaches[t.source],t,r),Od(i,i.style.terrain,e)}return!0}return this._renderToTexture[e]}return!1}}const Nd={symbol:function(t,e,i,r,s){if("translucent"!==t.renderPass)return;const n=md.disabled,a=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,e,i,r,s,n,a){const o=e.transform,l="map"===s,c="map"===n;for(const s of t){const t=r.getTile(s),n=t.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const h=cc(n.textSizeData,o.zoom),u=pu(t,1,e.transform.zoom),p=Kh(s.posMatrix,c,l,e.transform,u),d="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(h){const i=Math.pow(2,o.zoom-t.tileID.overscaledZ);vd(n,l,c,a,o,p,s.posMatrix,i,h,d,e.style.terrain?(t,i)=>e.style.terrain.getElevation(s,t,i):null)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),s),0!==i.paint.get("icon-opacity").constantOr(1)&&wd(t,e,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,a),0!==i.paint.get("text-opacity").constantOr(1)&&wd(t,e,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),n,a),e.map.showCollisionBoxes&&(gd(t,e,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),gd(t,e,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("circle-opacity"),n=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),o=!i.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const l=t.context,c=l.gl,h=t.depthModeForSublayer(0,pd.ReadOnly),u=md.disabled,p=t.colorModeForRenderPass(),d=[];for(let s=0;s<r.length;s++){const n=r[s],a=e.getTile(n),l=a.getBucket(i);if(!l)continue;const c=l.programConfigurations.get(i.id),h=t.useProgram("circle",c),u=l.layoutVertexBuffer,p=l.indexBuffer,m=t.style.terrain&&t.style.terrain.getTerrainData(n),f={programConfiguration:c,program:h,layoutVertexBuffer:u,indexBuffer:p,uniformValues:np(t,n,a,i),terrainData:m};if(o){const t=l.segments.get();for(const e of t)d.push({segments:new En([e]),sortKey:e.sortKey,state:f})}else d.push({segments:l.segments,sortKey:0,state:f})}o&&d.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of d){const{programConfiguration:r,program:s,layoutVertexBuffer:n,indexBuffer:a,uniformValues:o,terrainData:d}=e.state;s.draw(l,c.TRIANGLES,h,u,p,fd.disabled,o,d,i.id,n,a,e.segments,i.paint,t.transform.zoom,r)}},heatmap:function(t,e,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,n=s.gl,a=md.disabled,o=new hd([n.ONE,n.ONE],jt.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let s=i.heatmapFbo;if(s)r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer);else{const n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),s=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,e.width/4,e.height/4,0,s.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,n,s)}}(s,t,i),s.clear({color:jt.transparent});for(let l=0;l<r.length;l++){const c=r[l];if(e.hasRenderableParent(c))continue;const h=e.getTile(c),u=h.getBucket(i);if(!u)continue;const p=u.programConfigurations.get(i.id),d=t.useProgram("heatmap",p),{zoom:m}=t.transform;d.draw(s,n.TRIANGLES,pd.disabled,a,o,fd.disabled,cp(c.posMatrix,h,m,i.paint.get("heatmap-intensity")),null,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,t.transform.zoom,p)}s.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,e){const i=t.context,r=i.gl,s=e.heatmapFbo;if(!s)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let n=e.colorRampTexture;n||(n=e.colorRampTexture=new kc(i,e.colorRamp,r.RGBA)),n.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,pd.disabled,md.disabled,t.colorModeForRenderPass(),fd.disabled,((t,e,i,r)=>{const s=ka();Oa(s,0,t.width,t.height,0,0,1);const n=t.context.gl;return{u_matrix:s,u_world:[n.drawingBufferWidth,n.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}})(t,e),null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom)}(t,i))},line:function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===s.constantOr(1)||0===n.constantOr(1))return;const a=t.depthModeForSublayer(0,pd.ReadOnly),o=t.colorModeForRenderPass(),c=i.paint.get("line-dasharray"),h=i.paint.get("line-pattern"),u=h.constantOr(1),p=i.paint.get("line-gradient"),d=i.getCrossfadeParameters(),m=u?"linePattern":c?"lineSDF":p?"lineGradient":"line",f=t.context,_=f.gl;let g=!0;for(const s of r){const r=e.getTile(s);if(u&&!r.patternsLoaded())continue;const n=r.getBucket(i);if(!n)continue;const x=n.programConfigurations.get(i.id),v=t.context.program.get(),b=t.useProgram(m,x),w=g||b.program!==v,T=t.style.terrain&&t.style.terrain.getTerrainData(s),I=h.constantOr(null);if(I&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[I.to.toString()],i=t.patternPositions[I.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const z=T?s:null,S=u?dp(t,r,i,d,z):c?mp(t,r,i,c,d,z):p?pp(t,r,i,n.lineClipsArray.length,z):up(t,r,i,z);if(u)f.activeTexture.set(_.TEXTURE0),r.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),x.updatePaintBuffers(d);else if(c&&(w||t.lineAtlas.dirty))f.activeTexture.set(_.TEXTURE0),t.lineAtlas.bind(f);else if(p){const r=n.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let o=256;if(i.stepInterpolant){const i=e.getSource().maxzoom,r=s.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-s.canonical.z):1;o=l((y=n.maxLineLength/aa*1024*r)<=1?1:Math.pow(2,Math.ceil(Math.log(y)/Math.LN2)),256,f.maxTextureSize)}r.gradient=Qa({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:o,image:r.gradient||void 0,clips:n.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new kc(f,r.gradient,_.RGBA),r.version=i.gradientVersion,a=r.texture}f.activeTexture.set(_.TEXTURE0),a.bind(i.stepInterpolant?_.NEAREST:_.LINEAR,_.CLAMP_TO_EDGE)}b.draw(f,_.TRIANGLES,a,t.stencilModeForClipping(s),o,fd.disabled,S,T,i.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,i.paint,t.transform.zoom,x,n.layoutVertexBuffer2),g=!1}var y},fill:function(t,e,i,r){const s=i.paint.get("fill-color"),n=i.paint.get("fill-opacity");if(0===n.constantOr(1))return;const a=t.colorModeForRenderPass(),o=i.paint.get("fill-pattern"),l=t.opaquePassEnabledForLayer()&&!o.constantOr(1)&&1===s.constantOr(jt.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";if(t.renderPass===l){const s=t.depthModeForSublayer(1,"opaque"===t.renderPass?pd.ReadWrite:pd.ReadOnly);Id(t,e,i,r,s,a,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const s=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,pd.ReadOnly);Id(t,e,i,r,s,a,!0)}},"fill-extrusion":function(t,e,i,r){const s=i.paint.get("fill-extrusion-opacity");if(0!==s&&"translucent"===t.renderPass){const n=new pd(t.context.gl.LEQUAL,pd.ReadWrite,t.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))zd(t,e,i,r,n,md.disabled,hd.disabled),zd(t,e,i,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass());else{const s=t.colorModeForRenderPass();zd(t,e,i,r,n,md.disabled,s)}}},hillshade:function(t,e,i,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const s=t.context,n=t.depthModeForSublayer(0,pd.ReadOnly),a=t.colorModeForRenderPass(),[o,l]="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r];for(const r of l){const s=e.getTile(r);void 0!==s.needsHillshadePrepare&&s.needsHillshadePrepare&&"offscreen"===t.renderPass?Ad(t,s,i,n,md.disabled,a):"translucent"===t.renderPass&&Sd(t,r,s,i,n,o[r.overscaledZ],a)}s.viewport.set([0,0,t.width,t.height])},raster:function(t,e,i,r){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const s=t.context,n=s.gl,a=e.getSource(),o=t.useProgram("raster"),l=t.colorModeForRenderPass(),[c,h]=a instanceof dh?[{},r]:t.stencilConfigForOverlap(r),u=h[h.length-1].overscaledZ,p=!t.options.moving;for(const r of h){const h=t.depthModeForSublayer(r.overscaledZ-u,1===i.paint.get("raster-opacity")?pd.ReadWrite:pd.ReadOnly,n.LESS),d=e.getTile(r);d.registerFadeDuration(i.paint.get("raster-fade-duration"));const m=e.findLoadedParent(r,0),f=Ed(d,m,e,i,t.transform,t.style.terrain);let _,g;const y="nearest"===i.paint.get("raster-resampling")?n.NEAREST:n.LINEAR;s.activeTexture.set(n.TEXTURE0),d.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),s.activeTexture.set(n.TEXTURE1),m?(m.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),_=Math.pow(2,m.tileID.overscaledZ-d.tileID.overscaledZ),g=[d.tileID.canonical.x*_%1,d.tileID.canonical.y*_%1]):d.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST);const x=t.style.terrain&&t.style.terrain.getTerrainData(r),v=x?r:null,b=v?v.posMatrix:t.transform.calculatePosMatrix(r.toUnwrapped(),p),w=gp(b,g||[0,0],_||1,f,i);a instanceof dh?o.draw(s,n.TRIANGLES,h,md.disabled,l,fd.disabled,w,x,i.id,a.boundsBuffer,t.quadTriangleIndexBuffer,a.boundsSegments):o.draw(s,n.TRIANGLES,h,c[r.overscaledZ],l,fd.disabled,w,x,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}},background:function(t,e,i,r){const s=i.paint.get("background-color"),n=i.paint.get("background-opacity");if(0===n)return;const a=t.context,o=a.gl,l=t.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const u=!h&&1===s.a&&1===n&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const p=md.disabled,d=t.depthModeForSublayer(0,"opaque"===u?pd.ReadWrite:pd.ReadOnly),m=t.colorModeForRenderPass(),f=t.useProgram(h?"backgroundPattern":"background"),_=r||l.coveringTiles({tileSize:c,terrain:t.style.terrain});h&&(a.activeTexture.set(o.TEXTURE0),t.imageManager.bind(t.context));const g=i.getCrossfadeParameters();for(const e of _){const l=r?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=h?Tp(l,n,t,h,{tileID:e,tileSize:c},g):wp(l,n,s),_=t.style.terrain&&t.style.terrain.getTerrainData(e);f.draw(a,o.TRIANGLES,d,p,m,fd.disabled,u,_,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}},debug:function(t,e,i){for(let r=0;r<i.length;r++)Fd(t,e,i[r])},custom:function(t,e,i){const r=t.context,s=i.implementation;if("offscreen"===t.renderPass){const e=s.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(s,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(md.disabled);const e="3d"===s.renderingMode?new pd(t.context.gl.LEQUAL,pd.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,pd.ReadOnly);r.setDepthMode(e),s.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class qd{constructor(t,e){this.context=new ud(t),this.transform=e,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:ka(),renderTime:0},this.setup(),this.numSublayers=Eh.maxUnderzooming+Eh.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Fu,this.gpuTimers={}}resize(t,e,i){if(this.width=t*i,this.height=e*i,this.pixelRatio=i,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,e=new ln;e.emplaceBack(0,0),e.emplaceBack(aa,0),e.emplaceBack(0,aa),e.emplaceBack(aa,aa),this.tileExtentBuffer=t.createVertexBuffer(e,Ou.members),this.tileExtentSegments=En.simpleSegment(0,0,4,2);const i=new ln;i.emplaceBack(0,0),i.emplaceBack(aa,0),i.emplaceBack(0,aa),i.emplaceBack(aa,aa),this.debugBuffer=t.createVertexBuffer(i,Ou.members),this.debugSegments=En.simpleSegment(0,0,4,5);const r=new cn;r.emplaceBack(0,0,0,0),r.emplaceBack(aa,0,aa,0),r.emplaceBack(0,aa,0,aa),r.emplaceBack(aa,aa,aa,aa),this.rasterBoundsBuffer=t.createVertexBuffer(r,ph.members),this.rasterBoundsSegments=En.simpleSegment(0,0,4,2);const s=new ln;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Ou.members),this.viewportSegments=En.simpleSegment(0,0,4,2);const n=new zn;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(n);const a=new Tn;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new kc(t,{width:1,height:1,data:new Uint8Array([0,0,0,0])},t.gl.RGBA);const o=this.context.gl;this.stencilClearMode=new md({func:o.ALWAYS,mask:0},0,255,o.ZERO,o.ZERO,o.ZERO)}clearStencil(){const t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const i=ka();Oa(i,0,this.width,this.height,0,0,1),Ra(i,i,[e.drawingBufferWidth,e.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,e.TRIANGLES,pd.disabled,this.stencilClearMode,hd.disabled,fd.disabled,lp(i),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 i=this.context,r=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(hd.disabled),i.setDepthMode(pd.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,n=this.style.terrain&&this.style.terrain.getTerrainData(t);s.draw(i,r.TRIANGLES,pd.disabled,new md({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),hd.disabled,fd.disabled,lp(t.posMatrix),n,"$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 md({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new md({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i<s;i++)t[i+r]=new md({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=s,[t,i]}return[{[r]:md.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const e=1/8;return new hd([t.CONSTANT_COLOR,t.ONE],new jt(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?hd.unblended:hd.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return pd.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new pd(i||this.context.gl.LEQUAL,e,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,e){this.style=t,this.options=e,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(P.now()),this.imageManager.beginFrame();const i=this.style._order,r=this.style.sourceCaches,s=this.style.terrain&&new Ud(this);for(const t in r){const e=r[t];e.used&&e.prepare(this.context)}const n={},a={},o={};for(const t in r){const e=r[t];n[t]=e.getVisibleCoordinates(),a[t]=n[t].slice().reverse(),o[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}if(s){this.opaquePassCutoff=0;const t=this.style.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);!this.terrainFacilitator.dirty&&(h=(l=this.terrainFacilitator.matrix)[0],u=l[1],p=l[2],d=l[3],m=l[4],f=l[5],_=l[6],g=l[7],y=l[8],x=l[9],v=l[10],b=l[11],w=l[12],T=l[13],I=l[14],z=l[15],S=(c=this.transform.projMatrix)[0],A=c[1],E=c[2],C=c[3],k=c[4],M=c[5],D=c[6],L=c[7],B=c[8],R=c[9],F=c[10],O=c[11],V=c[12],U=c[13],N=c[14],q=c[15],Math.abs(h-S)<=Ca*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(u-A)<=Ca*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(p-E)<=Ca*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(d-C)<=Ca*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(m-k)<=Ca*Math.max(1,Math.abs(m),Math.abs(k))&&Math.abs(f-M)<=Ca*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(_-D)<=Ca*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-L)<=Ca*Math.max(1,Math.abs(g),Math.abs(L))&&Math.abs(y-B)<=Ca*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(x-R)<=Ca*Math.max(1,Math.abs(x),Math.abs(R))&&Math.abs(v-F)<=Ca*Math.max(1,Math.abs(v),Math.abs(F))&&Math.abs(b-O)<=Ca*Math.max(1,Math.abs(b),Math.abs(O))&&Math.abs(w-V)<=Ca*Math.max(1,Math.abs(w),Math.abs(V))&&Math.abs(T-U)<=Ca*Math.max(1,Math.abs(T),Math.abs(U))&&Math.abs(I-N)<=Ca*Math.max(1,Math.abs(I),Math.abs(N))&&Math.abs(z-q)<=Ca*Math.max(1,Math.abs(z),Math.abs(q)))&&!t.length||(function(t,e){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]}(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,e){const i=t.context,r=i.gl,s=hd.unblended,n=new pd(r.LEQUAL,pd.ReadWrite,[0,1]),a=e.getTerrainMesh(),o=e.sourceCache.getRenderableTiles(),l=t.useProgram("terrainDepth");i.bindFramebuffer.set(e.getFramebuffer("depth").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:jt.transparent,depth:1});for(const c of o){const o=e.getTerrainData(c.tileID),h=t.transform.calculatePosMatrix(c.tileID.toUnwrapped());l.draw(i,r.TRIANGLES,n,md.disabled,s,fd.backCCW,{u_matrix:h},o,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}(this,this.style.terrain),function(t,e){const i=t.context,r=i.gl,s=hd.unblended,n=new pd(r.LEQUAL,pd.ReadWrite,[0,1]),a=e.getTerrainMesh(),o=e.getCoordsTexture(),l=e.sourceCache.getRenderableTiles(),c=t.useProgram("terrainCoords");i.bindFramebuffer.set(e.getFramebuffer("coords").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:jt.transparent,depth:1}),e.coordsIndex=[];for(const h of l){const l=e.getTerrainData(h.tileID);i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.texture);const u=t.transform.calculatePosMatrix(h.tileID.toUnwrapped());c.draw(i,r.TRIANGLES,n,md.disabled,s,fd.backCCW,{u_matrix:u,u_terrain_coords_id:(255-e.coordsIndex.length)/255,u_texture:0},l,"terrain",a.vertexBuffer,a.indexBuffer,a.segments),e.coordsIndex.push(h.tileID.key)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}(this,this.style.terrain))}var l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,z,S,A,E,C,k,M,D,L,B,R,F,O,V,U,N,q;this.renderPass="offscreen";for(const t of i){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=a[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,r[e.source],e,i)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:e.showOverdrawInspector?jt.black:jt.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=e.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!s)for(this.renderPass="opaque",this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],e=r[t.source],s=n[t.source];this._renderTileClippingMasks(t,s),this.renderLayer(this,e,t,s)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const t=this.style._layers[i[this.currentLayer]],e=r[t.source];if(s&&s.renderLayer(t))continue;const l=("symbol"===t.type?o:a)[t.source];this._renderTileClippingMasks(t,n[t.source]),this.renderLayer(this,e,t,l)}if(this.options.showTileBoundaries){let t,e;Object.values(this.style._layers).forEach((i=>{i.source&&!i.isHidden(this.transform.zoom)&&(i.source!==(e&&e.id)&&(e=this.style.sourceCaches[i.source]),(!t||t.getSource().maxzoom<e.getSource().maxzoom)&&(t=e))})),t&&Nd.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;Ld(t,t.transform.height-(e.top||0),3,Cd),Ld(t,e.bottom||0,3,Pd),Bd(t,e.left||0,3,kd),Bd(t,t.transform.width-(e.right||0),3,Md);const i=t.transform.centerPoint;!function(t,e,i,r){Rd(t,e-1,i-10,2,20,r),Rd(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,Dd)}(this),this.context.setDefault()}renderLayer(t,e,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"custom"===i.type||(r||[]).length)&&(this.id=i.id,this.gpuTimingStart(i),Nd[i.type](t,e,i,r,this.style.placement.variableOffsets),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],s=this.context.extTimerQuery,n=s.getQueryObjectEXT(r.query,s.QUERY_RESULT_EXT)/1e6;s.deleteQueryEXT(r.query),e[i]=n}return e}translatePosMatrix(t,e,i,r,s){if(!i[0]&&!i[1])return t;const n=s?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(n){const t=Math.sin(n),e=Math.cos(n);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}const a=[s?i[0]:pu(e,i[0],this.transform.zoom),s?i[1]:pu(e,i[1],this.transform.zoom),0],o=new Float32Array(16);return Ba(o,t,a),o}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()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new Yu(this.context,t,Xu[t],e,Ip[t],this._showOverdrawInspector,this.style.terrain)),this.cache[i]}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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new kc(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class $d{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i){const r=Math.pow(2,i),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const s=1/(i=$a([],i,t))[3]/e*r;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(i,i,[s,s,1/i[3],s])})),n=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}([],function(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}([],qa([],s[t[0]],s[t[1]]),qa([],s[t[2]],s[t[1]]))),i=-((r=e)[0]*(n=s[t[1]])[0]+r[1]*n[1]+r[2]*n[2]);var r,n;return e.concat(i)}));return new $d(s,n)}}class jd{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max))}quadrant(t){const e=[t%2==0,t<2],i=Ua(this.min),r=Ua(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],r[t]=e[t]?this.center[t]:this.max[t];return r[2]=this.max[2],new jd(i,r)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const e=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let i=!0;for(let n=0;n<t.planes.length;n++){const a=t.planes[n];let o=0;for(let t=0;t<e.length;t++)(r=a)[0]*(s=e[t])[0]+r[1]*s[1]+r[2]*s[2]+r[3]*s[3]>=0&&o++;if(0===o)return 0;o!==e.length&&(i=!1)}var r,s;if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let s=0;s<t.points.length;s++){const n=t.points[s][e]-this.min[e];i=Math.min(i,n),r=Math.max(r,n)}if(r<0||i>this.max[e]-this.min[e])return 0}return 1}}class Zd{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<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=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=Re(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=Re(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=Re(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=Re(t.right,e.right,i)),this}getCenter(t,e){const i=l((this.left+t-this.right)/2,0,t),r=l((this.top+e-this.bottom)/2,0,e);return new k(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Zd(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class Gd{constructor(t,e,i,r,s){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=void 0===s||!!s,this._minZoom=t||0,this._maxZoom=e||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setMaxBounds(),this.width=0,this.height=0,this._center=new Gc(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Zd,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new Gd(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}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 k(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const e=-c(t,-180,180)*Math.PI/180;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=function(){var t=new Pa(4);return Pa!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}(),function(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*o,t[1]=s*l+a*o,t[2]=r*-o+n*l,t[3]=s*-o+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const e=l(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,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.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,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,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),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 e=[new oh(0,t)];if(this._renderWorldCopies){const i=this.pointCoordinate(new k(0,0)),r=this.pointCoordinate(new k(this.width,0)),s=this.pointCoordinate(new k(this.width,this.height)),n=this.pointCoordinate(new k(0,this.height)),a=Math.floor(Math.min(i.x,r.x,s.x,n.x)),o=Math.floor(Math.max(i.x,r.x,s.x,n.x)),l=1;for(let i=a-l;i<=o+l;i++)0!==i&&e.push(new oh(i,t))}return e}coveringTiles(t){let e=this.coveringZoomLevel(t);const i=e;if(void 0!==t.minzoom&&e<t.minzoom)return[];void 0!==t.maxzoom&&e>t.maxzoom&&(e=t.maxzoom);const r=this.pointCoordinate(this.getCameraPoint()),s=th.fromLngLat(this.center),n=Math.pow(2,e),a=[n*r.x,n*r.y,0],o=[n*s.x,n*s.y,0],l=$d.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e);let c=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(c=e);const h=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,u=t=>({aabb:new jd([t*n,0,0],[(t+1)*n,n,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),p=[],d=[],m=e,f=t.reparseOverscaled?i:e;if(this._renderWorldCopies)for(let t=1;t<=3;t++)p.push(u(-t)),p.push(u(t));for(p.push(u(0));p.length>0;){const e=p.pop(),i=e.x,r=e.y;let s=e.fullyVisible;if(!s){const t=e.aabb.intersects(l);if(0===t)continue;s=2===t}const n=t.terrain?a:o,u=e.aabb.distanceX(n),_=e.aabb.distanceY(n),g=Math.max(Math.abs(u),Math.abs(_)),y=h+(1<<m-e.zoom)-2;if(e.zoom===m||g>y&&e.zoom>=c){const t=m-e.zoom,s=a[0]-.5-(i<<t),n=a[1]-.5-(r<<t);d.push({tileID:new lh(e.zoom===m?f:e.zoom,e.wrap,e.zoom,i,r),distanceSq:ja([o[0]-.5-i,o[1]-.5-r]),tileDistanceToCamera:Math.sqrt(s*s+n*n)})}else for(let n=0;n<4;n++){const a=(i<<1)+n%2,o=(r<<1)+(n>>1),l=e.zoom+1;let c=e.aabb.quadrant(n);if(t.terrain){const i=new lh(l,e.wrap,l,a,o),r=t.terrain.getTerrainData(i).tile;let s=this.elevation,n=this.elevation;r&&r.dem&&(s=r.dem.min*t.terrain.exaggeration,n=r.dem.max*t.terrain.exaggeration),c=new jd([c.min[0],c.min[1],s],[c.max[0],c.max[1],n])}p.push({aabb:c,zoom:l,x:a,y:o,wrap:e.wrap,fullyVisible:s})}}return d.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 e=l(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new k(Kc(t.lng)*this.worldSize,Yc(e)*this.worldSize)}unproject(t){return new th(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(t,e){const i=th.fromLngLat(t),r=(1<<this.tileZoom)*aa,s=i.x*r,n=i.y*r,a=Math.floor(s/aa),o=Math.floor(n/aa),l=new lh(this.tileZoom,0,this.tileZoom,a,o);return e.getElevation(l,s%aa,n%aa,aa)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const e=this.pointLocation(this.centerPoint,t),i=this.getElevation(e,t);if(!(this.elevation-i))return;const r=this.getCameraPosition(),s=th.fromLngLat(r.lngLat,r.altitude),n=th.fromLngLat(e,i),a=s.x-n.x,o=s.y-n.y,l=s.z-n.z,c=Math.sqrt(a*a+o*o+l*l),h=this.scaleZoom(this.cameraToCenterDistance/c/this.tileSize);this._elevation=i,this._center=e,this.zoom=h}setLocationAtPoint(t,e){const i=this.pointCoordinate(e),r=this.pointCoordinate(this.centerPoint),s=this.locationCoordinate(t),n=new th(s.x-(i.x-r.x),s.y-(i.y-r.y));this.center=this.coordinateLocation(n),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),this.getElevation(t,e),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return th.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];$a(i,i,this.pixelMatrixInverse),$a(r,r,this.pixelMatrixInverse);const s=i[3],n=r[3],a=i[1]/s,o=r[1]/n,l=i[2]/s,c=r[2]/n,h=l===c?0:(0-l)/(c-l);return new th(Re(i[0]/s,r[0]/n,h)/this.worldSize,Re(a,o,h)/this.worldSize)}coordinatePoint(t,e=0,i=this.pixelMatrix){const r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return $a(r,r,i),new k(r[0]/r[3],r[1]/r[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new Xc).extend(this.pointLocation(new k(0,t))).extend(this.pointLocation(new k(this.width,t))).extend(this.pointLocation(new k(this.width,this.height))).extend(this.pointLocation(new k(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new Xc([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=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,e=!1){const i=t.key,r=e?this._alignedPosMatrixCache:this._posMatrixCache;if(r[i])return r[i];const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),a=s.x+Math.pow(2,s.z)*t.wrap,o=Ma(new Float64Array(16));return Ba(o,o,[a*n,s.y*n,0]),Ra(o,o,[n/aa,n/aa,1]),La(o,e?this.alignedProjMatrix:this.projMatrix,o),r[i]=new Float32Array(o),r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,e,i,r,s=-90,n=90,a=-180,o=180;const l=this.size,c=this._unmodified;if(this.latRange){const e=this.latRange;s=Yc(e[1])*this.worldSize,n=Yc(e[0])*this.worldSize,t=n-s<l.y?l.y/(n-s):0}if(this.lngRange){const t=this.lngRange;a=Kc(t[0])*this.worldSize,o=Kc(t[1])*this.worldSize,e=o-a<l.x?l.x/(o-a):0}const h=this.point,u=Math.max(e||0,t||0);if(u)return this.center=this.unproject(new k(e?(o+a)/2:h.x,t?(n+s)/2:h.y)),this.zoom+=this.scaleZoom(u),this._unmodified=c,void(this._constraining=!1);if(this.latRange){const t=h.y,e=l.y/2;t-e<s&&(r=s+e),t+e>n&&(r=n-e)}if(this.lngRange){const t=h.x,e=l.x/2;t-e<a&&(i=a+e),t+e>o&&(i=o-e)}void 0===i&&void 0===r||(this.center=this.unproject(new k(void 0!==i?i:h.x,void 0!==r?r:h.y))),this._unmodified=c,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,e=this.point.x,i=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=Jc(1,this.center.lat)*this.worldSize;let r=Ma(new Float64Array(16));Ra(r,r,[this.width/2,-this.height/2,1]),Ba(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=Ma(new Float64Array(16)),Ra(r,r,[1,-1,1]),Ba(r,r,[-1,-1,0]),Ra(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const s=Math.PI/2+this._pitch,n=this._fov*(.5+t.y/this.height),a=Math.sin(n)*this.cameraToSeaLevelDistance/Math.sin(l(Math.PI-s-n,.01,Math.PI-.01)),o=this.getHorizon(),c=2*Math.atan(o/this.cameraToCenterDistance)*(.5+t.y/(2*o)),h=Math.sin(c)*this.cameraToSeaLevelDistance/Math.sin(l(Math.PI-s-c,.01,Math.PI-.01)),u=Math.cos(Math.PI/2-this._pitch)*a+this.cameraToSeaLevelDistance,p=Math.cos(Math.PI/2-this._pitch)*h+this.cameraToSeaLevelDistance,d=1.01*Math.min(u,p),m=this.height/50;r=new Float64Array(16),function(t,e,i,r,s){var n,a=1/Math.tan(e/2);t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0?(t[10]=(s+r)*(n=1/(r-s)),t[14]=2*s*r*n):(t[10]=-1,t[14]=-2*r)}(r,this._fov,this.width/this.height,m,d),r[8]=2*-t.x/this.width,r[9]=2*t.y/this.height,Ra(r,r,[1,-1,1]),Ba(r,r,[0,0,-this.cameraToCenterDistance]),function(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];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]=n*s+c*r,t[5]=a*s+h*r,t[6]=o*s+u*r,t[7]=l*s+p*r,t[8]=c*s-n*r,t[9]=h*s-a*r,t[10]=u*s-o*r,t[11]=p*s-l*r}(r,r,this._pitch),Fa(r,r,this.angle),Ba(r,r,[-e,-i,0]),this.mercatorMatrix=Ra([],r,[this.worldSize,this.worldSize,this.worldSize]),Ra(r,r,[1,1,this._pixelPerMeter]),this.pixelMatrix=La(new Float64Array(16),this.labelPlaneMatrix,r),Ba(r,r,[0,0,-this.elevation]),this.projMatrix=r,this.invProjMatrix=Da([],r),this.pixelMatrix3D=La(new Float64Array(16),this.labelPlaneMatrix,r);const f=this.width%2/2,_=this.height%2/2,g=Math.cos(this.angle),y=Math.sin(this.angle),x=e-Math.round(e)+g*f+y*_,v=i-Math.round(i)+g*_+y*f,b=new Float64Array(r);if(Ba(b,b,[x>.5?x-1:x,v>.5?v-1:v,0]),this.alignedProjMatrix=b,r=Da(new Float64Array(16),this.pixelMatrix),!r)throw new Error("failed to invert matrix");this.pixelMatrixInverse=r,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new k(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return $a(e,e,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new k(0,t))}getCameraQueryGeometry(t){const e=this.getCameraPoint();if(1===t.length)return[t[0],e];{let i=e.x,r=e.y,s=e.x,n=e.y;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),n=Math.max(n,e.y);return[new k(i,r),new k(s,r),new k(s,n),new k(i,n),new k(i,r)]}}}class Xd{constructor(t){this._hashName=t&&encodeURIComponent(t),f(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(t,e){let i=!1,r=null;const s=()=>{r=null,i&&(t(),r=setTimeout(s,300),i=!1)};return()=>(i=!0,r||s(),r)}(this._updateHashUnthrottled.bind(this))}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()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),n=Math.round(e.lng*s)/s,a=Math.round(e.lat*s)/s,o=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${n}/${a}/${i}`:`${i}/${a}/${n}`,(o||l)&&(c+="/"+Math.round(10*o)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_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("/")}_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}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}}}const Wd={linearity:.3,easing:a(0,0,.3,1)},Hd=u({deceleration:2500,maxSpeed:1400},Wd),Kd=u({deceleration:20,maxSpeed:1400},Wd),Yd=u({deceleration:1e3,maxSpeed:360},Wd),Jd=u({deceleration:1e3,maxSpeed:90},Wd);class Qd{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:P.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=P.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const e={zoom:0,bearing:0,pitch:0,pan:new k(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){const s=em(e.pan.mag(),i,u({},Hd,t||{}));r.offset=e.pan.mult(s.amount/e.pan.mag()),r.center=this._map.transform.center,tm(r,s)}if(e.zoom){const t=em(e.zoom,i,Kd);r.zoom=this._map.transform.zoom+t.amount,tm(r,t)}if(e.bearing){const t=em(e.bearing,i,Yd);r.bearing=this._map.transform.bearing+l(t.amount,-179,179),tm(r,t)}if(e.pitch){const t=em(e.pitch,i,Jd);r.pitch=this._map.transform.pitch+t.amount,tm(r,t)}if(r.zoom||r.bearing){const t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),u(r,{noMoveStart:!0})}}function tm(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function em(t,e,i){const{maxSpeed:r,linearity:s,deceleration:n}=i,a=l(t*s/(e/1e3),-r,r),o=Math.abs(a)/(n*s);return{easing:i.easing,duration:1e3*o,amount:a*(o/2)}}class im extends ut{constructor(t,e,i,r={}){const s=D.mousePos(e.getCanvasContainer(),i);super(t,u({point:s,lngLat:e.unproject(s),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class rm extends ut{constructor(t,e,i){const r="touchend"===t?i.changedTouches:i.touches,s=D.touchPos(e.getCanvasContainer(),r),n=s.map((t=>e.unproject(t))),a=s.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new k(0,0));super(t,{points:s,point:a,lngLats:n,lngLat:e.unproject(a),originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class sm extends ut{constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class nm{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new sm(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new im(t.type,this._map,t))}mouseup(t){this._map.fire(new im(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new im(t.type,this._map,t))}dblclick(t){return this._firePreventable(new im(t.type,this._map,t))}mouseover(t){this._map.fire(new im(t.type,this._map,t))}mouseout(t){this._map.fire(new im(t.type,this._map,t))}touchstart(t){return this._firePreventable(new rm(t.type,this._map,t))}touchmove(t){this._map.fire(new rm(t.type,this._map,t))}touchend(t){this._map.fire(new rm(t.type,this._map,t))}touchcancel(t){this._map.fire(new rm(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class am{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(t){this._map.fire(new im(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new im("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new im(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class om{constructor(t,e){this._map=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&&(D.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=D.create("div","maplibregl-boxzoom mapboxgl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair","mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const s=Math.min(r.x,i.x),n=Math.max(r.x,i.x),a=Math.min(r.y,i.y),o=Math.max(r.y,i.y);D.setTransform(this._box,`translate(${s}px,${a}px)`),this._box.style.width=n-s+"px",this._box.style.height=o-a+"px"}mouseupWindow(t,e){if(!this._active)return;if(0!==t.button)return;const i=this._startPos,r=e;if(this.reset(),D.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new ut("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._map.getBearing(),{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","mapboxgl-crosshair"),this._box&&(D.remove(this._box),this._box=null),D.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new ut(t,{originalEvent:e}))}}function lm(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class cm{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const e=new k(0,0);for(const i of t)e._add(i);return e.div(t.length)}(e),this.touches=lm(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=lm(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class hm{constructor(t){this.singleTap=new cm(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class um{constructor(){this._zoomIn=new hm({numTouches:1,numTaps:2}),this._zoomOut=new hm({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(s)},{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}}const pm={0:1,2:2};class dm{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=D.mouseButton(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),function(t,e){const i=pm[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&D.mouseButton(t)===this._eventButton&&(this._moved&&D.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mm extends dm{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class fm extends dm{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class _m extends dm{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class gm{constructor(t){this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new k(0,0)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);const r=lm(i,e),s=new k(0,0),n=new k(0,0);let a=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(s._add(e),n._add(e.sub(i)),a++,r[t]=e)}if(this._touches=r,a<this._minTouches||!n.mag())return;const o=n.div(a);return this._sum._add(o),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(a),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ym{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,s]=this._firstTwoTouches,n=xm(i,e,r),a=xm(i,e,s);if(!n||!a)return;const o=this._aroundCenter?null:n.add(a).div(2);return this._move([n,a],o,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,s]=this._firstTwoTouches,n=xm(i,e,r),a=xm(i,e,s);n&&a||(this._active&&D.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function xm(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function vm(t,e){return Math.log(t/e)/Math.LN2}class bm extends ym{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(vm(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:vm(this._distance,i),pinchAround:e}}}function wm(t,e){return 180*t.angleWith(e)/Math.PI}class Tm extends ym{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:wm(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=wm(t,this._startVector);return Math.abs(i)<e}}function Im(t){return Math.abs(t.y)>Math.abs(t.x)}class zm extends ym{reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(t){this._lastPoints=t,Im(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,s,i.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+s.y)/2*-.5}}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,s=e.mag()>=2;if(!r&&!s)return;if(!r||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return Im(t)&&Im(e)&&n}}const Sm={panStep:100,bearingStep:15,pitchStep:10};class Am{constructor(){const t=Sm;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,s=0,n=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?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const o=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Em,zoom:e?Math.round(o)+e*(t.shiftKey?2:1):o,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-s*this._panStep,-n*this._panStep],center:a.getCenter()},{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 Em(t){return t*(2-t)}const Cm=4.000244140625;class Pm{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._handler=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,f(["_onTimeout"],this)}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)}wheel(t){if(!this.isEnabled())return;let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=P.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Cm==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*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()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_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 e=D.mousePos(this._el,t);this._around=Gc.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(e)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Cm?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const e="number"==typeof this._targetZoom?this._targetZoom:t.zoom,i=this._startZoom,r=this._easing;let s,n=!1;if("wheel"===this._type&&i&&r){const t=Math.min((P.now()-this._lastWheelEventTime)/200,1);s=Re(i,e,r(t)),t<1?this._frameId||(this._frameId=!0):n=!0}else s=e,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!n,zoomDelta:s-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=o;if(this._prevEase){const t=this._prevEase,i=(P.now()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),s=.27/Math.sqrt(r*r+1e-4)*.01;e=a(s,Math.sqrt(.0729-s*s),.25,1)}return this._prevEase={start:P.now(),duration:t,easing:e},e}reset(){this._active=!1}}class km{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 Mm{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dm{constructor(){this._tap=new hm({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],s=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Lm{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Bm{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}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 Rm{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,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","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-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()}}const Fm=t=>t.zoom||t.drag||t.pitch||t.rotate;class Om extends ut{}function Vm(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Um{constructor(t,e){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Qd(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e),f(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)D.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)D.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new nm(e,t));const r=e.boxZoom=new om(e,t);this._add("boxZoom",r);const s=new um,n=new Mm;e.doubleClickZoom=new km(n,s),this._add("tapZoom",s),this._add("clickZoom",n);const a=new Dm;this._add("tapDragZoom",a);const o=e.touchPitch=new zm;this._add("touchPitch",o);const l=new fm(t),c=new _m(t);e.dragRotate=new Bm(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new mm(t),u=new gm(t);e.dragPan=new Lm(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new Tm,d=new bm;e.touchZoomRotate=new Rm(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]);const m=e.scrollZoom=new Pm(e,this);this._add("scrollZoom",m,["mousePan"]);const f=e.keyboard=new Am;this._add("keyboard",f),this._add("blockableMapEvent",new am(e));for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),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(Fm(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},s={},n={},a=t.touches,o=a?this._getMapTouches(a):void 0,l=o?D.touchPos(this._el,o):D.mousePos(this._el,t);for(const{handlerName:a,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(n,h,a)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,o),this.mergeHandlerResult(r,s,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(n[a]=c)}const c={};for(const t in this._previousActiveHandlers)n[t]||(c[t]=i);this._previousActiveHandlers=n,(Object.keys(c).length||Vm(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(n).length||Vm(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,e,i,r,s){if(!i)return;u(t,i);const n={handlerName:r,originalEvent:i.originalEvent||s};void 0!==i.zoomDelta&&(e.zoom=n),void 0!==i.panDelta&&(e.drag=n),void 0!==i.pitchDelta&&(e.pitch=n),void 0!==i.bearingDelta&&(e.rotate=n)}_applyChanges(){const t={},e={},i={};for(const[r,s,n]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new k(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),u(e,s),u(i,n);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,s=r.transform,n=r.style&&r.style.terrain;if(!(Vm(t)||n&&this._drag))return this._fireEvents(e,i,!0);let{panDelta:a,zoomDelta:o,bearingDelta:l,pitchDelta:c,around:h,pinchAround:u}=t;void 0!==u&&(h=u),r._stop(!0),h=h||r.transform.centerPoint;const p=s.pointLocation(a?h.sub(a):h);l&&(s.bearing+=l),c&&(s.pitch+=c),o&&(s.zoom+=o),n?e.drag&&!this._drag?(this._drag={center:s.centerPoint,lngLat:s.pointLocation(h),point:h,handlerName:e.drag.handlerName},r.fire(new ut("freezeElevation",{freeze:!0}))):this._drag&&i[this._drag.handlerName]?(r.fire(new ut("freezeElevation",{freeze:!1})),this._drag=null):e.drag&&this._drag&&(s.center=s.pointLocation(s.centerPoint.sub(a))):s.setLocationAtPoint(p,h),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,e,i){const r=Fm(this._eventsInProgress),s=Fm(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const t in n)this._fireEvent(t,n[t]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let o;for(const t in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],o=e[i]||r,a[`${t}end`]=o)}for(const t in a)this._fireEvent(t,a[t]);const l=Fm(this._eventsInProgress);if(i&&(r||s)&&!l){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t?(e(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:o})):(this._map.fire(new ut("moveend",{originalEvent:o})),e(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,e){this._map.fire(new ut(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Om("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Nm={extend:(t,...e)=>u(t,...e),run(t){t()},logToElement(t,e=!1,i="log"){const r=window.document.getElementById(i);r&&(e&&(r.innerHTML=""),r.innerHTML+=`<br>${t}`)}};class qm extends dt{constructor(t,e){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,f(["_renderFrameCallback"],this)}getCenter(){return new Gc(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,e,i){return t=k.convert(t).mult(-1),this.panTo(this.transform.center,u({offset:t},e),i)}panTo(t,e,i){return this.easeTo(u({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(u({zoom:t},e),i)}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,e,i){return this.easeTo(u({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,u({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(u({bearing:0,pitch:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=Xc.convert(t);const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,e,i,r){const s={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=u({padding:s,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){const t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}r.padding=u(s,r.padding);const n=this.transform,a=n.padding,o=n.project(Gc.convert(t)),l=n.project(Gc.convert(e)),c=o.rotate(-i*Math.PI/180),h=l.rotate(-i*Math.PI/180),p=new k(Math.max(c.x,h.x),Math.max(c.y,h.y)),d=new k(Math.min(c.x,h.x),Math.min(c.y,h.y)),m=p.sub(d),f=(n.width-(a.left+a.right+r.padding.left+r.padding.right))/m.x,_=(n.height-(a.top+a.bottom+r.padding.top+r.padding.bottom))/m.y;if(_<0||f<0)return void v("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const g=Math.min(n.scaleZoom(n.scale*Math.min(f,_)),r.maxZoom),y=k.convert(r.offset),x=new k((r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2).rotate(i*Math.PI/180),b=y.add(x).mult(n.scale/n.zoomScale(g));return{center:n.unproject(o.add(l).div(2).sub(b)),zoom:g,bearing:i}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,e,i,r,s){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(k.convert(t)),this.transform.pointLocation(k.convert(e)),i,r),r,s)}_fitInternal(t,e,i){return t?(delete(e=u(t,e)).padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop();const i=this.transform;let r=!1,s=!1,n=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(r=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=Gc.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(s=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(n=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),this.fire(new ut("movestart",e)).fire(new ut("move",e)),r&&this.fire(new ut("zoomstart",e)).fire(new ut("zoom",e)).fire(new ut("zoomend",e)),s&&this.fire(new ut("rotatestart",e)).fire(new ut("rotate",e)).fire(new ut("rotateend",e)),n&&this.fire(new ut("pitchstart",e)).fire(new ut("pitch",e)).fire(new ut("pitchend",e)),this.fire(new ut("moveend",e))}easeTo(t,e){this._stop(!1,t.easeId),(!1===(t=u({offset:[0,0],duration:500,easing:o},t)).animate||!t.essential&&P.prefersReducedMotion)&&(t.duration=0);const i=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:n,p="padding"in t?t.padding:i.padding,d=k.convert(t.offset);let m=i.centerPoint.add(d);const f=i.pointLocation(m),_=Gc.convert(t.center||f);this._normalizeCenter(_);const g=i.project(f),y=i.project(_).sub(g),x=i.zoomScale(l-r);let v,b;t.around&&(v=Gc.convert(t.around),b=i.locationPoint(v));const w={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||l!==r,this._rotating=this._rotating||s!==c,this._pitching=this._pitching||h!==n,this._padding=!i.isPaddingEqual(p),this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,w),this._ease((t=>{if(this._zooming&&(i.zoom=Re(r,l,t)),this._rotating&&(i.bearing=Re(s,c,t)),this._pitching&&(i.pitch=Re(n,h,t)),this._padding&&(i.interpolatePadding(a,p,t),m=i.centerPoint.add(d)),v)i.setLocationAtPoint(v,b);else{const e=i.zoomScale(i.zoom-r),s=l>r?Math.min(2,x):Math.max(.5,x),n=Math.pow(s,1-t),a=i.unproject(g.add(y.mult(t*n)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,m)}this._fireMoveEvents(e)}),(t=>{this._afterEase(e,t)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,this.fire(new ut("freezeElevation",{freeze:!0})),e||i.moving||this.fire(new ut("movestart",t)),this._zooming&&!i.zooming&&this.fire(new ut("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new ut("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new ut("pitchstart",t))}_fireMoveEvents(t){this.fire(new ut("move",t)),this._zooming&&this.fire(new ut("zoom",t)),this._rotating&&this.fire(new ut("rotate",t)),this._pitching&&this.fire(new ut("pitch",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)return;delete this._easeId,this.fire(new ut("freezeElevation",{freeze:!1}));const i=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new ut("zoomend",t)),r&&this.fire(new ut("rotateend",t)),s&&this.fire(new ut("pitchend",t)),this.fire(new ut("moveend",t))}flyTo(t,e){if(!t.essential&&P.prefersReducedMotion){const i=p(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,e)}this.stop(),t=u({offset:[0,0],speed:1.2,curve:1.42,easing:o},t);const i=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a=this.getPadding(),c="zoom"in t?l(+t.zoom,i.minZoom,i.maxZoom):r,h="bearing"in t?this._normalizeBearing(t.bearing,s):s,d="pitch"in t?+t.pitch:n,m="padding"in t?t.padding:i.padding,f=i.zoomScale(c-r),_=k.convert(t.offset);let g=i.centerPoint.add(_);const y=i.pointLocation(g),x=Gc.convert(t.center||y);this._normalizeCenter(x);const v=i.project(y),b=i.project(x).sub(v);let w=t.curve;const T=Math.max(i.width,i.height),I=T/f,z=b.mag();if("minZoom"in t){const e=l(Math.min(t.minZoom,r,c),i.minZoom,i.maxZoom),s=T/i.zoomScale(e-r);w=Math.sqrt(s/z*2)}const S=w*w;function A(t){const e=(I*I-T*T+(t?-1:1)*S*S*z*z)/(2*(t?I:T)*S*z);return Math.log(Math.sqrt(e*e+1)-e)}function E(t){return(Math.exp(t)-Math.exp(-t))/2}function C(t){return(Math.exp(t)+Math.exp(-t))/2}const M=A(0);let D=function(t){return C(M)/C(M+w*t)},L=function(t){return T*((C(M)*(E(e=M+w*t)/C(e))-E(M))/S)/z;var e},B=(A(1)-M)/w;if(Math.abs(z)<1e-6||!isFinite(B)){if(Math.abs(T-I)<1e-6)return this.easeTo(t,e);const i=I<T?-1:1;B=Math.abs(Math.log(I/T))/w,L=function(){return 0},D=function(t){return Math.exp(i*w*t)}}return t.duration="duration"in t?+t.duration:1e3*B/("screenSpeed"in t?+t.screenSpeed/w:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==h,this._pitching=d!==n,this._padding=!i.isPaddingEqual(m),this._prepareEase(e,!1),this._ease((t=>{const o=t*B,l=1/D(o);i.zoom=1===t?c:r+i.scaleZoom(l),this._rotating&&(i.bearing=Re(s,h,t)),this._pitching&&(i.pitch=Re(n,d,t)),this._padding&&(i.interpolatePadding(a,m,t),g=i.centerPoint.add(_));const u=1===t?x:i.unproject(v.add(b.mult(L(o))).mult(l));i.setLocationAtPoint(i.renderWorldCopies?u.wrap():u,g),this._fireMoveEvents(e)}),(()=>this._afterEase(e)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){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)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=P.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((P.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,e){t=c(t,-180,180);const i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}}class $m{constructor(t={}){this.options=t,f(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=D.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=D.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=D.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){D.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",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 i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_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","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||this._updateAttributions()}_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 i in e){const r=e[i];if(r.used){const e=r.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,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._editLink=null)}_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","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class jm{constructor(t={}){this.options=t,f(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=D.create("div","maplibregl-ctrl mapboxgl-ctrl");const e=D.create("a","maplibregl-ctrl-logo mapboxgl-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(){D.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_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","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class Zm{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,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Gm;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(Gm||(Gm={}));let Xm=null,Wm=[];const Hm=1e3/30,Km={mark(t){performance.mark(t)},frame(t){const e=t;null!=Xm&&Wm.push(e-Xm),Xm=e},clearMetrics(){Xm=null,Wm=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const t in Gm)performance.clearMarks(Gm[t])},getPerformanceMetrics(){performance.measure("loadTime",Gm.create,Gm.load),performance.measure("fullLoadTime",Gm.create,Gm.fullLoad);const t=performance.getEntriesByName("loadTime")[0].duration,e=performance.getEntriesByName("fullLoadTime")[0].duration,i=Wm.length,r=1/(Wm.reduce(((t,e)=>t+e),0)/i/1e3),s=Wm.filter((t=>t>Hm)).reduce(((t,e)=>t+(e-Hm)/Hm),0);return{loadTime:t,fullLoadTime:e,fps:r,percentDroppedFrames:s/(i+s)*100}}},Ym={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"},Jm={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},Qm={showCompass:!0,showZoom:!0,visualizePitch:!1};class tf{constructor(t,e,i=!1){this._clickTolerance=10,this.element=e,this.mouseRotate=new fm({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new _m({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),f(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),D.addEventListener(e,"mousedown",this.mousedown),D.addEventListener(e,"touchstart",this.touchstart,{passive:!1}),D.addEventListener(e,"touchmove",this.touchmove),D.addEventListener(e,"touchend",this.touchend),D.addEventListener(e,"touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),D.disableDrag()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;D.removeEventListener(t,"mousedown",this.mousedown),D.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),D.removeEventListener(t,"touchmove",this.touchmove),D.removeEventListener(t,"touchend",this.touchend),D.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){D.enableDrag(),D.removeEventListener(window,"mousemove",this.mousemove),D.removeEventListener(window,"mouseup",this.mouseup)}mousedown(t){this.down(u({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),D.mousePos(this.element,t)),D.addEventListener(window,"mousemove",this.mousemove),D.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.move(t,D.mousePos(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=D.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=D.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function ef(t,e,i){if(t=new Gc(t.lng,t.lat),e){const r=new Gc(t.lng-360,t.lat),s=new Gc(t.lng+360,t.lat),n=i.locationPoint(t).distSqr(e);i.locationPoint(r).distSqr(e)<n?t=r:i.locationPoint(s).distSqr(e)<n&&(t=s)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const rf={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 sf(t,e,i){const r=t.classList;for(const t in rf)r.remove(`maplibregl-${i}-anchor-${t}`,`mapboxgl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`,`mapboxgl-${i}-anchor-${e}`)}class nf extends dt{constructor(t,e){if(super(),(t instanceof HTMLElement||e)&&(t=u({element:t},e)),f(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),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._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,t&&t.element)this._element=t.element,this._offset=k.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=D.create("div"),this._element.setAttribute("aria-label","Map marker");const e=D.createNS("http://www.w3.org/2000/svg","svg"),i=41,r=27;e.setAttributeNS(null,"display","block"),e.setAttributeNS(null,"height",`${i}px`),e.setAttributeNS(null,"width",`${r}px`),e.setAttributeNS(null,"viewBox",`0 0 ${r} ${i}`);const s=D.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const n=D.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill-rule","nonzero");const a=D.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const o=[{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 o){const e=D.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),a.appendChild(e)}const l=D.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"fill",this._color);const c=D.createNS("http://www.w3.org/2000/svg","path");c.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"),l.appendChild(c);const h=D.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"opacity","0.25"),h.setAttributeNS(null,"fill","#000000");const u=D.createNS("http://www.w3.org/2000/svg","path");u.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"),h.appendChild(u);const p=D.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const d=D.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(8.0, 8.0)");const m=D.createNS("http://www.w3.org/2000/svg","circle");m.setAttributeNS(null,"fill","#000000"),m.setAttributeNS(null,"opacity","0.25"),m.setAttributeNS(null,"cx","5.5"),m.setAttributeNS(null,"cy","5.5"),m.setAttributeNS(null,"r","5.4999962");const f=D.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#FFFFFF"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962"),d.appendChild(m),d.appendChild(f),n.appendChild(a),n.appendChild(l),n.appendChild(h),n.appendChild(p),n.appendChild(d),e.appendChild(n),e.setAttributeNS(null,"height",i*this._scale+"px"),e.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(e),this._offset=k.convert(t&&t.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),sf(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",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("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),D.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Gc.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,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=ef(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let e="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?e=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(e=`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)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),D.setTransform(this._element,`${rf[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${e}`),this._map.style&&this._map.style.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const t=this._map.unproject(this._pos),e=40075016.686*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=t.distanceTo(this._lngLat)>20*e?"0.2":"1.0",this._opacityTimeout=null}),100))}getOffset(){return this._offset}setOffset(t){return this._offset=k.convert(t),this._update(),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 ut("dragstart"))),this.fire(new ut("drag")))}_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 ut("dragend")),this._state="inactive"}_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))}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}}const af={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let of,lf=0,cf=!1;const hf={maxWidth:100,unit:"metric"};function uf(t,e,i){const r=i&&i.maxWidth||100,s=t._container.clientHeight/2,n=t.unproject([0,s]),a=t.unproject([r,s]),o=n.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*o;i>5280?pf(e,r,i/5280,t._getUIString("ScaleControl.Miles")):pf(e,r,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?pf(e,r,o/1852,t._getUIString("ScaleControl.NauticalMiles")):o>=1e3?pf(e,r,o/1e3,t._getUIString("ScaleControl.Kilometers")):pf(e,r,o,t._getUIString("ScaleControl.Meters"))}function pf(t,e,i,r){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s} ${r}`}const df={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},mf=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ff(t){if(t){if("number"==typeof t){const e=Math.round(Math.sqrt(.5*Math.pow(t,2)));return{center:new k(0,0),top:new k(0,t),"top-left":new k(e,e),"top-right":new k(-e,e),bottom:new k(0,-t),"bottom-left":new k(e,-e),"bottom-right":new k(-e,-e),left:new k(t,0),right:new k(-t,0)}}if(t instanceof k||Array.isArray(t)){const e=k.convert(t);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:k.convert(t.center||[0,0]),top:k.convert(t.top||[0,0]),"top-left":k.convert(t["top-left"]||[0,0]),"top-right":k.convert(t["top-right"]||[0,0]),bottom:k.convert(t.bottom||[0,0]),"bottom-left":k.convert(t["bottom-left"]||[0,0]),"bottom-right":k.convert(t["bottom-right"]||[0,0]),left:k.convert(t.left||[0,0]),right:k.convert(t.right||[0,0])}}return ff(new k(0,0))}const _f={supported:t,setRTLTextPlugin:function(t,e,i=!1){if(Qr===Hr||Qr===Kr||Qr===Yr)throw new Error("setRTLTextPlugin cannot be called multiple times.");ts=P.resolveURL(t),Qr=Hr,Jr=e,is(),i||ns()},getRTLTextPluginStatus:ss,Map:class extends qm{constructor(t){var e;if(Km.mark(Gm.create),null!=(t=u({},Jm,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Gd(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new Zm,this._controls=[],this._mapId=m(),this._locale=u({},Ym,t.locale),this._clickTolerance=t.clickTolerance,this._pixelRatio=null!==(e=t.pixelRatio)&&void 0!==e?e:devicePixelRatio,this._requestManager=new ot(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),f(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),"undefined"!=typeof window&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new Um(this,t),this._hash=t.hash&&new Xd("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,u({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new $m({customAttribution:t.customAttribution})),t.maplibreLogo&&this.addControl(new jm,t.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 ut(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new ut(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new ut("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new pt(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new pt(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}resize(t){const e=this._containerDimensions(),i=e[0],r=e[1];this._resizeCanvas(i,r,this.getPixelRatio()),this.transform.resize(i,r),this.painter.resize(i,r,this.getPixelRatio());const s=!this._moving;return s&&(this.stop(),this.fire(new ut("movestart",t)).fire(new ut("move",t))),this.fire(new ut("resize",t)),s&&this.fire(new ut("moveend",t)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(t){const[e,i]=this._containerDimensions();this._pixelRatio=t,this._resizeCanvas(e,i,t),this.painter.resize(e,i,t)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(Xc.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=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?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>85)throw new Error("maxPitch must be less than or equal to 85");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(Gc.convert(t),this.style&&this.style.terrain)}unproject(t){return this.transform.pointLocation(k.convert(t),this.style&&this.style.terrain)}isMoving(){return this._moving||this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers.isRotating()}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const s=s=>{const n=this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[];n.length?r||(r=!0,i.call(this,new im(t,this,s.originalEvent,{features:n}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const s=s=>{(this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new im(t,this,s.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new im(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:n}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const s=this._delegatedListeners[t];for(let t=0;t<s.length;t++){const r=s[t];if(r.layer===e&&r.listener===i){for(const t in r.delegates)this.off(t,r.delegates[t]);return s.splice(t,1),this}}})(),this)}queryRenderedFeatures(t,e){if(!this.style)return[];let i;if(void 0!==e||void 0===t||t instanceof k||Array.isArray(t)||(e=t,t=void 0),e=e||{},(t=t||[[0,0],[this.transform.width,this.transform.height]])instanceof k||"number"==typeof t[0])i=[k.convert(t)];else{const e=k.convert(t[0]),r=k.convert(t[1]);i=[e,new k(r.x,e.y),r,new k(e.x,r.y),e]}return this.style.queryRenderedFeatures(i,e,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,e){return!1!==(e=u({},{localIdeographFontFamily:this._localIdeographFontFamily},e)).diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(t,e))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove()),t?(this.style=new Zu(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Zu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,e){if("string"==typeof t){const i=this._requestManager.transformRequest(t,H.Style);tt(i,((t,i)=>{t?this.fire(new pt(t)):i&&this._updateDiff(i,e)}))}else"object"==typeof t&&this._updateDiff(t,e)}_updateDiff(t,e){try{this.style.setState(t)&&this._update(!0)}catch(i){v(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():v("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 e=this.style&&this.style.sourceCaches[t];if(void 0!==e)return e.loaded();this.fire(new pt(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){return this.style.setTerrain(t),this}getTerrain(){return this.style.terrain&&this.style.terrain.options}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,e,{pixelRatio:i=1,sdf:r=!1,stretchX:s,stretchY:n,content:a}={}){if(this._lazyInitEmptyStyle(),e instanceof HTMLImageElement||C(e)){const{width:o,height:l,data:c}=P.getImageData(e);this.style.addImage(t,{data:new Ja({width:o,height:l},c),pixelRatio:i,stretchX:s,stretchY:n,content:a,sdf:r,version:0})}else{if(void 0===e.width||void 0===e.height)return this.fire(new pt(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:o,height:l,data:c}=e,h=e;this.style.addImage(t,{data:new Ja({width:o,height:l},new Uint8Array(c)),pixelRatio:i,stretchX:s,stretchY:n,content:a,sdf:r,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}}updateImage(t,e){const i=this.style.getImage(t);if(!i)return this.fire(new pt(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=e instanceof HTMLImageElement||C(e)?P.getImageData(e):e,{width:s,height:n,data:a}=r;if(void 0===s||void 0===n)return this.fire(new pt(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(s!==i.data.width||n!==i.data.height)return this.fire(new pt(new Error("The width and height of the updated image must be that same as the previous version of the image")));const o=!(e instanceof HTMLImageElement||C(e));i.data.replace(a,o),this.style.updateImage(t,i)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new pt(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t,e){at(this._requestManager.transformRequest(t,H.Image),e)}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)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}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","mapboxgl-map");const e=this._canvasContainer=D.create("div","maplibregl-canvas-container mapboxgl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=D.create("canvas","maplibregl-canvas mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const i=this._containerDimensions();this._resizeCanvas(i[0],i[1],this.getPixelRatio());const r=this._controlContainer=D.create("div","maplibregl-control-container mapboxgl-control-container",t),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{s[t]=D.create("div",`maplibregl-ctrl-${t} mapboxgl-ctrl-${t}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=i*t,this._canvas.height=i*e,this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const e=u({},t.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);i?(this.painter=new qd(i,this.transform),$.testSupport(i)):this.fire(new pt(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new ut("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new ut("webglcontextrestored",{originalEvent:t}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(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){let e,i=0;const r=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(e=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,e),i=P.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,e=P.now();this.style.zoomHistory.update(t,e);const i=new os(t,{now:e,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=i.crossFadingFactor();1===r&&r===this._crossFadingFactor||(s=!0,this._crossFadingFactor=r),this.style.update(i)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.style.terrain&&this.style.terrain.sourceCache.update(this.transform,this.style.terrain),this.transform.updateElevation(this.style.terrain),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new ut("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,Km.mark(Gm.load),this.fire(new ut("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const t=P.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,e),setTimeout((()=>{const i=r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(e),this.fire(new ut("gpu-timing-frame",{cpuTime:t,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const e=this.painter.queryGpuTimers(t);this.fire(new ut("gpu-timing-layer",{layerTimes:e}))}),50)}const n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new ut("idle")),!this._loaded||this._fullyLoaded||n||(this._fullyLoaded=!0,Km.mark(Gm.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),D.remove(this._canvasContainer),D.remove(this._controlContainer),this._container.classList.remove("maplibregl-map","mapboxgl-map"),Km.clearMetrics(),this._removed=!0,this.fire(new ut("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=P.frame((t=>{Km.frame(t),this._frame=null,this._render(t)})))}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}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()}_setCacheLimits(t,e){!function(t,e){O=t,V=e}(t,e)}},NavigationControl:class{constructor(t){this.options=u({},Qm,t),this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(f(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(f(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_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}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 tf(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){D.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 i=D.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}},GeolocateControl:class extends dt{constructor(t){super(),this.options=u({},af,t),f(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(t){var e;return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),e=this._setupUI,void 0!==of?e(of):void 0!==window.navigator.permissions?window.navigator.permissions.query({name:"geolocation"}).then((t=>{of="denied"!==t.state,e(of)})):(of=!!window.navigator.geolocation,e(of)),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(),D.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,lf=0,cf=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new ut("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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background")}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","mapboxgl-user-location-dot-stale"),this.fire(new ut("geolocate",t)),this._finish()}}_updateCamera(t){const e=new Gc(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=u({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(e.toBounds(i),r,{geolocateSource:!0})}_updateMarker(t){if(t){const e=new Gc(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([1,t]),r=e.distanceTo(i),s=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-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&&cf)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new ut("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=D.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){v("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.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=D.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new nf(this._dotElement),this._circleElement=D.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new nf({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this.fire(new ut("trackuserlocationend")))}))}trigger(){if(!this._setup)return v("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 ut("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":lf--,cf=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new ut("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new ut("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active")}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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),lf++,lf>1?(t={maximumAge:6e5,timeout:0},cf=!0):(t=this.options.positionOptions,cf=!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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:$m,LogoControl:jm,ScaleControl:class{constructor(t){this.options=u({},hf,t),f(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){uf(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){D.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,uf(this._map,this._container,this.options)}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:v("Full screen control 'container' must be a DOM element.")),f(["_onClickFullscreen","_changeIcon"],this),"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=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",v("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){D.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=D.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_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}_changeIcon(){(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?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._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},TerrainControl:class{constructor(t){this.options=t,f(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._terrainButton=D.create("button","maplibregl-ctrl-terrain mapboxgl-ctrl-terrain",this._container),D.create("span","maplibregl-ctrl-icon mapboxgl-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(){D.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._map.style.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends dt{constructor(t){super(),this.options=u(Object.create(df),t),f(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new ut("open")),this}isOpen(){return!!this._map}remove(){return this._content&&D.remove(this._content),this._container&&(D.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),delete this._map),this.fire(new ut("close")),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Gc.convert(t),this._pos=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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){return this._container&&this._container.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=D.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=D.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(t){this._update(t.point)}_onMouseMove(t){this._update(t.point)}_onDrag(t){this._update(t.point)}_update(t){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(this._container||(this._container=D.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=D.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((t=>this._container.classList.add(t))),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),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=ef(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let i=this.options.anchor;const r=ff(this.options.offset);if(!i){const t=this._container.offsetWidth,s=this._container.offsetHeight;let n;n=e.y+r.bottom.y<s?["top"]:e.y>this._map.transform.height-s?["bottom"]:[],e.x<t/2?n.push("left"):e.x>this._map.transform.width-t/2&&n.push("right"),i=0===n.length?"bottom":n.join("-")}const s=e.add(r[i]).round();D.setTransform(this._container,`${rf[i]} translate(${s.x}px,${s.y}px)`),sf(this._container,i,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(mf);t&&t.focus()}_onClose(){this.remove()}},Marker:nf,Style:Zu,LngLat:Gc,LngLatBounds:Xc,Point:k,MercatorCoordinate:th,Evented:dt,AJAXError:K,config:L,CanvasSource:fh,GeoJSONSource:uh,ImageSource:dh,RasterDEMTileSource:hh,RasterTileSource:rh,VectorTileSource:ih,VideoSource:mh,prewarm:function(){Bh().acquire(kh)},clearPrewarmedResources:function(){const t=Lh;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(kh),Lh=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()"))},get workerCount(){return Mh.workerCount},set workerCount(t){Mh.workerCount=t},get maxParallelImageRequests(){return L.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){L.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){!function(t){const e=caches.delete(B);t&&e.catch(t).then((()=>t()))}(t)},workerUrl:"",addProtocol(t,e){L.REGISTERED_PROTOCOLS[t]=e},removeProtocol(t){delete L.REGISTERED_PROTOCOLS[t]}};return Nm.extend(_f,{isSafari:E,getPerformanceMetrics:Km.getPerformanceMetrics}),_f}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).maplibregl=e()}(this,(function(){"use strict";var t=e;function e(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl",r)||i.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var r}(t)}var i={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var r=s;function s(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}function n(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!n(t[i],e[i]))return!1;return!0}return t===e}function a(t,e,i,s){const n=new r(t,e,i,s);return function(t){return n.solve(t)}}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 i=t,r=0;r<8;r++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var n=this.sampleCurveDerivativeX(i);if(Math.abs(n)<1e-6)break;i-=s/n}var a=0,o=1;for(i=t,r=0;r<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));r++)t>s?a=i:o=i,i=.5*(o-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};const o=a(.25,.1,.25,1);function l(t,e,i){return Math.min(i,Math.max(e,t))}function c(t,e,i){const r=i-e,s=((t-e)%r+r)%r+e;return s===e?i:s}function h(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const s=new Array(t.length);let n=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(n=t),s[a]=e,0==--r&&i(n,s)}))}))}function u(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function p(t,e){const i={};for(let r=0;r<e.length;r++){const s=e[r];s in t&&(i[s]=t[s])}return i}let d=1;function m(){return d++}function f(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function _(t,e,i){const r={};for(const s in t)r[s]=e.call(i||this,t[s],s,t);return r}function g(t,e,i){const r={};for(const s in t)e.call(i||this,t[s],s,t)&&(r[s]=t[s]);return r}function y(t){return Array.isArray(t)?t.map(y):"object"==typeof t&&t?_(t,y):t}const x={};function v(t){x[t]||("undefined"!=typeof console&&console.warn(t),x[t]=!0)}function b(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function w(t){let e=0;for(let i,r,s=0,n=t.length,a=n-1;s<n;a=s++)i=t[s],r=t[a],e+=(r.x-i.x)*(i.y+r.y);return e}function T(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function I(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,s)=>{const n=r||s;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let S,A,z=null;function E(t){if(null==z){const e=t.navigator?t.navigator.userAgent:null;z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return z}function C(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const P={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const i=window.document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return i.width=t.width,i.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:t=>(S||(S=document.createElement("a")),S.href=t,S.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==A&&(A=matchMedia("(prefers-reduced-motion: reduce)")),A.matches)}};var k=M;function M(t,e){this.x=t,this.y=e}M.prototype={clone:function(){return new M(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,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},M.convert=function(t){return t instanceof M?t:Array.isArray(t)?new M(t[0],t[1]):t};class D{static testProp(t){if(!D.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in D.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){D.docStyle&&D.selectProp&&(D.userSelect=D.docStyle[D.selectProp],D.docStyle[D.selectProp]="none")}static enableDrag(){D.docStyle&&D.selectProp&&(D.docStyle[D.selectProp]=D.userSelect)}static setTransform(t,e){t.style[D.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",D.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",D.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",D.suppressClickInternal,!0)}),0)}static mousePos(t,e){const i=t.getBoundingClientRect();return new k(e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop)}static touchPos(t,e){const i=t.getBoundingClientRect(),r=[];for(let s=0;s<e.length;s++)r.push(new k(e[s].clientX-i.left-t.clientLeft,e[s].clientY-i.top-t.clientTop));return r}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}}D.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,D.selectProp=D.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),D.transformProp=D.testProp(["transform","WebkitTransform"]);const L={MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},B="mapbox-tiles";let R,F,O=500,V=50;function U(){"undefined"==typeof caches||R||(R=caches.open(B))}let N=1/0;function $(t){N++,N>V&&(t.getActor().send("enforceCacheSizeLimit",O),N=0)}const q={supported:!1,testSupport:function(t){!G&&Z&&(X?W(t):j=t)}};let j,Z,G=!1,X=!1;function W(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Z),t.isContextLost())return;q.supported=!0}catch(t){}t.deleteTexture(e),G=!0}"undefined"!=typeof document&&(Z=document.createElement("img"),Z.onload=function(){j&&W(j),j=null,X=!0},Z.onerror=function(){G=!0,j=null},Z.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const H={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(H);class K extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const Y=T()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href;function J(t,e){const i=new AbortController,r=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Y(),signal:i.signal});let s=!1,n=!1;"json"===t.type&&r.headers.set("Accept","application/json");return((i,a,o)=>{if(n)return;const l=Date.now();fetch(r).then((i=>i.ok?((i,a,o)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{n||(a&&o&&function(t,e,i){if(U(),!R)return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const s=I(e.headers.get("Cache-Control")||"");s["no-store"]||(s["max-age"]&&r.headers.set("Expires",new Date(i+1e3*s["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-i<42e4||function(t,e){if(void 0===F)try{new Response(new ReadableStream),F=!0}catch(t){F=!1}F?e(t.body):t.blob().then(e)}(e,(e=>{const i=new Response(e,r);U(),R&&R.then((e=>e.put(function(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}(t.url),i))).catch((t=>v(t.message)))})))}(r,a,o),s=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{n||e(new Error(t.message))}))})(i,null,l):i.blob().then((r=>e(new K(i.status,i.statusText,t.url,r)))))).catch((t=>{20!==t.code&&e(new Error(t.message))}))})(),{cancel:()=>{n=!0,s||i.abort()}}}const Q=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!T()){const i=t.url.substring(0,t.url.indexOf("://"));return(L.REGISTERED_PROTOCOLS[i]||J)(t,e)}}if(!(/^file:/.test(i=t.url)||/^file:/.test(Y())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return J(t,e);if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else{const r=new Blob([i.response],{type:i.getResponseHeader("Content-Type")});e(new K(i.status,i.statusText,t.url,r))}},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},tt=function(t,e){return Q(u(t,{type:"json"}),e)},et=function(t,e){return Q(u(t,{type:"arrayBuffer"}),e)};function it(t){const e=window.document.createElement("a");return e.href=t,e.protocol===window.document.location.protocol&&e.host===window.document.location.host}const rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let st,nt;st=[],nt=0;const at=function(t,e){if(q.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),nt>=L.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return st.push(i),i}nt++;let i=!1;const r=()=>{if(!i)for(i=!0,nt--;st.length&&nt<L.MAX_PARALLEL_IMAGE_REQUESTS;){const t=st.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=at(e,i).cancel)}},s=et(t,((t,i,s,n)=>{r(),t?e(t):i&&function(t,e){"function"==typeof createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(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.`))}))}(t,e):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame((()=>{i.src=rt}))},i.onerror=()=>e(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 r=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(r):rt}(t,e)}(i,((t,i)=>{null!=t?e(t):null!=i&&e(null,i,{cacheControl:s,expires:n})}))}));return{cancel:()=>{s.cancel(),r()}}};class ot{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeSpriteURL(t,e,i){const r=function(t){const e=t.match(lt);if(!e)throw new Error(`Unable to parse URL "${t}"`);return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}(t);return r.path+=`${e}${i}`,function(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}(r)}setTransformRequest(t){this._transformRequestFn=t}}const lt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ct(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function ht(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class ut{constructor(t,e={}){u(this,e),this.type=t}}class pt extends ut{constructor(t,e={}){super("error",u({error:t},e))}}class dt{on(t,e){return this._listeners=this._listeners||{},ct(t,e,this._listeners),this}off(t,e){return ht(t,e,this._listeners),ht(t,e,this._oneTimeListeners),this}once(t,e){return this._oneTimeListeners=this._oneTimeListeners||{},ct(t,e,this._oneTimeListeners),this}fire(t,e){"string"==typeof t&&(t=new ut(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)ht(i,e,this._oneTimeListeners),e.call(this,t);const s=this._eventedParent;s&&(u(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof pt&&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 mt={$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"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"string"},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:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{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-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":{},within:{}}},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}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1},elevationOffset:{type:"number",default:450}},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"}}};class ft{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function _t(t){const e=t.value;return e?[new ft(t.key,e,"constants have been deprecated as of v8")]:[]}function gt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function yt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function xt(t){if(Array.isArray(t))return t.map(xt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=xt(t[i]);return e}return yt(t)}class vt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class bt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new bt(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 wt={kind:"null"},Tt={kind:"number"},It={kind:"string"},St={kind:"boolean"},At={kind:"color"},zt={kind:"object"},Et={kind:"value"},Ct={kind:"collator"},Pt={kind:"formatted"},kt={kind:"padding"},Mt={kind:"resolvedImage"};function Dt(t,e){return{kind:"array",itemType:t,N:e}}function Lt(t){if("array"===t.kind){const e=Lt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Bt=[wt,Tt,It,St,At,Pt,zt,Dt(Et),kt,Mt];function Rt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Rt(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 Bt)if(!Rt(t,e))return null}return`Expected ${Lt(t)} but found ${Lt(e)} instead.`}function Ft(t,e){return e.some((e=>e.kind===t.kind))}function Ot(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))}var Vt,Ut={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Nt(t){return(t=Math.round(t))<0?0:t>255?255:t}function $t(t){return Nt("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function qt(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function jt(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Vt={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Ut)return Ut[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var r=i.indexOf("("),s=i.indexOf(")");if(-1!==r&&s+1===i.length){var n=i.substr(0,r),a=i.substr(r+1,s-(r+1)).split(","),o=1;switch(n){case"rgba":if(4!==a.length)return null;o=qt(a.pop());case"rgb":return 3!==a.length?null:[$t(a[0]),$t(a[1]),$t(a[2]),o];case"hsla":if(4!==a.length)return null;o=qt(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,c=qt(a[1]),h=qt(a[2]),u=h<=.5?h*(c+1):h+c-h*c,p=2*h-u;return[Nt(255*jt(p,u,l+1/3)),Nt(255*jt(p,u,l)),Nt(255*jt(p,u,l-1/3)),o];default:return null}}return null}}catch(t){}class Zt{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Zt)return t;if("string"!=typeof t)return;const e=Vt(t);return e?new Zt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}Zt.black=new Zt(0,0,0,1),Zt.white=new Zt(1,1,1,1),Zt.transparent=new Zt(0,0,0,0),Zt.red=new Zt(1,0,0,1);class Gt{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,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 Xt{constructor(t,e,i,r,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=s}}class Wt{constructor(t){this.sections=t}static fromString(t){return new Wt([new Xt(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 Wt?t:Wt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Ht{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ht)return t;if("number"==typeof t)return new Ht([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 Ht(t)}}toString(){return JSON.stringify(this.values)}}class Kt{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Kt({name:t,available:!1}):null}}function Yt(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Jt(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Zt)return!0;if(t instanceof Gt)return!0;if(t instanceof Wt)return!0;if(t instanceof Ht)return!0;if(t instanceof Kt)return!0;if(Array.isArray(t)){for(const e of t)if(!Jt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Jt(t[e]))return!1;return!0}return!1}function Qt(t){if(null===t)return wt;if("string"==typeof t)return It;if("boolean"==typeof t)return St;if("number"==typeof t)return Tt;if(t instanceof Zt)return At;if(t instanceof Gt)return Ct;if(t instanceof Wt)return Pt;if(t instanceof Ht)return kt;if(t instanceof Kt)return Mt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Qt(e);if(i){if(i===t)continue;i=Et;break}i=t}return Dt(i||Et,e)}return zt}function te(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Zt||t instanceof Wt||t instanceof Ht||t instanceof Kt?t.toString():JSON.stringify(t)}class ee{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(!Jt(t[1]))return e.error("invalid value");const i=t[1];let r=Qt(i);const s=e.expectedType;return"array"!==r.kind||0!==r.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(r=s),new ee(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class ie{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const re={string:It,number:Tt,boolean:St,object:zt};class se{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 i,r=1;const s=t[0];if("array"===s){let s,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in re)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=re[i],r++}else s=Et;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);n=t[2],r++}i=Dt(s,n)}else i=re[s];const n=[];for(;r<t.length;r++){const i=e.parse(t[r],r,Et);if(!i)return null;n.push(i)}return new se(i,n)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Rt(this.type,Qt(i)))return i;if(e===this.args.length-1)throw new ie(`Expected value to be of type ${Lt(this.type)}, but found ${Lt(Qt(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const ne={"to-boolean":St,"to-color":At,"to-number":Tt,"to-string":It};class ae{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 i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=ne[i],s=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,Et);if(!r)return null;s.push(r)}return new ae(r,s)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof Zt)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Yt(e[0],e[1],e[2],e[3]),!i))return new Zt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ie(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}if("padding"===this.type.kind){let e;for(const i of this.args){e=i.evaluate(t);const r=Ht.parse(e);if(r)return r}throw new ie(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new ie(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Wt.fromString(te(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Kt.fromString(te(this.args[0].evaluate(t))):te(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const oe=["Unknown","Point","LineString","Polygon"];class le{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?oe[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]=Zt.parse(t)),e}}class ce{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],r=ce.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(r)?r[0]:r.type,n=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=n.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[r,n]of a){o=new Me(e.registry,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],s=Array.isArray(r)?r[e-1]:r.type,n=o.parse(i,1+a.length,s);if(!n){l=!0;break}a.push(n)}if(!l)if(Array.isArray(r)&&r.length!==a.length)o.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let t=0;t<a.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=a[t];o.concat(t+1).checkSubtype(e,i.type)}if(0===o.errors.length)return new ce(i,s,n,a)}}if(1===a.length)e.errors.push(...o.errors);else{const i=(a.length?a:n).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Lt).join(", ")})`:`(${Lt(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const s=e.parse(t[i],1+r.length);if(!s)return null;r.push(Lt(s.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){ce.definitions=e;for(const i in e)t[i]=ce}}class he{constructor(t,e,i){this.type=Ct,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,St);if(!r)return null;const s=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,St);if(!s)return null;let n=null;return i.locale&&(n=e.parse(i.locale,1,It),!n)?null:new he(r,s,n)}evaluate(t){return new Gt(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}}const ue=8192;function pe(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 de(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function me(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*ue),Math.round(r*s*ue)]}function fe(t,e,i){const r=t[0]-e[0],s=t[1]-e[1],n=t[0]-i[0],a=t[1]-i[1];return r*a-n*s==0&&r*n<=0&&s*a<=0}function _e(t,e){let i=!1;for(let a=0,o=e.length;a<o;a++){const o=e[a];for(let e=0,a=o.length;e<a-1;e++){if(fe(t,o[e],o[e+1]))return!1;(s=o[e])[1]>(r=t)[1]!=(n=o[e+1])[1]>r[1]&&r[0]<(n[0]-s[0])*(r[1]-s[1])/(n[1]-s[1])+s[0]&&(i=!i)}}var r,s,n;return i}function ge(t,e){for(let i=0;i<e.length;i++)if(_e(t,e[i]))return!0;return!1}function ye(t,e,i,r){const s=r[0]-i[0],n=r[1]-i[1],a=(t[0]-i[0])*n-s*(t[1]-i[1]),o=(e[0]-i[0])*n-s*(e[1]-i[1]);return a>0&&o<0||a<0&&o>0}function xe(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(o=[(a=c[i+1])[0]-(n=c[i])[0],a[1]-n[1]])[0]*(l=[(s=e)[0]-(r=t)[0],s[1]-r[1]])[1]-o[1]*l[0]&&ye(r,s,n,a)&&ye(n,a,r,s))return!0;var r,s,n,a,o,l;return!1}function ve(t,e){for(let i=0;i<t.length;++i)if(!_e(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(xe(t[i],t[i+1],e))return!1;return!0}function be(t,e){for(let i=0;i<e.length;i++)if(ve(t,e[i]))return!0;return!1}function we(t,e,i){const r=[];for(let s=0;s<t.length;s++){const n=[];for(let r=0;r<t[s].length;r++){const a=me(t[s][r],i);pe(e,a),n.push(a)}r.push(n)}return r}function Te(t,e,i){const r=[];for(let s=0;s<t.length;s++){const n=we(t[s],e,i);r.push(n)}return r}function Ie(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let s=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===s&&(s=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=s}pe(e,t)}function Se(t,e,i,r){const s=Math.pow(2,r.z)*ue,n=[r.x*ue,r.y*ue],a=[];for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];Ie(r,e,i,s),a.push(r)}return a}function Ae(t,e,i,r){const s=Math.pow(2,r.z)*ue,n=[r.x*ue,r.y*ue],a=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];pe(e,i),t.push(i)}a.push(t)}if(e[2]-e[0]<=s/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const r of t)Ie(r,e,i,s)}var o;return a}class ze{constructor(t,e){this.type=St,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(Jt(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new ze(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new ze(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new ze(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=we(e.coordinates,r,s),a=Se(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!_e(t,n))return!1}if("MultiPolygon"===e.type){const n=Te(e.coordinates,r,s),a=Se(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!ge(t,n))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=we(e.coordinates,r,s),a=Ae(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!ve(t,n))return!1}if("MultiPolygon"===e.type){const n=Te(e.coordinates,r,s),a=Ae(t.geometry(),i,r,s);if(!de(i,r))return!1;for(const t of a)if(!be(t,n))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}function Ee(t){if(t instanceof ce){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 ze)return!1;let e=!0;return t.eachChild((t=>{e&&!Ee(t)&&(e=!1)})),e}function Ce(t){if(t instanceof ce&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Ce(t)&&(e=!1)})),e}function Pe(t,e){if(t instanceof ce&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Pe(t,e)&&(i=!1)})),i}class ke{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ke(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class Me{constructor(t,e=[],i,r=new bt,s=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=s,this.expectedType=i}parse(t,e,i,r,s={}){return e?this.concat(e,i,r)._parse(t,s):this._parse(t,s)}_parse(t,e){function i(t,e,i){return"assert"===i?new se(e,[t]):"coerce"===i?new ae(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 r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[r];if(s){let r=s.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,s=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==s.kind&&"string"!==s.kind)if("padding"!==t.kind||"value"!==s.kind&&"number"!==s.kind&&"array"!==s.kind){if(this.checkSubtype(t,s))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ee)&&"resolvedImage"!==r.type.kind&&De(r)){const t=new le;try{r=new ee(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,s=i?this.scope.concat(i):this.scope;return new Me(this.registry,r,e||null,s,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new vt(i,t))}checkSubtype(t,e){const i=Rt(t,e);return i&&this.error(i),i}}function De(t){if(t instanceof ke)return De(t.boundExpression);if(t instanceof ce&&"error"===t.name)return!1;if(t instanceof he)return!1;if(t instanceof ze)return!1;const e=t instanceof ae||t instanceof se;let i=!0;return t.eachChild((t=>{i=e?i&&De(t):i&&t instanceof ee})),!!i&&Ee(t)&&Pe(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Le(t,e){const i=t.length-1;let r,s,n=0,a=i,o=0;for(;n<=a;)if(o=Math.floor((n+a)/2),r=t[o],s=t[o+1],r<=e){if(o===i||e<s)return o;n=o+1}else{if(!(r>e))throw new ie("Input is not a number.");a=o-1}return 0}class Be{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)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 i=e.parse(t[1],1,Tt);if(!i)return null;const r=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let i=1;i<t.length;i+=2){const n=1===i?-1/0:t[i],a=t[i+1],o=i,l=i+1;if("number"!=typeof n)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(r.length&&r[r.length-1][0]>=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(a,l,s);if(!c)return null;s=s||c.type,r.push([n,c])}return new Be(s,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;return r>=e[s-1]?i[s-1].evaluate(t):i[Le(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Re(t,e,i){return t*(1-i)+e*i}var Fe=Object.freeze({__proto__:null,number:Re,color:function(t,e,i){return new Zt(Re(t.r,e.r,i),Re(t.g,e.g,i),Re(t.b,e.b,i),Re(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>Re(t,e[r],i)))},padding:function(t,e,i){const r=t.values,s=e.values;return new Ht([Re(r[0],s[0],i),Re(r[1],s[1],i),Re(r[2],s[2],i),Re(r[3],s[3],i)])}});const Oe=.95047,Ve=1.08883,Ue=4/29,Ne=6/29,$e=3*Ne*Ne,qe=Math.PI/180,je=180/Math.PI;function Ze(t){return t>.008856451679035631?Math.pow(t,1/3):t/$e+Ue}function Ge(t){return t>Ne?t*t*t:$e*(t-Ue)}function Xe(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function We(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function He(t){const e=We(t.r),i=We(t.g),r=We(t.b),s=Ze((.4124564*e+.3575761*i+.1804375*r)/Oe),n=Ze((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*n-16,a:500*(s-n),b:200*(n-Ze((.0193339*e+.119192*i+.9503041*r)/Ve)),alpha:t.a}}function Ke(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ge(e),i=Oe*Ge(i),r=Ve*Ge(r),new Zt(Xe(3.2404542*i-1.5371385*e-.4985314*r),Xe(-.969266*i+1.8760108*e+.041556*r),Xe(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Ye(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Je={forward:He,reverse:Ke,interpolate:function(t,e,i){return{l:Re(t.l,e.l,i),a:Re(t.a,e.a,i),b:Re(t.b,e.b,i),alpha:Re(t.alpha,e.alpha,i)}}},Qe={forward:function(t){const{l:e,a:i,b:r}=He(t),s=Math.atan2(r,i)*je;return{h:s<0?s+360:s,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*qe,i=t.c;return Ke({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Ye(t.h,e.h,i),c:Re(t.c,e.c,i),l:Re(t.l,e.l,i),alpha:Re(t.alpha,e.alpha,i)}}};var ti=Object.freeze({__proto__:null,lab:Je,hcl:Qe});class ei{constructor(t,e,i,r,s){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of s)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,s){let n=0;if("exponential"===t.name)n=ii(e,t.base,i,s);else if("linear"===t.name)n=ii(e,1,i,s);else if("cubic-bezier"===t.name){const a=t.controlPoints;n=new r(a[0],a[1],a[2],a[3]).solve(ii(e,1,i,s))}return n}static parse(t,e){let[i,r,s,...n]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((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);r={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(s=e.parse(s,2,Tt),!s)return null;const a=[];let o=null;"interpolate-hcl"===i||"interpolate-lab"===i?o=At:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t<n.length;t+=2){const i=n[t],r=n[t+1],s=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(a.length&&a[a.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(r,l,o);if(!c)return null;o=o||c.type,a.push([i,c])}return"number"===o.kind||"color"===o.kind||"padding"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new ei(o,i,r,s,a):e.error(`Type ${Lt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;if(r>=e[s-1])return i[s-1].evaluate(t);const n=Le(e,r),a=ei.interpolationFactor(this.interpolation,r,e[n],e[n+1]),o=i[n].evaluate(t),l=i[n+1].evaluate(t);return"interpolate"===this.operator?Fe[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?Qe.reverse(Qe.interpolate(Qe.forward(o),Qe.forward(l),a)):Je.reverse(Je.interpolate(Je.forward(o),Je.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ii(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}class ri{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 i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const s=[];for(const r of t.slice(1)){const t=e.parse(r,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,s.push(t)}const n=r&&s.some((t=>Rt(r,t.type)));return new ri(n?Et:i,s)}evaluate(t){let e,i=null,r=0;for(const s of this.args)if(r++,i=s.evaluate(t),i&&i instanceof Kt&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class si{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 i=[];for(let r=1;r<t.length-1;r+=2){const s=t[r];if("string"!=typeof s)return e.error(`Expected string, but found ${typeof s} instead.`,r);if(/[^a-zA-Z0-9_]/.test(s))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const n=e.parse(t[r+1],r+1);if(!n)return null;i.push([s,n])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new si(i,r):null}outputDefined(){return this.result.outputDefined()}}class ni{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Tt),r=e.parse(t[2],2,Dt(e.expectedType||Et));return i&&r?new ni(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new ie(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new ie(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ie(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ai{constructor(t,e){this.type=St,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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Et);return i&&r?Ft(i.type,[St,It,Tt,wt,Et])?new ai(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Lt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Ot(e,["boolean","string","number","null"]))throw new ie(`Expected first argument to be of type boolean, string, number or null, but found ${Lt(Qt(e))} instead.`);if(!Ot(i,["string","array"]))throw new ie(`Expected second argument to be of type array or string, but found ${Lt(Qt(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class oi{constructor(t,e,i){this.type=Tt,this.needle=t,this.haystack=e,this.fromIndex=i}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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Et);if(!i||!r)return null;if(!Ft(i.type,[St,It,Tt,wt,Et]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Lt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Tt);return s?new oi(i,r,s):null}return new oi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Ot(e,["boolean","string","number","null"]))throw new ie(`Expected first argument to be of type boolean, string, number or null, but found ${Lt(Qt(e))} instead.`);if(!Ot(i,["string","array"]))throw new ie(`Expected second argument to be of type array or string, but found ${Lt(Qt(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class li{constructor(t,e,i,r,s,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=s,this.otherwise=n}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 i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const s={},n=[];for(let a=2;a<t.length-1;a+=2){let o=t[a];const l=t[a+1];Array.isArray(o)||(o=[o]);const c=e.concat(a);if(0===o.length)return c.error("Expected at least one branch label.");for(const t of o){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.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(i){if(c.checkSubtype(i,Qt(t)))return null}else i=Qt(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=n.length}const h=e.parse(l,a,r);if(!h)return null;r=r||h.type,n.push(h)}const a=e.parse(t[1],1,Et);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,r);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(i,a.type)?null:new li(i,r,a,s,n,o):null}evaluate(t){const e=this.input.evaluate(t);return(Qt(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 ci{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}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 i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let s=1;s<t.length-1;s+=2){const n=e.parse(t[s],s,St);if(!n)return null;const a=e.parse(t[s+1],s+1,i);if(!a)return null;r.push([n,a]),i=i||a.type}const s=e.parse(t[t.length-1],t.length-1,i);return s?new ci(i,r,s):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}}class hi{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=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 i=e.parse(t[1],1,Et),r=e.parse(t[2],2,Tt);if(!i||!r)return null;if(!Ft(i.type,[Dt(Et),It,Et]))return e.error(`Expected first argument to be of type array or string, but found ${Lt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Tt);return s?new hi(i.type,i,r,s):null}return new hi(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Ot(e,["string","array"]))throw new ie(`Expected first argument to be of type array or string, but found ${Lt(Qt(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function ui(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 pi(t,e,i,r){return 0===r.compare(e,i)}function di(t,e,i){const r="=="!==t&&"!="!==t;return class s{constructor(t,e,i){this.type=St,this.lhs=t,this.rhs=e,this.collator=i,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 i=t[0];let n=e.parse(t[1],1,Et);if(!n)return null;if(!ui(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Lt(n.type)}'.`);let a=e.parse(t[2],2,Et);if(!a)return null;if(!ui(i,a.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Lt(a.type)}'.`);if(n.type.kind!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Lt(n.type)}' and '${Lt(a.type)}'.`);r&&("value"===n.type.kind&&"value"!==a.type.kind?n=new se(a.type,[n]):"value"!==n.type.kind&&"value"===a.type.kind&&(a=new se(n.type,[a])));let o=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ct),!o)return null}return new s(n,a,o)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(r&&this.hasUntypedArgument){const e=Qt(n),i=Qt(a);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ie(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Qt(n),i=Qt(a);if("string"!==t.kind||"string"!==i.kind)return e(s,n,a)}return this.collator?i(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const mi=di("==",(function(t,e,i){return e===i}),pi),fi=di("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!pi(0,e,i,r)})),_i=di("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),gi=di(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),yi=di("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),xi=di(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class vi{constructor(t,e,i,r,s){this.type=It,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Tt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=e.parse(r.locale,1,It),!s))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,It),!n))return null;let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,Tt),!a))return null;let o=null;return r["max-fraction-digits"]&&(o=e.parse(r["max-fraction-digits"],1,Tt),!o)?null:new vi(i,s,n,a,o)}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 bi{constructor(t){this.type=Pt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let s=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(s&&"object"==typeof n&&!Array.isArray(n)){s=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,Tt),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,Dt(It)),!i))return null;let a=null;if(n["text-color"]&&(a=e.parse(n["text-color"],1,At),!a))return null;const o=r[r.length-1];o.scale=t,o.font=i,o.textColor=a}else{const n=e.parse(t[i],1,Et);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new bi(r)}evaluate(t){return new Wt(this.sections.map((e=>{const i=e.content.evaluate(t);return Qt(i)===Mt?new Xt("",i,null,null,null):new Xt(te(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}}class wi{constructor(t){this.type=Mt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,It);return i?new wi(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Kt.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ti{constructor(t){this.type=Tt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Lt(i.type)} instead.`):new Ti(i):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 ie(`Expected value to be of type string or array, but found ${Lt(Qt(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Ii={"==":mi,"!=":fi,">":gi,"<":_i,">=":xi,"<=":yi,array:se,at:ni,boolean:se,case:ci,coalesce:ri,collator:he,format:bi,image:wi,in:ai,"index-of":oi,interpolate:ei,"interpolate-hcl":ei,"interpolate-lab":ei,length:Ti,let:si,literal:ee,match:li,number:se,"number-format":vi,object:se,slice:hi,step:Be,string:se,"to-boolean":ae,"to-color":ae,"to-number":ae,"to-string":ae,var:ke,within:ze};function Si(t,[e,i,r,s]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const n=s?s.evaluate(t):1,a=Yt(e,i,r,n);if(a)throw new ie(a);return new Zt(e/255*n,i/255*n,r/255*n,n)}function Ai(t,e){return t in e}function zi(t,e){const i=e[t];return void 0===i?null:i}function Ei(t){return{type:t}}function Ci(t){return{result:"success",value:t}}function Pi(t){return{result:"error",value:t}}function ki(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Mi(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Di(t){return!!t.expression&&t.expression.interpolated}function Li(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Bi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ri(t){return t}function Fi(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],s=r||!(r||void 0!==t.property),n=t.type||(Di(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?Zt.parse:Ht.parse;(t=gt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==t.colorSpace&&!ti[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let a,o,l;if("exponential"===n)a=Ni;else if("interval"===n)a=Ui;else if("categorical"===n){a=Vi,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);a=$i}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const s=t.stops[e],n=s[0].zoom;void 0===i[n]&&(i[n]={zoom:n,type:t.type,property:t.property,default:t.default,stops:[]},r.push(n)),i[n].stops.push([s[0].value,s[1]])}const s=[];for(const t of r)s.push([i[t].zoom,Fi(i[t],e)]);const n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:ei.interpolationFactor.bind(void 0,n),zoomStops:s.map((t=>t[0])),evaluate:({zoom:i},r)=>Ni({stops:s,base:t.base},e,i).evaluate(i,r)}}if(s){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ei.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,o,l)}}return{kind:"source",evaluate(i,r){const s=r&&r.properties?r.properties[t.property]:void 0;return void 0===s?Oi(t.default,e.default):a(t,e,s,o,l)}}}function Oi(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Vi(t,e,i,r,s){return Oi(typeof i===s?r[i]:void 0,t.default,e.default)}function Ui(t,e,i){if("number"!==Li(i))return Oi(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const s=Le(t.stops.map((t=>t[0])),i);return t.stops[s][1]}function Ni(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Li(i))return Oi(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const n=Le(t.stops.map((t=>t[0])),i),a=function(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),o=t.stops[n][1],l=t.stops[n+1][1];let c=Fe[e.type]||Ri;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ti[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),a))}return"function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,a)}}:c(o,l,a)}function $i(t,e,i){switch(e.type){case"color":i=Zt.parse(i);break;case"formatted":i=Wt.fromString(i.toString());break;case"resolvedImage":i=Kt.fromString(i.toString());break;case"padding":i=Ht.parse(i);break;default:Li(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return Oi(i,t.default,e.default)}ce.register(Ii,{error:[{kind:"error"},[It],(t,[e])=>{throw new ie(e.evaluate(t))}],typeof:[It,[Et],(t,[e])=>Lt(Qt(e.evaluate(t)))],"to-rgba":[Dt(Tt,4),[At],(t,[e])=>e.evaluate(t).toArray()],rgb:[At,[Tt,Tt,Tt],Si],rgba:[At,[Tt,Tt,Tt,Tt],Si],has:{type:St,overloads:[[[It],(t,[e])=>Ai(e.evaluate(t),t.properties())],[[It,zt],(t,[e,i])=>Ai(e.evaluate(t),i.evaluate(t))]]},get:{type:Et,overloads:[[[It],(t,[e])=>zi(e.evaluate(t),t.properties())],[[It,zt],(t,[e,i])=>zi(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Et,[It],(t,[e])=>zi(e.evaluate(t),t.featureState||{})],properties:[zt,[],t=>t.properties()],"geometry-type":[It,[],t=>t.geometryType()],id:[Et,[],t=>t.id()],zoom:[Tt,[],t=>t.globals.zoom],"heatmap-density":[Tt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Tt,[],t=>t.globals.lineProgress||0],accumulated:[Et,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Tt,Ei(Tt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Tt,Ei(Tt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Tt,overloads:[[[Tt,Tt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Tt],(t,[e])=>-e.evaluate(t)]]},"/":[Tt,[Tt,Tt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Tt,[Tt,Tt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Tt,[Tt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Tt,[Tt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Tt,[Tt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Tt,[Tt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Tt,[Tt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Tt,[Tt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Tt,[Tt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Tt,Ei(Tt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Tt,Ei(Tt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Tt,[Tt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Tt,[Tt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Tt,[Tt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Tt,[Tt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[St,[It,Et],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[St,[Et],(t,[e])=>t.id()===e.value],"filter-type-==":[St,[It],(t,[e])=>t.geometryType()===e.value],"filter-<":[St,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[St,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[St,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[St,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[St,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[St,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[St,[It,Et],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[St,[Et],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[St,[Et],(t,[e])=>e.value in t.properties()],"filter-has-id":[St,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[St,[Dt(It)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[St,[Dt(Et)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[St,[It,Dt(Et)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[St,[It,Dt(Et)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const s=i+r>>1;if(e[s]===t)return!0;e[s]>t?r=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:St,overloads:[[[St,St],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ei(St),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:St,overloads:[[[St,St],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ei(St),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[St,[St],(t,[e])=>!e.evaluate(t)],"is-supported-script":[St,[It],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[It,[It],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[It,[It],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[It,Ei(Et),(t,e)=>e.map((e=>te(e.evaluate(t)))).join("")],"resolved-locale":[It,[Ct],(t,[e])=>e.evaluate(t).resolvedLocale()]});class qi{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new le,this._defaultValue=e?function(t){return"color"===t.type&&Bi(t.default)?new Zt(0,0,0,0):"color"===t.type?Zt.parse(t.default)||null:"padding"===t.type?Ht.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,s,n){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||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 ie(`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 ji(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Ii}function Zi(t,e){const i=new Me(Ii,[],e?function(t){const e={color:At,string:It,number:Tt,enum:It,boolean:St,formatted:Pt,padding:kt,resolvedImage:Mt};return"array"===t.type?Dt(e[t.value]||Et,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Ci(new qi(r,e)):Pi(i.errors)}class Gi{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ce(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}}class Xi{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ce(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?ei.interpolationFactor(this.interpolationType,t,e,i):0}}function Wi(t,e){const i=Zi(t,e);if("error"===i.result)return i;const r=i.value.expression,s=Ee(r);if(!s&&!ki(e))return Pi([new vt("","data expressions not supported")]);const n=Pe(r,["zoom"]);if(!n&&!Mi(e))return Pi([new vt("","zoom expressions not supported")]);const a=Ki(r);return a||n?a instanceof vt?Pi([a]):a instanceof ei&&!Di(e)?Pi([new vt("",'"interpolate" expressions cannot be used with this property')]):Ci(a?new Xi(s?"camera":"composite",i.value,a.labels,a instanceof ei?a.interpolation:void 0):new Gi(s?"constant":"source",i.value)):Pi([new vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hi{constructor(t,e){this._parameters=t,this._specification=e,gt(this,Fi(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 Ki(t){let e=null;if(t instanceof si)e=Ki(t.result);else if(t instanceof ri){for(const i of t.args)if(e=Ki(i),e)break}else(t instanceof Be||t instanceof ei)&&t.input instanceof ce&&"zoom"===t.input.name&&(e=t);return e instanceof vt||t.eachChild((t=>{const i=Ki(t);i instanceof vt?e=i:!e&&i?e=new vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new vt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Yi(t){const e=t.key,i=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},n=t.style,a=t.styleSpec;let o=[];const l=Li(i);if("object"!==l)return[new ft(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(s[l])h=s[l];else if(r[l])h=Sr;else if(s["*"])h=s["*"];else{if(!r["*"]){o.push(new ft(e,i[t],`unknown property "${t}"`));continue}h=Sr}o=o.concat(h({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:n,styleSpec:a,object:i,objectKey:t},i))}for(const t in r)s[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&o.push(new ft(e,i,`missing required property "${t}"`));return o}function Ji(t){const e=t.value,i=t.valueSpec,r=t.style,s=t.styleSpec,n=t.key,a=t.arrayElementValidator||Sr;if("array"!==Li(e))return[new ft(n,e,`array expected, ${Li(e)} found`)];if(i.length&&e.length!==i.length)return[new ft(n,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new ft(n,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let o={type:i.value,values:i.values};s.$version<7&&(o.function=i.function),"object"===Li(i.value)&&(o=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(a({array:e,arrayIndex:t,value:e[t],valueSpec:o,style:r,styleSpec:s,key:`${n}[${t}]`}));return l}function Qi(t){const e=t.key,i=t.value,r=t.valueSpec;let s=Li(i);return"number"===s&&i!=i&&(s="NaN"),"number"!==s?[new ft(e,i,`number expected, ${s} found`)]:"minimum"in r&&i<r.minimum?[new ft(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new ft(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function tr(t){const e=t.valueSpec,i=yt(t.value.type);let r,s,n,a={};const o="categorical"!==i&&void 0===t.value.property,l=!o,c="array"===Li(t.value.stops)&&"array"===Li(t.value.stops[0])&&"object"===Li(t.value.stops[0][0]),h=Yi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new ft(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ji({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Li(r)&&0===r.length&&e.push(new ft(t.key,r,"array must have at least one stop")),e},default:function(t){return Sr({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&o&&h.push(new ft(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new ft(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Di(t.valueSpec)&&h.push(new ft(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!ki(t.valueSpec)?h.push(new ft(t.key,t.value,"property functions not supported")):o&&!Mi(t.valueSpec)&&h.push(new ft(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new ft(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,o=t.key;if("array"!==Li(r))return[new ft(o,r,`array expected, ${Li(r)} found`)];if(2!==r.length)return[new ft(o,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Li(r[0]))return[new ft(o,r,`object expected, ${Li(r[0])} found`)];if(void 0===r[0].zoom)return[new ft(o,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new ft(o,r,"object stop key must have value")];if(n&&n>yt(r[0].zoom))return[new ft(o,r[0].zoom,"stop zoom values must appear in ascending order")];yt(r[0].zoom)!==n&&(n=yt(r[0].zoom),s=void 0,a={}),i=i.concat(Yi({key:`${o}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Qi,value:p}}))}else i=i.concat(p({key:`${o}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return ji(xt(r[1]))?i.concat([new ft(`${o}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(Sr({key:`${o}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,n){const o=Li(t.value),l=yt(t.value),c=null!==t.value?t.value:n;if(r){if(o!==r)return[new ft(t.key,c,`${o} stop domain type must match previous stop domain type ${r}`)]}else r=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new ft(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==i){let r=`number expected, ${o} found`;return ki(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ft(t.key,c,r)]}return"categorical"!==i||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===o&&void 0!==s&&l<s?[new ft(t.key,c,"stop domain values must appear in ascending order")]:(s=l,"categorical"===i&&l in a?[new ft(t.key,c,"stop domain values must be unique")]:(a[l]=!0,[])):[new ft(t.key,c,`integer expected, found ${l}`)]}}function er(t){const e=("property"===t.expressionContext?Wi:Zi)(xt(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new ft(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.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&&!Ce(i))return[new ft(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ce(i))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(!Pe(i,["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&&!Ee(i))return[new ft(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ir(t){const e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(yt(i))&&s.push(new ft(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(yt(i))&&s.push(new ft(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function rr(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(!rr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const sr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function nr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};rr(t)||(t=lr(t));const e=Zi(t,sr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:or(t)}}function ar(t,e){return t<e?-1:t>e?1:0}function or(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(or(t[e]))return!0;return!1}function lr(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?cr(t[1],t[2],"=="):"!="===e?pr(cr(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?cr(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(lr))):"all"===e?["all"].concat(t.slice(1).map(lr)):"none"===e?["all"].concat(t.slice(1).map(lr).map(pr)):"in"===e?hr(t[1],t.slice(2)):"!in"===e?pr(hr(t[1],t.slice(2))):"has"===e?ur(t[1]):"!has"===e?pr(ur(t[1])):"within"!==e||t;var i}function cr(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function hr(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(ar)]]:["filter-in-small",t,["literal",e]]}}function ur(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function pr(t){return["!",t]}function dr(t){return rr(xt(t.value))?er(gt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):mr(t)}function mr(t){const e=t.value,i=t.key;if("array"!==Li(e))return[new ft(i,e,`array expected, ${Li(e)} found`)];const r=t.styleSpec;let s,n=[];if(e.length<1)return[new ft(i,e,"filter array must have at least 1 element")];switch(n=n.concat(ir({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),yt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===yt(e[1])&&n.push(new ft(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new ft(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=Li(e[1]),"string"!==s&&n.push(new ft(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let a=2;a<e.length;a++)s=Li(e[a]),"$type"===yt(e[1])?n=n.concat(ir({key:`${i}[${a}]`,value:e[a],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==s&&"number"!==s&&"boolean"!==s&&n.push(new ft(`${i}[${a}]`,e[a],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)n=n.concat(mr({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":s=Li(e[1]),2!==e.length?n.push(new ft(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==s&&n.push(new ft(`${i}[1]`,e[1],`string expected, ${s} found`));break;case"within":s=Li(e[1]),2!==e.length?n.push(new ft(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==s&&n.push(new ft(`${i}[1]`,e[1],`object expected, ${s} found`))}return n}function fr(t,e){const i=t.key,r=t.style,s=t.styleSpec,n=t.value,a=t.objectKey,o=s[`${e}_${t.layerType}`];if(!o)return[];const l=a.match(/^(.*)-transition$/);if("paint"===e&&l&&o[l[1]]&&o[l[1]].transition)return Sr({key:i,value:n,valueSpec:s.transition,style:r,styleSpec:s});const c=t.valueSpec||o[a];if(!c)return[new ft(i,n,`unknown property "${a}"`)];let h;if("string"===Li(n)&&ki(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(n)))return[new ft(i,n,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===a&&r&&!r.glyphs&&u.push(new ft(i,n,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&Bi(xt(n))&&"identity"===yt(n.type)&&u.push(new ft(i,n,'"text-font" does not support identity functions'))),u.concat(Sr({key:t.key,value:n,valueSpec:c,style:r,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function _r(t){return fr(t,"paint")}function gr(t){return fr(t,"layout")}function yr(t){let e=[];const i=t.value,r=t.key,s=t.style,n=t.styleSpec;i.type||i.ref||e.push(new ft(r,i,'either "type" or "ref" is required'));let a=yt(i.type);const o=yt(i.ref);if(i.id){const n=yt(i.id);for(let a=0;a<t.arrayIndex;a++){const t=s.layers[a];yt(t.id)===n&&e.push(new ft(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new ft(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{yt(e.id)===o&&(t=e)})),t?t.ref?e.push(new ft(r,i.ref,"ref cannot reference another ref layer")):a=yt(t.type):e.push(new ft(r,i.ref,`ref layer "${o}" not found`))}else if("background"!==a)if(i.source){const t=s.sources&&s.sources[i.source],n=t&&yt(t.type);t?"vector"===n&&"raster"===a?e.push(new ft(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===n&&"raster"!==a?e.push(new ft(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==a?e.push(new ft(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]||"geojson"===n&&t.lineMetrics||e.push(new ft(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ft(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new ft(r,i.source,`source "${i.source}" not found`))}else e.push(new ft(r,i,'missing required property "source"'));return e=e.concat(Yi({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Sr({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:dr,layout:t=>Yi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>gr(gt({layerType:a},t))}}),paint:t=>Yi({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>_r(gt({layerType:a},t))}})}})),e}function xr(t){const e=t.value,i=t.key,r=Li(e);return"string"!==r?[new ft(i,e,`string expected, ${r} found`)]:[]}const vr={promoteId:function({key:t,value:e}){if("string"===Li(e))return xr({key:t,value:e});{const i=[];for(const r in e)i.push(...xr({key:`${t}.${r}`,value:e[r]}));return i}}};function br(t){const e=t.value,i=t.key,r=t.styleSpec,s=t.style;if(!e.type)return[new ft(i,e,'"type" is required')];const n=yt(e.type);let a;switch(n){case"vector":case"raster":case"raster-dem":return a=Yi({key:i,value:e,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:vr}),a;case"geojson":if(a=Yi({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,objectElementValidators:vr}),e.cluster)for(const t in e.clusterProperties){const[r,s]=e.clusterProperties[t],n="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...er({key:`${i}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...er({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return a;case"video":return Yi({key:i,value:e,valueSpec:r.source_video,style:s,styleSpec:r});case"image":return Yi({key:i,value:e,valueSpec:r.source_image,style:s,styleSpec:r});case"canvas":return[new ft(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ir({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,styleSpec:r})}}function wr(t){const e=t.value,i=t.styleSpec,r=i.light,s=t.style;let n=[];const a=Li(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new ft("light",e,`object expected, ${a} found`)]),n;for(const t in e){const a=t.match(/^(.*)-transition$/);n=n.concat(a&&r[a[1]]&&r[a[1]].transition?Sr({key:t,value:e[t],valueSpec:i.transition,style:s,styleSpec:i}):r[t]?Sr({key:t,value:e[t],valueSpec:r[t],style:s,styleSpec:i}):[new ft(t,e[t],`unknown property "${t}"`)])}return n}function Tr(t){const e=t.value,i=t.styleSpec,r=i.terrain,s=t.style;let n=[];const a=Li(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new ft("terrain",e,`object expected, ${a} found`)]),n;for(const t in e)n=n.concat(r[t]?Sr({key:t,value:e[t],valueSpec:r[t],style:s,styleSpec:i}):[new ft(t,e[t],`unknown property "${t}"`)]);return n}const Ir={"*":()=>[],array:Ji,boolean:function(t){const e=t.value,i=t.key,r=Li(e);return"boolean"!==r?[new ft(i,e,`boolean expected, ${r} found`)]:[]},number:Qi,color:function(t){const e=t.key,i=t.value,r=Li(i);return"string"!==r?[new ft(e,i,`color expected, ${r} found`)]:null===Vt(i)?[new ft(e,i,`color expected, "${i}" found`)]:[]},constants:_t,enum:ir,filter:dr,function:tr,layer:yr,object:Yi,source:br,light:wr,terrain:Tr,string:xr,formatted:function(t){return 0===xr(t).length?[]:er(t)},resolvedImage:function(t){return 0===xr(t).length?[]:er(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Li(i)){if(i.length<1||i.length>4)return[new ft(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const t={type:"number"};let r=[];for(let s=0;s<i.length;s++)r=r.concat(Sr({key:`${e}[${s}]`,value:i[s],valueSpec:t}));return r}return Qi({key:e,value:i,valueSpec:{}})}};function Sr(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Bi(yt(e))?tr(t):i.expression&&ji(xt(e))?er(t):i.type&&Ir[i.type]?Ir[i.type](t):Yi(gt({},t,{valueSpec:i.type?r[i.type]:i}))}function Ar(t){const e=t.value,i=t.key,r=xr(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new ft(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new ft(i,e,'"glyphs" url must include a "{range}" token'))),r}function zr(t,e=mt){let i=[];return i=i.concat(Sr({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Ar,"*":()=>[]}})),t.constants&&(i=i.concat(_t({key:"constants",value:t.constants,style:t,styleSpec:e}))),Er(i)}function Er(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Cr(t){return function(...e){return Er(t.apply(this,e))}}zr.source=Cr(br),zr.light=Cr(wr),zr.terrain=Cr(Tr),zr.layer=Cr(yr),zr.filter=Cr(dr),zr.paintProperty=Cr(_r),zr.layoutProperty=Cr(gr);const Pr=zr,kr=Pr.light,Mr=Pr.paintProperty,Dr=Pr.layoutProperty;function Lr(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new pt(new Error(r.message))),i=!0;return i}class Br{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t<this.d*this.d;t++){const e=s[3+t],i=s[3+t+1];r.push(e===i?null:s.subarray(e,i))}const n=s[3+r.length+1];this.keys=s.subarray(s[3+r.length],n),this.bboxes=s.subarray(n),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const s=i/e*t;this.min=-s,this.max=t+s}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,s,n){this.cells[s].push(n)}query(t,e,i,r,s){const n=this.min,a=this.max;if(t<=n&&e<=n&&a<=i&&a<=r&&!s)return Array.prototype.slice.call(this.keys);{const n=[];return this._forEachCell(t,e,i,r,this._queryCell,n,{},s),n}}_queryCell(t,e,i,r,s,n,a,o){const l=this.cells[s];if(null!==l){const s=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===a[u]){const l=4*u;(o?o(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(a[u]=!0,n.push(s[u])):a[u]=!1}}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++){const c=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&s.call(this,t,e,i,r,c,n,a,o))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let s=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=s,r.set(i,s),s+=i.length}return r[3+t.length]=s,r.set(this.keys,s),s+=this.keys.length,r[3+t.length+1]=s,r.set(this.bboxes,s),s+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new Br(t.buffer)}}const Rr={};function Fr(t,e,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Rr[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Fr("Object",Object),Fr("TransferableGridIndex",Br),Fr("Color",Zt),Fr("Error",Error),Fr("AJAXError",K),Fr("ResolvedImage",Kt),Fr("StylePropertyFunction",Hi),Fr("StyleExpression",qi,{omit:["_evaluator"]}),Fr("ZoomDependentExpression",Xi),Fr("ZoomConstantExpression",Gi),Fr("CompoundExpression",ce,{omit:["_evaluate"]});for(const t in Ii)Ii[t]._classRegistryKey||Fr(`Expression_${t}`,Ii[t]);function Or(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Vr(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob)return t;if(Or(t))return e&&e.push(t),t;if(C(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(Vr(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class");const s=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const i in t){if(!t.hasOwnProperty(i))continue;if(Rr[r].omit.indexOf(i)>=0)continue;const n=t[i];s[i]=Rr[r].shallow.indexOf(i)>=0?n:Vr(n,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(s.$name=r),s}throw new Error("can't serialize object of type "+typeof t)}function Ur(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||Or(t)||C(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Ur);if("object"==typeof t){const e=t.$name||"Object";if(!Rr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Rr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const s=t[i];r[i]=Rr[e].shallow.indexOf(i)>=0?s:Ur(s)}return r}throw new Error("can't deserialize object of type "+typeof t)}class Nr{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const $r=t=>t>=12352&&t<=12447,qr=t=>t>=12448&&t<=12543,jr=t=>t>=19968&&t<=40959,Zr=t=>t>=44032&&t<=55215;function Gr(t){for(const e of t)if(Xr(e.charCodeAt(0)))return!0;return!1}function Xr(t){return!(746!==t&&747!==t&&(t<4352||!((t=>t>=12704&&t<=12735)(t)||(t=>t>=12544&&t<=12591)(t)||(t=>t>=65072&&t<=65103)(t)&&!(t>=65097&&t<=65103)||(t=>t>=63744&&t<=64255)(t)||(t=>t>=13056&&t<=13311)(t)||(t=>t>=11904&&t<=12031)(t)||(t=>t>=12736&&t<=12783)(t)||!(!(t=>t>=12288&&t<=12351)(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||(t=>t>=13312&&t<=19903)(t)||jr(t)||(t=>t>=12800&&t<=13055)(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||Zr(t)||$r(t)||(t=>t>=12272&&t<=12287)(t)||(t=>t>=12688&&t<=12703)(t)||(t=>t>=12032&&t<=12255)(t)||(t=>t>=12784&&t<=12799)(t)||qr(t)&&12540!==t||!(!(t=>t>=65280&&t<=65519)(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)||!(!(t=>t>=65104&&t<=65135)(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||(t=>t>=65040&&t<=65055)(t)||(t=>t>=19904&&t<=19967)(t)||(t=>t>=40960&&t<=42127)(t)||(t=>t>=42128&&t<=42191)(t))))}function Wr(t){return t>=1424&&t<=2303||(t=>t>=64336&&t<=65023)(t)||(t=>t>=65136&&t<=65279)(t)}function Hr(t,e){return!(!e&&Wr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function Kr(t){for(const e of t)if(Wr(e.charCodeAt(0)))return!0;return!1}const Yr="deferred",Jr="loading",Qr="loaded";let ts=null,es="unavailable",is=null;const rs=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(es="error"),ts&&ts(t)};function ss(){ns.fire(new ut("pluginStateChange",{pluginStatus:es,pluginURL:is}))}const ns=new dt,as=function(){return es},os=function(){if(es!==Yr||!is)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");es=Jr,ss(),is&&et({url:is},(t=>{t?rs(t):(es=Qr,ss())}))},ls={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>es===Qr||null!=ls.applyArabicShaping,isLoading:()=>es===Jr,setState(t){es=t.pluginStatus,is=t.pluginURL},isParsed:()=>null!=ls.applyArabicShaping,getPluginURL:()=>is};class cs{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 Nr,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!Hr(i.charCodeAt(0),e))return!1;return!0}(t,ls.isLoaded())}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),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class hs{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Bi(t))return new Hi(t,e);if(ji(t)){const i=Wi(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=Zt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)||(i=Ht.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class us{constructor(t){this.property=t,this.value=new hs(t,void 0)}transitioned(t,e){return new ds(this.property,this.value,e,u({},t.transition,this.transition),t.now)}untransitioned(){return new ds(this.property,this.value,null,{},0)}}class ps{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return y(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new us(this._values[t].property)),this._values[t].value=new hs(this._values[t].property,null===e?void 0:y(e))}getTransition(t){return y(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new us(this._values[t].property)),this._values[t].transition=y(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new ms(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new ms(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ds{constructor(t,e,i,r,s){this.property=t,this.value=e,this.begin=s+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,s=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(r<this.begin)return n.possiblyEvaluate(t,e,i);{const a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(t,e,i),s,function(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(a))}}return s}}class ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new gs(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return y(this._values[t].value)}setValue(t,e){this._values[t]=new hs(this._values[t].property,null===e?void 0:y(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new gs(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}}class _s{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class gs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class ys{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=Fe[this.specification.type];return r?r(t,e,i):t}}class xs{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new _s(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new _s(this,{kind:"constant",value:void 0},t.parameters);const r=Fe[this.specification.type];return r?new _s(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,s,n){return"constant"===t.kind?t.value:t.evaluate(e,i,r,s,n)}}class vs extends xs{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new _s(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r),n="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,a=this._calculate(n,n,n,e);return new _s(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new _s(this,{kind:"constant",value:i},e)}return new _s(this,t.expression,e)}evaluate(t,e,i,r,s,n){if("source"===t.kind){const a=t.evaluate(e,i,r,s,n);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class bs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new cs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new cs(Math.floor(e.zoom),e)),t.expression.evaluate(new cs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class ws{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Ts{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new hs(i,void 0),s=this.defaultTransitionablePropertyValues[e]=new us(i);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}Fr("DataDrivenProperty",xs),Fr("DataConstantProperty",ys),Fr("CrossFadedDataDrivenProperty",vs),Fr("CrossFadedProperty",bs),Fr("ColorRampProperty",ws);const Is="-transition";class Ss extends dt{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 fs(e.layout)),e.paint)){this._transitionablePaint=new ps(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 gs(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(Dr,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(Is)?this._transitionablePaint.getTransition(t.slice(0,-Is.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Mr,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(Is))return this._transitionablePaint.setTransition(t.slice(0,-Is.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||s||r||this._handleOverridablePaintPropertyUpdate(t,n,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&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),g(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&Lr(this,t.call(Pr,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:mt,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 _s&&ki(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const As={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Es{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Cs(t,e=1){let i=0,r=0;return{members:t.map((t=>{const s=As[t.type].BYTES_PER_ELEMENT,n=i=Ps(i,Math.max(e,s)),a=t.components||1;return r=Math.max(r,s),i+=s*a,{name:t.name,type:t.type,components:a,offset:n}})),size:Ps(i,Math.max(r,e)),alignment:e}}function Ps(t,e){return Math.ceil(t/e)*e}class ks extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}ks.prototype.bytesPerElement=4,Fr("StructArrayLayout2i4",ks);class Ms extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=s,t}}Ms.prototype.bytesPerElement=8,Fr("StructArrayLayout4i8",Ms);class Ds extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}Ds.prototype.bytesPerElement=12,Fr("StructArrayLayout2i4i12",Ds);class Ls extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=s,this.uint8[l+6]=n,this.uint8[l+7]=a,t}}Ls.prototype.bytesPerElement=8,Fr("StructArrayLayout2i4ub8",Ls);class Bs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Bs.prototype.bytesPerElement=8,Fr("StructArrayLayout2f8",Bs);class Rs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,s,n,a,o,l,c)}emplace(t,e,i,r,s,n,a,o,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=n,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Rs.prototype.bytesPerElement=20,Fr("StructArrayLayout10ui20",Rs);class Fs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,s,n,a,o,l,c,h,u)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=s,this.uint16[d+4]=n,this.uint16[d+5]=a,this.uint16[d+6]=o,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,t}}Fs.prototype.bytesPerElement=24,Fr("StructArrayLayout4i4ui4i24",Fs);class Os extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}Os.prototype.bytesPerElement=12,Fr("StructArrayLayout3f12",Os);class Vs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Vs.prototype.bytesPerElement=4,Fr("StructArrayLayout1ul4",Vs);class Us extends Es{_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,i,r,s,n,a,o,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,s,n,a,o,l)}emplace(t,e,i,r,s,n,a,o,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=s,this.int16[h+4]=n,this.int16[h+5]=a,this.uint32[u+3]=o,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}Us.prototype.bytesPerElement=20,Fr("StructArrayLayout6i1ul2ui20",Us);class Ns extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}Ns.prototype.bytesPerElement=12,Fr("StructArrayLayout2i2i2i12",Ns);class $s extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,s)}emplace(t,e,i,r,s,n){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[o+6]=s,this.int16[o+7]=n,t}}$s.prototype.bytesPerElement=16,Fr("StructArrayLayout2f1f2i16",$s);class qs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=12*t,a=3*t;return this.uint8[n+0]=e,this.uint8[n+1]=i,this.float32[a+1]=r,this.float32[a+2]=s,t}}qs.prototype.bytesPerElement=12,Fr("StructArrayLayout2ub2f12",qs);class js extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=r,t}}js.prototype.bytesPerElement=6,Fr("StructArrayLayout3ui6",js);class Zs extends Es{_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,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=s,this.uint32[x+2]=n,this.uint32[x+3]=a,this.uint32[x+4]=o,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=p,this.uint8[v+36]=d,this.uint8[v+37]=m,this.uint8[v+38]=f,this.uint32[x+10]=_,this.int16[y+22]=g,t}}Zs.prototype.bytesPerElement=48,Fr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Zs);class Gs extends Es{_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,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,S,A,z){const E=this.length;return this.resize(E+1),this.emplace(E,t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,S,A,z)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,S,A,z,E){const C=34*t,P=17*t;return this.int16[C+0]=e,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=s,this.int16[C+4]=n,this.int16[C+5]=a,this.int16[C+6]=o,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=p,this.uint16[C+12]=d,this.uint16[C+13]=m,this.uint16[C+14]=f,this.uint16[C+15]=_,this.uint16[C+16]=g,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[P+12]=I,this.float32[P+13]=S,this.float32[P+14]=A,this.float32[P+15]=z,this.float32[P+16]=E,t}}Gs.prototype.bytesPerElement=68,Fr("StructArrayLayout8i15ui1ul4f68",Gs);class Xs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Xs.prototype.bytesPerElement=4,Fr("StructArrayLayout1f4",Xs);class Ws extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,t}}Ws.prototype.bytesPerElement=6,Fr("StructArrayLayout3i6",Ws);class Hs extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,t}}Hs.prototype.bytesPerElement=8,Fr("StructArrayLayout1ul2ui8",Hs);class Ks extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Ks.prototype.bytesPerElement=4,Fr("StructArrayLayout2ui4",Ks);class Ys extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Ys.prototype.bytesPerElement=2,Fr("StructArrayLayout1ui2",Ys);class Js extends Es{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=s,t}}Js.prototype.bytesPerElement=16,Fr("StructArrayLayout4f16",Js);class Qs extends zs{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 k(this.anchorPointX,this.anchorPointY)}}Qs.prototype.size=20;class tn extends Us{get(t){return new Qs(this,t)}}Fr("CollisionBoxArray",tn);class en extends zs{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]}}en.prototype.size=48;class rn extends Zs{get(t){return new en(this,t)}}Fr("PlacedSymbolArray",rn);class sn extends zs{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 textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}sn.prototype.size=68;class nn extends Gs{get(t){return new sn(this,t)}}Fr("SymbolInstanceArray",nn);class an extends Xs{getoffsetX(t){return this.float32[1*t+0]}}Fr("GlyphOffsetArray",an);class on extends Ws{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Fr("SymbolLineVertexArray",on);class ln extends zs{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]}}ln.prototype.size=8;class cn extends Hs{get(t){return new ln(this,t)}}Fr("FeatureIndexArray",cn);class hn extends ks{}class un extends Ms{}class pn extends ks{}class dn extends ks{}class mn extends Ds{}class fn extends Ls{}class _n extends Bs{}class gn extends Rs{}class yn extends Fs{}class xn extends Os{}class vn extends Vs{}class bn extends Ns{}class wn extends $s{}class Tn extends qs{}class In extends js{}class Sn extends js{}class An extends Ks{}class zn extends Ys{}const En=Cs([{name:"a_pos",components:2,type:"Int16"}],4),{members:Cn}=En;class Pn{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let s=this.segments[this.segments.length-1];return t>Pn.MAX_VERTEX_ARRAY_LENGTH&&v(`Max vertices per segment is ${Pn.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!s||s.vertexLength+t>Pn.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==r)&&(s={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(s.sortKey=r),this.segments.push(s)),s}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,i,r){return new Pn([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function kn(t,e){return 256*(t=l(Math.floor(t),0,255))+l(Math.floor(e),0,255)}Pn.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Fr("SegmentVector",Pn);const Mn=Cs([{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 Dn={exports:{}},Ln={exports:{}};!function(t){t.exports=function(t,e){var i,r,s,n,a,o,l,c;for(r=t.length-(i=3&t.length),s=e,a=3432918353,o=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,s=27492+(65535&(n=5*(65535&(s=(s^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}(Ln);var Bn={exports:{}};!function(t){t.exports=function(t,e){for(var i,r=t.length,s=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:s^=(255&t.charCodeAt(n+2))<<16;case 2:s^=(255&t.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}(Bn);var Rn=Ln.exports,Fn=Bn.exports;Dn.exports=Rn,Dn.exports.murmur3=Rn,Dn.exports.murmur2=Fn;class On{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Vn(t)),this.positions.push(e,i,r)}getPositions(t){const e=Vn(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Un(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new On;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Vn(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Dn.exports(String(t))}function Un(t,e,i,r){for(;i<r;){const s=t[i+r>>1];let n=i-1,a=r+1;for(;;){do{n++}while(t[n]<s);do{a--}while(t[a]>s);if(n>=a)break;Nn(t,n,a),Nn(e,3*n,3*a),Nn(e,3*n+1,3*a+1),Nn(e,3*n+2,3*a+2)}a-i<r-a?(Un(t,e,i,a),i=a+1):(Un(t,e,a+1,r),r=a)}}function Nn(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Fr("FeaturePositionMap",On);class $n{constructor(t,e){this.gl=t.gl,this.location=e}}class qn extends $n{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}}class jn extends $n{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Zn extends $n{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}}class Gn extends $n{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}}class Xn extends $n{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Wn extends $n{constructor(t,e){super(t,e),this.current=Zt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Hn=new Float32Array(16);class Kn extends $n{constructor(t,e){super(t,e),this.current=Hn}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}}function Yn(t){return[kn(255*t.r,255*t.g),kn(255*t.b,255*t.a)]}class Jn{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Wn(t,e):new jn(t,e)}}class Qn{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,i,r){const s="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;s&&t.set(s)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new Xn(t,e):new jn(t,e)}}class ta{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,s){const n=this.paintVertexArray.length,a=this.expression.evaluate(new cs(0),e,{},r,[],s);this.paintVertexArray.resize(t),this._setPaintValue(n,t,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=Yn(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class ea{constructor(t,e,i,r,s,n){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,s){const n=this.expression.evaluate(new cs(this.zoom),e,{},r,[],s),a=this.expression.evaluate(new cs(this.zoom+1),e,{},r,[],s),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,n,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:this.zoom},i,r),n=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,s,n)}_setPaintValue(t,e,i,r){if("color"===this.type){const s=Yn(i),n=Yn(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,s[0],s[1],n[0],n[1])}else{for(let s=t;s<e;s++)this.paintVertexArray.emplace(s,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=l(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new jn(t,e)}}class ia{constructor(t,e,i,r,s,n){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,s){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],s)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:s,mid:n,max:a}=i,o=r[s],l=r[n],c=r[a];if(o&&l&&c)for(let i=t;i<e;i++)this.zoomInPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],o.tl[0],o.tl[1],o.br[0],o.br[1],l.pixelRatio,o.pixelRatio),this.zoomOutPaintVertexArray.emplace(i,l.tl[0],l.tl[1],l.br[0],l.br[1],c.tl[0],c.tl[1],c.br[0],c.br[1],l.pixelRatio,c.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Mn.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Mn.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ra{constructor(t,e,i){this.binders={},this._buffers=[];const r=[];for(const s in t.paint._values){if(!i(s))continue;const n=t.paint.get(s);if(!(n instanceof _s&&ki(n.property.specification)))continue;const a=na(s,t.type),o=n.value,l=n.property.specification.type,c=n.property.useIntegerZoom,h=n.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===o.kind)this.binders[s]=u?new Qn(o.value,a):new Jn(o.value,a,l),r.push(`/u_${s}`);else if("source"===o.kind||u){const i=aa(s,l,"source");this.binders[s]=u?new ia(o,l,c,e,i,t.id):new ta(o,a,l,i),r.push(`/a_${s}`)}else{const t=aa(s,l,"composite");this.binders[s]=new ea(o,a,l,c,e,t),r.push(`/z_${s}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof ta||e instanceof ea?e.maxValue:0}populatePaintArrays(t,e,i,r,s){for(const n in this.binders){const a=this.binders[n];(a instanceof ta||a instanceof ea||a instanceof ia)&&a.populatePaintArray(t,e,i,r,s)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Qn&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,s){let n=!1;for(const a in t){const o=e.getPositions(a);for(const e of o){const o=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof ta||l instanceof ea||l instanceof ia)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,o,t[a],s),n=!0}}}}return n}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Jn||i instanceof Qn)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof ta||i instanceof ea)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof ia)for(let e=0;e<Mn.members.length;e++)t.push(Mn.members[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Jn||i instanceof Qn||i instanceof ea)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const s=this.binders[r];if(s instanceof Jn||s instanceof Qn||s instanceof ea)for(const n of s.uniformNames)if(e[n]){const a=s.getBinding(t,e[n],n);i.push({name:n,property:r,binding:a})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:s,binding:n}of e)this.binders[s].setUniform(n,r,i.get(s),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof ia){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof ta||i instanceof ea)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof ta||i instanceof ea||i instanceof ia)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof ta||e instanceof ea||e instanceof ia)&&e.destroy()}}}class sa{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new ra(r,e,i);this.needsUpload=!1,this._featureMap=new On,this._bufferOffset=0}populatePaintArrays(t,e,i,r,s,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,s,n);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r)||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 na(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 aa(t,e,i){const r={color:{source:Bs,composite:Js},number:{source:Xs,composite:Bs}},s=function(t){return{"line-pattern":{source:gn,composite:gn},"fill-pattern":{source:gn,composite:gn},"fill-extrusion-pattern":{source:gn,composite:gn}}[t]}(t);return s&&s[i]||r[e][i]}Fr("ConstantBinder",Jn),Fr("CrossFadedConstantBinder",Qn),Fr("SourceExpressionBinder",ta),Fr("CrossFadedCompositeBinder",ia),Fr("CompositeExpressionBinder",ea),Fr("ProgramConfiguration",ra,{omit:["_buffers"]}),Fr("ProgramConfigurationSet",sa);var oa=8192;const la=Math.pow(2,14)-1,ca=-la-1;function ha(t){const e=oa/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],s=Math.round(i.x*e),n=Math.round(i.y*e);i.x=l(s,ca,la),i.y=l(n,ca,la),(s<i.x||s>i.x+1||n<i.y||n>i.y+1)&&v("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function ua(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?ha(t):[]}}function pa(t,e,i,r,s){t.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}class da{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 pn,this.indexArray=new Sn,this.segments=new Pn,this.programConfigurations=new sa(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],s=[];let n=null,a=!1;"circle"===r.type&&(n=r.layout.get("circle-sort-key"),a=!n.isConstant());for(const{feature:e,id:r,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ua(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),c,i))continue;const h=a?n.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:ha(e),patterns:{},sortKey:h};s.push(u)}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:s,index:n,sourceLayerIndex:a}=r,o=t[n].feature;this.addFeature(r,s,n,i),e.featureIndex.insert(o,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Cn),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,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=oa||r<0||r>=oa)continue;const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),n=s.vertexLength;pa(this.layoutVertexArray,i,r,-1,-1),pa(this.layoutVertexArray,i,r,1,-1),pa(this.layoutVertexArray,i,r,1,1),pa(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(n,n+1,n+2),this.indexArray.emplaceBack(n,n+3,n+2),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function ma(t,e){for(let i=0;i<t.length;i++)if(Ta(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ta(t,e[i]))return!0;return!!ya(t,e)}function fa(t,e,i){return!!Ta(t,e)||!!va(e,t,i)}function _a(t,e){if(1===t.length)return wa(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(Ta(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(wa(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(ya(t,e[i]))return!0;return!1}function ga(t,e,i){if(t.length>1){if(ya(t,e))return!0;for(let r=0;r<e.length;r++)if(va(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(va(t[r],e,i))return!0;return!1}function ya(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)if(xa(r,s,e[t],e[t+1]))return!0}return!1}function xa(t,e,i,r){return b(t,i,r)!==b(e,i,r)&&b(t,e,i)!==b(t,e,r)}function va(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(ba(t,e[i-1],e[i])<r)return!0;return!1}function ba(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function wa(t,e){let i,r,s,n=!1;for(let a=0;a<t.length;a++){i=t[a];for(let t=0,a=i.length-1;t<i.length;a=t++)r=i[t],s=i[a],r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function Ta(t,e){let i=!1;for(let r=0,s=t.length-1;r<t.length;s=r++){const n=t[r],a=t[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i)}return i}function Ia(t,e,i){const r=i[0],s=i[2];if(t.x<r.x&&e.x<r.x||t.x>s.x&&e.x>s.x||t.y<r.y&&e.y<r.y||t.y>s.y&&e.y>s.y)return!1;const n=b(t,e,i[0]);return n!==b(t,e,i[1])||n!==b(t,e,i[2])||n!==b(t,e,i[3])}function Sa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Aa(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function za(t,e,i,r,s){if(!e[0]&&!e[1])return t;const n=k.convert(e)._mult(s);"viewport"===i&&n._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(n));return a}Fr("CircleBucket",da,{omit:["layers"]});const Ea=new Ts({"circle-sort-key":new xs(mt.layout_circle["circle-sort-key"])});var Ca={paint:new Ts({"circle-radius":new xs(mt.paint_circle["circle-radius"]),"circle-color":new xs(mt.paint_circle["circle-color"]),"circle-blur":new xs(mt.paint_circle["circle-blur"]),"circle-opacity":new xs(mt.paint_circle["circle-opacity"]),"circle-translate":new ys(mt.paint_circle["circle-translate"]),"circle-translate-anchor":new ys(mt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ys(mt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ys(mt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new xs(mt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new xs(mt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new xs(mt.paint_circle["circle-stroke-opacity"])}),layout:Ea},Pa=1e-6,ka="undefined"!=typeof Float32Array?Float32Array:Array;function Ma(){var t=new ka(9);return ka!=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 Da(){var t=new ka(16);return ka!=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 La(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 Ba(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],m=e[12],f=e[13],_=e[14],g=e[15],y=i*o-r*a,x=i*l-s*a,v=i*c-n*a,b=r*l-s*o,w=r*c-n*o,T=s*c-n*l,I=h*f-u*m,S=h*_-p*m,A=h*g-d*m,z=u*_-p*f,E=u*g-d*f,C=p*g-d*_,P=y*C-x*E+v*z+b*A-w*S+T*I;return P?(t[0]=(o*C-l*E+c*z)*(P=1/P),t[1]=(s*E-r*C-n*z)*P,t[2]=(f*T-_*w+g*b)*P,t[3]=(p*w-u*T-d*b)*P,t[4]=(l*A-a*C-c*S)*P,t[5]=(i*C-s*A+n*S)*P,t[6]=(_*v-m*T-g*x)*P,t[7]=(h*T-p*v+d*x)*P,t[8]=(a*E-o*A+c*I)*P,t[9]=(r*A-i*E-n*I)*P,t[10]=(m*w-f*v+g*y)*P,t[11]=(u*v-h*w-d*y)*P,t[12]=(o*S-a*z-l*I)*P,t[13]=(i*z-r*S+s*I)*P,t[14]=(f*x-m*b-_*y)*P,t[15]=(h*b-u*x+p*y)*P,t):null}function Ra(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],f=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*o+b*u+w*f,t[1]=x*s+v*l+b*p+w*_,t[2]=x*n+v*c+b*d+w*g,t[3]=x*a+v*h+b*m+w*y,t[4]=(x=i[4])*r+(v=i[5])*o+(b=i[6])*u+(w=i[7])*f,t[5]=x*s+v*l+b*p+w*_,t[6]=x*n+v*c+b*d+w*g,t[7]=x*a+v*h+b*m+w*y,t[8]=(x=i[8])*r+(v=i[9])*o+(b=i[10])*u+(w=i[11])*f,t[9]=x*s+v*l+b*p+w*_,t[10]=x*n+v*c+b*d+w*g,t[11]=x*a+v*h+b*m+w*y,t[12]=(x=i[12])*r+(v=i[13])*o+(b=i[14])*u+(w=i[15])*f,t[13]=x*s+v*l+b*p+w*_,t[14]=x*n+v*c+b*d+w*g,t[15]=x*a+v*h+b*m+w*y,t}function Fa(t,e,i){var r,s,n,a,o,l,c,h,u,p,d,m,f=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*f+e[4]*_+e[8]*g+e[12],t[13]=e[1]*f+e[5]*_+e[9]*g+e[13],t[14]=e[2]*f+e[6]*_+e[10]*g+e[14],t[15]=e[3]*f+e[7]*_+e[11]*g+e[15]):(s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],m=e[11],t[0]=r=e[0],t[1]=s,t[2]=n,t[3]=a,t[4]=o,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=m,t[12]=r*f+o*_+u*g+e[12],t[13]=s*f+l*_+p*g+e[13],t[14]=n*f+c*_+d*g+e[14],t[15]=a*f+h*_+m*g+e[15]),t}function Oa(t,e,i){var r=i[0],s=i[1],n=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Va(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=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]=n*s+c*r,t[1]=a*s+h*r,t[2]=o*s+u*r,t[3]=l*s+p*r,t[4]=c*s-n*r,t[5]=h*s-a*r,t[6]=u*s-o*r,t[7]=p*s-l*r,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Ua=function(t,e,i,r,s,n,a){var o=1/(e-i),l=1/(r-s),c=1/(n-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*o,t[13]=(s+r)*l,t[14]=(a+n)*c,t[15]=1,t},Na=Ra;function $a(){var t=new ka(3);return ka!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function qa(t){var e=new ka(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ja(t,e,i){var r=new ka(3);return r[0]=t,r[1]=e,r[2]=i,r}var Za,Ga=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t};function Xa(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3];return t[0]=i[0]*r+i[4]*s+i[8]*n+i[12]*a,t[1]=i[1]*r+i[5]*s+i[9]*n+i[13]*a,t[2]=i[2]*r+i[6]*s+i[10]*n+i[14]*a,t[3]=i[3]*r+i[7]*s+i[11]*n+i[15]*a,t}function Wa(){var t=new ka(4);return ka!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}$a(),Za=new ka(4),ka!=Float32Array&&(Za[0]=0,Za[1]=0,Za[2]=0,Za[3]=0),$a(),ja(1,0,0),ja(0,1,0),Wa(),Wa(),Ma();var Ha=function(t){var e=t[0],i=t[1];return e*e+i*i};function Ka(t,e){const i=Xa([],[t.x,t.y,0,1],e);return new k(i[0]/i[3],i[1]/i[3])}!function(){var t;t=new ka(2),ka!=Float32Array&&(t[0]=0,t[1]=0)}();class Ya extends da{}Fr("HeatmapBucket",Ya,{omit:["layers"]});var Ja={paint:new Ts({"heatmap-radius":new xs(mt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new xs(mt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ys(mt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ws(mt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ys(mt.paint_heatmap["heatmap-opacity"])})};function Qa(t,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*r}`)}else s=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=s,t}function to(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const s=Qa({},{width:e,height:i},r);eo(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=s.data}function eo(t,e,i,r,s,n){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;for(let l=0;l<s.height;l++){const c=((i.y+l)*t.width+i.x)*n,h=((r.y+l)*e.width+r.x)*n;for(let t=0;t<s.width*n;t++)o[h+t]=a[c+t]}return e}class io{constructor(t,e){Qa(this,t,1,e)}resize(t){to(this,t,1)}clone(){return new io({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){eo(t,e,i,r,s,1)}}class ro{constructor(t,e){Qa(this,t,4,e)}resize(t){to(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new ro({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){eo(t,e,i,r,s,4)}}function so(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,s=t.image||new ro({width:i,height:r}),n=(i,r,n)=>{e[t.evaluationKey]=n;const a=t.expression.evaluate(e);s.data[i+r+0]=Math.floor(255*a.r/a.a),s.data[i+r+1]=Math.floor(255*a.g/a.a),s.data[i+r+2]=Math.floor(255*a.b/a.a),s.data[i+r+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,s=0;e<r;++e,s+=4*i)for(let r=0,a=0;r<i;r++,a+=4){const o=r/(i-1),{start:l,end:c}=t.clips[e];n(s,a,l*(1-o)+c*o)}else for(let t=0,e=0;t<i;t++,e+=4)n(0,e,t/(i-1));return s}Fr("AlphaImage",io),Fr("RGBAImage",ro);var no={paint:new Ts({"hillshade-illumination-direction":new ys(mt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ys(mt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ys(mt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ys(mt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ys(mt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ys(mt.paint_hillshade["hillshade-accent-color"])})};const ao=Cs([{name:"a_pos",components:2,type:"Int16"}],4),{members:oo}=ao;var lo={exports:{}};function co(t,e,i){i=i||2;var r,s,n,a,o,l,c,h=e&&e.length,u=h?e[0]*i:t.length,p=ho(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,i,r){var s,n,a,o=[];for(s=0,n=e.length;s<n;s++)(a=ho(t,e[s]*r,s<n-1?e[s+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),o.push(wo(a));for(o.sort(yo),s=0;s<o.length;s++)i=xo(o[s],i);return i}(t,e,p,i)),t.length>80*i){r=n=t[0],s=a=t[1];for(var m=i;m<u;m+=i)(o=t[m])<r&&(r=o),(l=t[m+1])<s&&(s=l),o>n&&(n=o),l>a&&(a=l);c=0!==(c=Math.max(n-r,a-s))?32767/c:0}return po(p,d,i,r,s,c,0),d}function ho(t,e,i,r,s){var n,a;if(s===Bo(t,e,i,r)>0)for(n=e;n<i;n+=r)a=Mo(n,t[n],t[n+1],a);else for(n=i-r;n>=e;n-=r)a=Mo(n,t[n],t[n+1],a);return a&&Ao(a,a.next)&&(Do(a),a=a.next),a}function uo(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Ao(r,r.next)&&0!==So(r.prev,r,r.next))r=r.next;else{if(Do(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function po(t,e,i,r,s,n,a){if(t){!a&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=bo(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,a,o,l,c=1;do{for(i=t,t=null,n=null,a=0;i;){for(a++,r=i,o=0,e=0;e<c&&(o++,r=r.nextZ);e++);for(l=c;o>0||l>0&&r;)0!==o&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,c*=2}while(a>1)}(s)}(t,r,s,n);for(var o,l,c=t;t.prev!==t.next;)if(o=t.prev,l=t.next,n?fo(t,r,s,n):mo(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Do(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?po(t=_o(uo(t),e,i),e,i,r,s,n,2):2===a&&go(t,e,i,r,s,n):po(uo(t),e,i,r,s,n,1);break}}}function mo(t){var e=t.prev,i=t,r=t.next;if(So(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,a=r.x,o=e.y,l=i.y,c=r.y,h=s<n?s<a?s:a:n<a?n:a,u=o<l?o<c?o:c:l<c?l:c,p=s>n?s>a?s:a:n>a?n:a,d=o>l?o>c?o:c:l>c?l:c,m=r.next;m!==e;){if(m.x>=h&&m.x<=p&&m.y>=u&&m.y<=d&&To(s,o,n,l,a,c,m.x,m.y)&&So(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function fo(t,e,i,r){var s=t.prev,n=t,a=t.next;if(So(s,n,a)>=0)return!1;for(var o=s.x,l=n.x,c=a.x,h=s.y,u=n.y,p=a.y,d=o<l?o<c?o:c:l<c?l:c,m=h<u?h<p?h:p:u<p?u:p,f=o>l?o>c?o:c:l>c?l:c,_=h>u?h>p?h:p:u>p?u:p,g=bo(d,m,e,i,r),y=bo(f,_,e,i,r),x=t.prevZ,v=t.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=_&&x!==s&&x!==a&&To(o,h,l,u,c,p,x.x,x.y)&&So(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=d&&v.x<=f&&v.y>=m&&v.y<=_&&v!==s&&v!==a&&To(o,h,l,u,c,p,v.x,v.y)&&So(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=f&&x.y>=m&&x.y<=_&&x!==s&&x!==a&&To(o,h,l,u,c,p,x.x,x.y)&&So(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=f&&v.y>=m&&v.y<=_&&v!==s&&v!==a&&To(o,h,l,u,c,p,v.x,v.y)&&So(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function _o(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!Ao(s,n)&&zo(s,r,r.next,n)&&Po(s,n)&&Po(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),Do(r),Do(r.next),r=t=n),r=r.next}while(r!==t);return uo(r)}function go(t,e,i,r,s,n){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Io(a,o)){var l=ko(a,o);return a=uo(a,a.next),l=uo(l,l.next),po(a,e,i,r,s,n,0),void po(l,e,i,r,s,n,0)}o=o.next}a=a.next}while(a!==t)}function yo(t,e){return t.x-e.x}function xo(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,a=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var o=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=s&&o>a&&(a=o,i=r.x<r.next.x?r:r.next,o===s))return i}r=r.next}while(r!==e);if(!i)return null;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{s>=r.x&&r.x>=h&&s!==r.x&&To(n<u?s:a,n,h,u,n<u?a:s,n,r.x,r.y)&&(l=Math.abs(n-r.y)/(s-r.x),Po(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&vo(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=ko(i,t);return uo(r,r.next),uo(i,i.next)}function vo(t,e){return So(t.prev,t,e.prev)<0&&So(e.next,t,t.next)<0}function bo(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wo(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function To(t,e,i,r,s,n,a,o){return(s-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(r-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function Io(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&zo(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Po(t,e)&&Po(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(So(t.prev,t,e.prev)||So(t,e.prev,e))||Ao(t,e)&&So(t.prev,t,t.next)>0&&So(e.prev,e,e.next)>0)}function So(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ao(t,e){return t.x===e.x&&t.y===e.y}function zo(t,e,i,r){var s=Co(So(t,e,i)),n=Co(So(t,e,r)),a=Co(So(i,r,t)),o=Co(So(i,r,e));return s!==n&&a!==o||!(0!==s||!Eo(t,i,e))||!(0!==n||!Eo(t,r,e))||!(0!==a||!Eo(i,t,r))||!(0!==o||!Eo(i,e,r))}function Eo(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Co(t){return t>0?1:t<0?-1:0}function Po(t,e){return So(t.prev,t,t.next)<0?So(t,e,t.next)>=0&&So(t,t.prev,e)>=0:So(t,e,t.prev)<0||So(t,t.next,e)<0}function ko(t,e){var i=new Lo(t.i,t.x,t.y),r=new Lo(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Mo(t,e,i,r){var s=new Lo(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Do(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 Lo(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Bo(t,e,i,r){for(var s=0,n=e,a=i-r;n<i;n+=r)s+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return s}function Ro(t,e,i,r,s){Fo(t,e,i||0,r||t.length-1,s||Vo)}function Fo(t,e,i,r,s){for(;r>i;){if(r-i>600){var n=r-i+1,a=e-i+1,o=Math.log(n),l=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*l*(n-l)/n)*(a-n/2<0?-1:1);Fo(t,e,Math.max(i,Math.floor(e-a*l/n+c)),Math.min(r,Math.floor(e+(n-a)*l/n+c)),s)}var h=t[e],u=i,p=r;for(Oo(t,i,e),s(t[r],h)>0&&Oo(t,i,r);u<p;){for(Oo(t,u,p),u++,p--;s(t[u],h)<0;)u++;for(;s(t[p],h)>0;)p--}0===s(t[i],h)?Oo(t,i,p):Oo(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function Oo(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Vo(t,e){return t<e?-1:t>e?1:0}function Uo(t,e){const i=t.length;if(i<=1)return[t];const r=[];let s,n;for(let e=0;e<i;e++){const i=w(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===n&&(n=i<0),n===i<0?(s&&r.push(s),s=[t[e]]):s.push(t[e]))}if(s&&r.push(s),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Ro(r[t],e,1,r[t].length-1,No),r[t]=r[t].slice(0,e));return r}function No(t,e){return e.area-t.area}function $o(t,e,i){const r=i.patternDependencies;let s=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(s=!0);const n=e.constantOr(null);n&&(s=!0,r[n.to]=!0,r[n.from]=!0)}return s}function qo(t,e,i,r,s){const n=s.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},s.availableImages),o=e.evaluate({zoom:r},i,{},s.availableImages),l=e.evaluate({zoom:r+1},i,{},s.availableImages);t=t&&t.name?t.name:t,o=o&&o.name?o.name:o,l=l&&l.name?l.name:l,n[t]=!0,n[o]=!0,n[l]=!0,i.patterns[a.id]={min:t,mid:o,max:l}}}return i}lo.exports=co,lo.exports.default=co,co.deviation=function(t,e,i,r){var s=e&&e.length,n=Math.abs(Bo(t,0,s?e[0]*i:t.length,i));if(s)for(var a=0,o=e.length;a<o;a++)n-=Math.abs(Bo(t,e[a]*i,a<o-1?e[a+1]*i:t.length,i));var l=0;for(a=0;a<r.length;a+=3){var c=r[a]*i,h=r[a+1]*i,u=r[a+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===n&&0===l?0:Math.abs((l-n)/n)},co.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var a=0;a<e;a++)i.vertices.push(t[s][n][a]);s>0&&i.holes.push(r+=t[s-1].length)}return i};class jo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new dn,this.indexArray=new Sn,this.indexArray2=new An,this.programConfigurations=new sa(t.layers,t.zoom),this.segments=new Pn,this.segments2=new Pn,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=$o("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=ua(a,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),h,i))continue;const u=s?r.evaluate(h,{},i,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:ha(a),patterns:{},sortKey:u};n.push(p)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=qo("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,oo),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,i,r,s){for(const t of Uo(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,s=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(s.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),s.push(e[0].x),s.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),s.push(e[t].x),s.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const a=lo.exports(s,n);for(let t=0;t<a.length;t+=3)this.indexArray.emplaceBack(r+a[t],r+a[t+1],r+a[t+2]);i.vertexLength+=e,i.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}}Fr("FillBucket",jo,{omit:["layers","patternFeatures"]});const Zo=new Ts({"fill-sort-key":new xs(mt.layout_fill["fill-sort-key"])});var Go={paint:new Ts({"fill-antialias":new ys(mt.paint_fill["fill-antialias"]),"fill-opacity":new xs(mt.paint_fill["fill-opacity"]),"fill-color":new xs(mt.paint_fill["fill-color"]),"fill-outline-color":new xs(mt.paint_fill["fill-outline-color"]),"fill-translate":new ys(mt.paint_fill["fill-translate"]),"fill-translate-anchor":new ys(mt.paint_fill["fill-translate-anchor"]),"fill-pattern":new vs(mt.paint_fill["fill-pattern"])}),layout:Zo};const Xo=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Wo=Cs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ho}=Xo;var Ko={},Yo=k,Jo=Qo;function Qo(t,e,i,r,s){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=s,t.readFields(tl,this,e)}function tl(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],s=e._values[t.readVarint()];e.properties[r]=s}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function el(t){for(var e,i,r=0,s=0,n=t.length,a=n-1;s<n;a=s++)r+=((i=t[a]).x-(e=t[s]).x)*(e.y+i.y);return r}Qo.types=["Unknown","Point","LineString","Polygon"],Qo.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,s=0,n=0,a=0,o=[];t.pos<i;){if(s<=0){var l=t.readVarint();r=7&l,s=l>>3}if(s--,1===r||2===r)n+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&o.push(e),e=[]),e.push(new Yo(n,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&o.push(e),o},Qo.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,s=0,n=0,a=1/0,o=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(s+=t.readSVarint())<a&&(a=s),s>o&&(o=s),(n+=t.readSVarint())<l&&(l=n),n>c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,o,c]},Qo.prototype.toGeoJSON=function(t,e,i){var r,s,n=this.extent*Math.pow(2,i),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),c=Qo.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+a)/n-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+o)/n)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,s=[],n=0;n<e;n++){var a=el(t[n]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&s.push(i),i=[t[n]]):i.push(t[n]))}return i&&s.push(i),s}(l),r=0;r<l.length;r++)for(s=0;s<l[r].length;s++)h(l[r][s])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var il=Jo,rl=sl;function sl(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(nl,this,e),this.length=this._features.length}function nl(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}sl.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 il(this._pbf,e,this.extent,this._keys,this._values)};var al=rl;function ol(t,e,i){if(3===t){var r=new al(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}Ko.VectorTile=function(t,e){this.layers=t.readFields(ol,{},e)},Ko.VectorTileFeature=Jo,Ko.VectorTileLayer=rl;const ll=Ko.VectorTileFeature.types,cl=Math.pow(2,13);function hl(t,e,i,r,s,n,a,o){t.emplaceBack(e,i,2*Math.floor(r*cl)+a,s*cl*2,n*cl*2,Math.round(o))}class ul{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 mn,this.centroidVertexArray=new hn,this.indexArray=new Sn,this.programConfigurations=new sa(t.layers,t.zoom),this.segments=new Pn,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=$o("fill-extrusion",this.layers,e);for(const{feature:r,id:s,index:n,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ua(r,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),o,i))continue;const l={id:s,sourceLayerIndex:a,index:n,geometry:t?o.geometry:ha(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(qo("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,n,i,{}),e.featureIndex.insert(r,l.geometry,n,a,this.index,!0)}}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}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,Ho),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wo.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,i,r,s){const n={x:0,y:0,vertexCount:0};for(const i of Uo(e,500)){let e=0;for(const t of i)e+=t.length;let r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of i){if(0===t.length)continue;if(dl(t))continue;let e=0;for(let i=0;i<t.length;i++){const s=t[i];if(i>=1){const a=t[i-1];if(!pl(s,a)){r.vertexLength+4>Pn.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(a)._perp()._unit(),i=a.dist(s);e+i>32768&&(e=0),hl(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),hl(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),n.x+=2*s.x,n.y+=2*s.y,n.vertexCount+=2,e+=i,hl(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),hl(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),n.x+=2*a.x,n.y+=2*a.y,n.vertexCount+=2;const o=r.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>Pn.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==ll[t.type])continue;const s=[],a=[],o=r.vertexLength;for(const t of i)if(0!==t.length){t!==i[0]&&a.push(s.length/2);for(let e=0;e<t.length;e++){const i=t[e];hl(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),n.x+=i.x,n.y+=i.y,n.vertexCount+=1,s.push(i.x),s.push(i.y)}}const l=lo.exports(s,a);for(let t=0;t<l.length;t+=3)this.indexArray.emplaceBack(o+l[t],o+l[t+2],o+l[t+1]);r.primitiveLength+=l.length/3,r.vertexLength+=e}for(let t=0;t<n.vertexCount;t++)this.centroidVertexArray.emplaceBack(Math.floor(n.x/n.vertexCount),Math.floor(n.y/n.vertexCount));this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}}function pl(t,e){return t.x===e.x&&(t.x<0||t.x>oa)||t.y===e.y&&(t.y<0||t.y>oa)}function dl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>oa))||t.every((t=>t.y<0))||t.every((t=>t.y>oa))}Fr("FillExtrusionBucket",ul,{omit:["layers","features"]});var ml={paint:new Ts({"fill-extrusion-opacity":new ys(mt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new xs(mt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ys(mt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ys(mt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new vs(mt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new xs(mt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new xs(mt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ys(mt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function fl(t,e){return t.x*e.x+t.y*e.y}function _l(t,e){if(1===t.length){let i=0;const r=e[i++];let s;for(;!s||r.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){const n=e[i],a=t[0],o=s.sub(r),l=n.sub(r),c=a.sub(r),h=fl(o,o),u=fl(o,l),p=fl(l,l),d=fl(c,o),m=fl(c,l),f=h*p-u*u,_=(p*d-u*m)/f,g=(h*m-u*d)/f,y=r.z*(1-_-g)+s.z*_+n.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const gl=Cs([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:yl}=gl,xl=Cs([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:vl}=xl,bl=Ko.VectorTileFeature.types,wl=Math.cos(Math.PI/180*37.5),Tl=Math.pow(2,14)/.5;class Il{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new fn,this.layoutVertexArray2=new _n,this.indexArray=new Sn,this.programConfigurations=new sa(t.layers,t.zoom),this.segments=new Pn,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=$o("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ua(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),c,i))continue;const h=s?r.evaluate(c,{},i):void 0,u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:ha(e),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=qo("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}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,vl)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,yl),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,i,r,s){const n=this.layers[0].layout,a=n.get("line-join").evaluate(t,{}),o=n.get("line-cap"),l=n.get("line-miter-limit"),c=n.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,o,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}addLine(t,e,i,r,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a="Polygon"===bl[e.type];let o=t.length;for(;o>=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l<o-1&&t[l].equals(t[l+1]);)l++;if(o<(a?3:2))return;"bevel"===i&&(s=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*o,this.layoutVertexArray,this.indexArray);let u,p,d,m,f;this.e1=this.e2=-1,a&&(u=t[o-2],f=t[l].sub(u)._unit()._perp());for(let e=l;e<o;e++){if(d=e===o-1?a?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;f&&(m=f),u&&(p=u),u=t[e],f=d?d.sub(u)._unit()._perp():m,m=m||f;let _=m.add(f);0===_.x&&0===_.y||_._unit();const g=m.x*f.x+m.y*f.y,y=_.x*f.x+_.y*f.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<wl&&p&&d,w=m.x*f.y-m.y*f.x>0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}const T=p&&d;let I=T?i:a?"butt":r;if(T&&"round"===I&&(x<n?I="miter":x<=2&&(I="fakeround")),"miter"===I&&x>s&&(I="bevel"),"bevel"===I&&(x>2&&(I="flipbevel"),x<s&&(I="miter")),p&&this.updateDistance(p,u),"miter"===I)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===I){if(x>100)_=f.mult(-1);else{const t=x*m.add(f).mag()/m.sub(f).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===I||"fakeround"===I){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,m,e,i,h),"fakeround"===I){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=f.sub(m)._mult(i)._add(m)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}d&&this.addCurrentVertex(u,f,-e,-i,h)}else if("butt"===I)this.addCurrentVertex(u,_,0,0,h);else if("square"===I){const t=p?1:-1;this.addCurrentVertex(u,_,t,t,h)}else"round"===I&&(p&&(this.addCurrentVertex(u,m,0,0,h),this.addCurrentVertex(u,m,1,1,h,!0)),d&&(this.addCurrentVertex(u,f,-1,-1,h,!0),this.addCurrentVertex(u,f,0,0,h)));if(b&&e<o-1){const t=u.dist(d);if(t>2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,s,n=!1){const a=e.y*r-e.x,o=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,s),this.addHalfVertex(t,a,o,n,!0,-r,s),this.distance>Tl/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,i,r,s,n))}addHalfVertex({x:t,y:e},i,r,s,n,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Tl-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?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()}}Fr("LineBucket",Il,{omit:["layers","patternFeatures"]});const Sl=new Ts({"line-cap":new ys(mt.layout_line["line-cap"]),"line-join":new xs(mt.layout_line["line-join"]),"line-miter-limit":new ys(mt.layout_line["line-miter-limit"]),"line-round-limit":new ys(mt.layout_line["line-round-limit"]),"line-sort-key":new xs(mt.layout_line["line-sort-key"])});var Al={paint:new Ts({"line-opacity":new xs(mt.paint_line["line-opacity"]),"line-color":new xs(mt.paint_line["line-color"]),"line-translate":new ys(mt.paint_line["line-translate"]),"line-translate-anchor":new ys(mt.paint_line["line-translate-anchor"]),"line-width":new xs(mt.paint_line["line-width"]),"line-gap-width":new xs(mt.paint_line["line-gap-width"]),"line-offset":new xs(mt.paint_line["line-offset"]),"line-blur":new xs(mt.paint_line["line-blur"]),"line-dasharray":new bs(mt.paint_line["line-dasharray"]),"line-pattern":new vs(mt.paint_line["line-pattern"]),"line-gradient":new ws(mt.paint_line["line-gradient"])}),layout:Sl};const zl=new class extends xs{possiblyEvaluate(t,e){return e=new cs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=u({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Al.paint.properties["line-width"].specification);function El(t,e){return e>0?e+2*t:t}zl.useIntegerZoom=!0;const Cl=Cs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Pl=Cs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Cs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kl=Cs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Cs([{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 Ml=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Dl=Cs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Ll(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),t}(t.text,e,i)})),t}Cs([{name:"triangle",components:3,type:"Uint16"}]),Cs([{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"}]),Cs([{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Cs([{type:"Float32",name:"offsetX"}]),Cs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Bl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Rl=Vl,Fl=function(t,e,i,r,s){var n,a,o=8*s-r-1,l=(1<<o)-1,c=l>>1,h=-7,u=i?s-1:0,p=i?-1:1,d=t[e+u];for(u+=p,n=d&(1<<-h)-1,d>>=-h,h+=o;h>0;n=256*n+t[e+u],u+=p,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=r;h>0;a=256*a+t[e+u],u+=p,h-=8);if(0===n)n=1-c;else{if(n===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),n-=c}return(d?-1:1)*a*Math.pow(2,n-r)},Ol=function(t,e,i,r,s,n){var a,o,l,c=8*n-s-1,h=(1<<c)-1,u=h>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:n-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(a++,l/=2),a+u>=h?(o=0,a=h):a+u>=1?(o=(e*l-1)*Math.pow(2,s),a+=u):(o=e*Math.pow(2,u-1)*Math.pow(2,s),a=0));s>=8;t[i+d]=255&o,d+=m,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;t[i+d]=255&a,d+=m,a/=256,c-=8);t[i+d-m]|=128*f};function Vl(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Vl.Varint=0,Vl.Fixed64=1,Vl.Bytes=2,Vl.Fixed32=5;var Ul,Nl=4294967296,$l=1/Nl,ql="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jl(t){return t.type===Vl.Bytes?t.readVarint()+t.pos:t.pos+1}function Zl(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Gl(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var s=i.pos-1;s>=t;s--)i.buf[s+r]=i.buf[s]}function Xl(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function Wl(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function Hl(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function Kl(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function Yl(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function Jl(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function Ql(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function tc(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function ec(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function ic(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function rc(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function sc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function nc(t,e,i){1===t&&i.readMessage(ac,e)}function ac(t,e,i){if(3===t){const{id:t,bitmap:r,width:s,height:n,left:a,top:o,advance:l}=i.readMessage(oc,{});e.push({id:t,bitmap:new io({width:s+6,height:n+6},r),metrics:{width:s,height:n,left:a,top:o,advance:l}})}}function oc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function lc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:s,h:n,fill:e/(s*n)||0}}Vl.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),s=r>>3,n=this.pos;this.type=7&r,t(s,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=ic(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=sc(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=ic(this.buf,this.pos)+ic(this.buf,this.pos+4)*Nl;return this.pos+=8,t},readSFixed64:function(){var t=ic(this.buf,this.pos)+sc(this.buf,this.pos+4)*Nl;return this.pos+=8,t},readFloat:function(){var t=Fl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Fl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,s,n=i.buf;if(r=(112&(s=n[i.pos++]))>>4,s<128)return Zl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<3,s<128)return Zl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<10,s<128)return Zl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<17,s<128)return Zl(t,r,e);if(r|=(127&(s=n[i.pos++]))<<24,s<128)return Zl(t,r,e);if(r|=(1&(s=n[i.pos++]))<<31,s<128)return Zl(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ql?function(t,e,i){return ql.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",s=e;s<i;){var n,a,o,l=t[s],c=null,h=l>239?4:l>223?3:l>191?2:1;if(s+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(n=t[s+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===h?(a=t[s+2],128==(192&(n=t[s+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&n)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(a=t[s+2],o=t[s+3],128==(192&(n=t[s+1]))&&128==(192&a)&&128==(192&o)&&((c=(15&l)<<18|(63&n)<<12|(63&a)<<6|63&o)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),s+=h}return r}(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!==Vl.Bytes)return t.push(this.readVarint(e));var i=jl(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Vl.Bytes)return t.push(this.readSVarint());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Vl.Bytes)return t.push(this.readBoolean());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Vl.Bytes)return t.push(this.readFloat());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Vl.Bytes)return t.push(this.readDouble());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Vl.Bytes)return t.push(this.readFixed32());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Vl.Bytes)return t.push(this.readSFixed32());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Vl.Bytes)return t.push(this.readFixed64());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Vl.Bytes)return t.push(this.readSFixed64());var e=jl(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Vl.Varint)for(;this.buf[this.pos++]>127;);else if(e===Vl.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Vl.Fixed32)this.pos+=4;else{if(e!==Vl.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;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),rc(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),rc(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),rc(this.buf,-1&t,this.pos),rc(this.buf,Math.floor(t*$l),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),rc(this.buf,-1&t,this.pos),rc(this.buf,Math.floor(t*$l),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((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)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,s,n=0;n<e.length;n++){if((r=e.charCodeAt(n))>55295&&r<57344){if(!s){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):s=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,s=r;continue}r=s-55296<<10|r-56320|65536,s=null}else s&&(t[i++]=239,t[i++]=191,t[i++]=189,s=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&Gl(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Ol(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Ol(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 i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&Gl(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,Vl.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Xl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Wl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Yl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Hl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Kl,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Jl,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Ql,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,tc,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ec,e)},writeBytesField:function(t,e){this.writeTag(t,Vl.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Vl.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Vl.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Vl.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Vl.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Vl.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Vl.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Vl.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Vl.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Vl.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class cc{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:s,content:n}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=s,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}function hc(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function uc(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new cs(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let s=0;for(;s<e.length&&e[s]<=t;)s++;s=Math.max(0,s-1);let n=s;for(;n<e.length&&e[n]<t+1;)n++;n=Math.min(e.length-1,n);const a=e[s],o=e[n];return"composite"===i.kind?{kind:"composite",minZoom:a,maxZoom:o,interpolationType:r}:{kind:"camera",minZoom:a,maxZoom:o,minSize:i.evaluate(new cs(a)),maxSize:i.evaluate(new cs(o)),interpolationType:r}}}function pc(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return"source"===t.kind?r/128:"composite"===t.kind?Re(r/128,s/128,i):e}function dc(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:s,minZoom:n,maxZoom:a}=t,o=s?l(ei.interpolationFactor(s,e,n,a),0,1):0;"camera"===t.kind?r=Re(t.minSize,t.maxSize,o):i=o}return{uSizeT:i,uSize:r}}Fr("ImagePosition",cc),Fr("ImageAtlas",class{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const s=[];this.addImages(t,i,s),this.addImages(e,r,s);const{w:n,h:a}=lc(s),o=new ro({width:n||1,height:a||1});for(const e in t){const r=t[e],s=i[e].paddedRect;ro.copy(r.data,o,{x:0,y:0},{x:s.x+1,y:s.y+1},r.data)}for(const t in e){const i=e[t],s=r[t].paddedRect,n=s.x+1,a=s.y+1,l=i.data.width,c=i.data.height;ro.copy(i.data,o,{x:0,y:0},{x:n,y:a},i.data),ro.copy(i.data,o,{x:0,y:c-1},{x:n,y:a-1},{width:l,height:1}),ro.copy(i.data,o,{x:0,y:0},{x:n,y:a+c},{width:l,height:1}),ro.copy(i.data,o,{x:l-1,y:0},{x:n-1,y:a},{width:1,height:c}),ro.copy(i.data,o,{x:0,y:0},{x:n+l,y:a},{width:1,height:c})}this.image=o,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const s=t[r],n={x:0,y:0,w:s.data.width+2,h:s.data.height+2};i.push(n),e[r]=new cc(n,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,s]=t.tl;i.update(e.data,void 0,{x:r,y:s})}}),function(t){t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly"}(Ul||(Ul={}));class mc extends k{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new mc(this.x,this.y,this.angle,this.segment)}}Fr("Anchor",mc);const fc=Number.POSITIVE_INFINITY;function _c(t,e){return e[1]!==fc?function(t,e,i){let r=0,s=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,s]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const s=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=s-7;break;case"bottom-right":case"bottom-left":r=7-s;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}const gc=Ko.VectorTileFeature.types,yc=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xc(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=o?Math.min(32640,Math.round(o[0])):0,m=o?Math.min(32640,Math.round(o[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*s),n,a,(d<<1)+(l?1:0),m,16*c,16*h,256*u,256*p)}function vc(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function bc(t){for(const e of t.sections)if(Kr(e.text))return!0;return!1}class wc{constructor(t){this.layoutVertexArray=new yn,this.indexArray=new Sn,this.programConfigurations=t,this.segments=new Pn,this.dynamicLayoutVertexArray=new xn,this.opacityVertexArray=new vn,this.placedSymbolArray=new rn}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Cl.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Pl.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,yc,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Fr("SymbolBuffers",wc);class Tc{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Pn,this.collisionVertexArray=new Tn}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,kl.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Fr("CollisionBuffers",Tc);class Ic{constructor(t){this.collisionBoxArray=t.collisionBoxArray,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.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=La([]),this.placementViewportMatrix=La([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=uc(this.zoom,e["text-size"]),this.iconSizeData=uc(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap="never"!==Cc(i,"text-overlap","text-allow-overlap")||"never"!==Cc(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>Ul[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new wc(new sa(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new wc(new sa(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new an,this.lineVertexArray=new on,this.symbolInstances=new nn}calculateGlyphDependencies(t,e,i,r,s){for(let n=0;n<t.length;n++)if(e[t.charCodeAt(n)]=!0,(i||r)&&s){const i=Bl[t.charAt(n)];i&&(e[i.charCodeAt(0)]=!0)}}populate(t,e,i){const r=this.layers[0],s=r.layout,n=s.get("text-font"),a=s.get("text-field"),o=s.get("icon-image"),l=("constant"!==a.value.kind||a.value.value instanceof Wt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),c="constant"!==o.value.kind||!!o.value.value||Object.keys(o.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!l&&!c)return;const u=e.iconDependencies,p=e.glyphDependencies,d=e.availableImages,m=new cs(this.zoom);for(const{feature:e,id:a,index:o,sourceLayerIndex:f}of t){const t=r._featureFilter.needGeometry,_=ua(e,t);if(!r._featureFilter.filter(m,_,i))continue;let g,y;if(t||(_.geometry=ha(e)),l){const t=r.getValueAndResolveTokens("text-field",_,i,d),e=Wt.factory(t);bc(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===as()||this.hasRTLText&&ls.isParsed())&&(g=Ll(e,r,_))}if(c){const t=r.getValueAndResolveTokens("icon-image",_,i,d);y=t instanceof Kt?t:Kt.fromString(t)}if(!g&&!y)continue;const x=this.sortFeaturesByKey?h.evaluate(_,{},i):void 0;if(this.features.push({id:a,text:g,icon:y,index:o,sourceLayerIndex:f,geometry:_.geometry,properties:e.properties,type:gc[e.type],sortKey:x}),y&&(u[y.name]=!0),g){const t=n.evaluate(_,{},i).join(","),e="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ul.vertical)>=0;for(const i of g.sections)if(i.image)u[i.image.name]=!0;else{const r=Gr(g.toString()),s=i.fontStack||t,n=p[s]=p[s]||{};this.calculateGlyphDependencies(i.text,n,e,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let s=0;function n(e){r.push(t[e]),s++}function a(t,e,s){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(s[0]),n}function o(t,i,s){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=s[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){n(c);continue}const d=l(p,u),m=l(p,u,!0);if(d in i&&m in e&&i[d]!==e[m]){const t=o(d,m,u),s=a(d,m,r[t].geometry);delete e[d],delete i[m],i[l(p,r[s].geometry,!0)]=s,r[t].geometry=null}else d in i?a(d,m,u):m in e?o(d,m,u):(n(c),e[d]=s-1,i[m]=s-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const s={};for(let r=t.segment+1;r<e.length;r++)s[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,s,n,a,o,l,c,h,u){const p=t.indexArray,d=t.layoutVertexArray,m=t.segments.prepareSegment(4*e.length,d,p,this.canOverlap?n.sortKey:void 0),f=this.glyphOffsetArray.length,_=m.vertexLength,g=this.allowVerticalPlacement&&a===Ul.vertical?Math.PI/2:0,y=n.text&&n.text.sections;for(let r=0;r<e.length;r++){const{tl:s,tr:a,bl:l,br:c,tex:h,pixelOffsetTL:f,pixelOffsetBR:_,minFontScaleX:x,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=e[r],I=m.vertexLength,S=b[1];xc(d,o.x,o.y,s.x,S+s.y,h.x,h.y,i,w,f.x,f.y,x,v),xc(d,o.x,o.y,a.x,S+a.y,h.x+h.w,h.y,i,w,_.x,f.y,x,v),xc(d,o.x,o.y,l.x,S+l.y,h.x,h.y+h.h,i,w,f.x,_.y,x,v),xc(d,o.x,o.y,c.x,S+c.y,h.x+h.w,h.y+h.h,i,w,_.x,_.y,x,v),vc(t.dynamicLayoutVertexArray,o,g),p.emplaceBack(I,I+1,I+2),p.emplaceBack(I+1,I+2,I+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),r!==e.length-1&&T===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(d.length,n,n.index,{},u,y&&y[T])}t.placedSymbolArray.emplaceBack(o.x,o.y,f,this.glyphOffsetArray.length-f,_,l,c,o.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],a,0,!1,0,h)}_addCollisionDebugVertex(t,e,i,r,s,n){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,s,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(t,e,i,r,s,n,a){const o=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),l=o.vertexLength,c=s.layoutVertexArray,h=s.collisionVertexArray,u=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(c,h,n,u,p,new k(t,e)),this._addCollisionDebugVertex(c,h,n,u,p,new k(i,e)),this._addCollisionDebugVertex(c,h,n,u,p,new k(i,r)),this._addCollisionDebugVertex(c,h,n,u,p,new k(t,r)),o.vertexLength+=4;const d=s.indexArray;d.emplaceBack(l,l+1),d.emplaceBack(l+1,l+2),d.emplaceBack(l+2,l+3),d.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let s=t;s<e;s++){const t=this.collisionBoxArray.get(s);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Tc(bn,Ml.members,An),this.iconCollisionBox=new Tc(bn,Ml.members,An);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,s,n,a,o,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<s;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=n;e<a;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=o;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],s=[],n=[];for(let t=0;t<this.symbolInstances.length;++t){n.push(t);const a=this.symbolInstances.get(t);r.push(0|Math.round(e*a.anchorX+i*a.anchorY)),s.push(a.featureIndex)}return n.sort(((t,e)=>r[t]-r[e]||s[e]-s[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Fr("SymbolBucket",Ic,{omit:["layers","collisionBoxArray","features","compareText"]}),Ic.MAX_GLYPHS=65535,Ic.addDynamicAttributes=vc;const Sc=new Ts({"symbol-placement":new ys(mt.layout_symbol["symbol-placement"]),"symbol-spacing":new ys(mt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ys(mt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new xs(mt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ys(mt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ys(mt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new ys(mt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new ys(mt.layout_symbol["icon-ignore-placement"]),"icon-optional":new ys(mt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ys(mt.layout_symbol["icon-rotation-alignment"]),"icon-size":new xs(mt.layout_symbol["icon-size"]),"icon-text-fit":new ys(mt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ys(mt.layout_symbol["icon-text-fit-padding"]),"icon-image":new xs(mt.layout_symbol["icon-image"]),"icon-rotate":new xs(mt.layout_symbol["icon-rotate"]),"icon-padding":new xs(mt.layout_symbol["icon-padding"]),"icon-keep-upright":new ys(mt.layout_symbol["icon-keep-upright"]),"icon-offset":new xs(mt.layout_symbol["icon-offset"]),"icon-anchor":new xs(mt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ys(mt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ys(mt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ys(mt.layout_symbol["text-rotation-alignment"]),"text-field":new xs(mt.layout_symbol["text-field"]),"text-font":new xs(mt.layout_symbol["text-font"]),"text-size":new xs(mt.layout_symbol["text-size"]),"text-max-width":new xs(mt.layout_symbol["text-max-width"]),"text-line-height":new ys(mt.layout_symbol["text-line-height"]),"text-letter-spacing":new xs(mt.layout_symbol["text-letter-spacing"]),"text-justify":new xs(mt.layout_symbol["text-justify"]),"text-radial-offset":new xs(mt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ys(mt.layout_symbol["text-variable-anchor"]),"text-anchor":new xs(mt.layout_symbol["text-anchor"]),"text-max-angle":new ys(mt.layout_symbol["text-max-angle"]),"text-writing-mode":new ys(mt.layout_symbol["text-writing-mode"]),"text-rotate":new xs(mt.layout_symbol["text-rotate"]),"text-padding":new ys(mt.layout_symbol["text-padding"]),"text-keep-upright":new ys(mt.layout_symbol["text-keep-upright"]),"text-transform":new xs(mt.layout_symbol["text-transform"]),"text-offset":new xs(mt.layout_symbol["text-offset"]),"text-allow-overlap":new ys(mt.layout_symbol["text-allow-overlap"]),"text-overlap":new ys(mt.layout_symbol["text-overlap"]),"text-ignore-placement":new ys(mt.layout_symbol["text-ignore-placement"]),"text-optional":new ys(mt.layout_symbol["text-optional"])});var Ac={paint:new Ts({"icon-opacity":new xs(mt.paint_symbol["icon-opacity"]),"icon-color":new xs(mt.paint_symbol["icon-color"]),"icon-halo-color":new xs(mt.paint_symbol["icon-halo-color"]),"icon-halo-width":new xs(mt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new xs(mt.paint_symbol["icon-halo-blur"]),"icon-translate":new ys(mt.paint_symbol["icon-translate"]),"icon-translate-anchor":new ys(mt.paint_symbol["icon-translate-anchor"]),"text-opacity":new xs(mt.paint_symbol["text-opacity"]),"text-color":new xs(mt.paint_symbol["text-color"],{runtimeType:At,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new xs(mt.paint_symbol["text-halo-color"]),"text-halo-width":new xs(mt.paint_symbol["text-halo-width"]),"text-halo-blur":new xs(mt.paint_symbol["text-halo-blur"]),"text-translate":new ys(mt.paint_symbol["text-translate"]),"text-translate-anchor":new ys(mt.paint_symbol["text-translate-anchor"])}),layout:Sc};class zc{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:wt,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}}Fr("FormatSectionOverride",zc,{omit:["defaultValue"]});class Ec extends Ss{constructor(t){super(t,Ac)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const s=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||ji(n.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new Ic(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Ac.paint.overridableProperties){if(!Ec.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new zc(e),r=new qi(i,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new Gi("source",r):new Xi("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new _s(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Ec.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Ac.paint.properties[e];let s=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof Wt)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{s||(e instanceof ee&&Qt(e.value)===Pt?n(e.value.sections):e instanceof bi?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}function Cc(t,e,i){let r="never";const s=t.get(e);return s?r=s:t.get(i)&&(r="always"),r}var Pc={paint:new Ts({"background-color":new ys(mt.paint_background["background-color"]),"background-pattern":new bs(mt.paint_background["background-pattern"]),"background-opacity":new ys(mt.paint_background["background-opacity"])})},kc={paint:new Ts({"raster-opacity":new ys(mt.paint_raster["raster-opacity"]),"raster-hue-rotate":new ys(mt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ys(mt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ys(mt.paint_raster["raster-brightness-max"]),"raster-saturation":new ys(mt.paint_raster["raster-saturation"]),"raster-contrast":new ys(mt.paint_raster["raster-contrast"]),"raster-resampling":new ys(mt.paint_raster["raster-resampling"]),"raster-fade-duration":new ys(mt.paint_raster["raster-fade-duration"])})};class Mc extends Ss{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(){}}const Dc={circle:class extends Ss{constructor(t){super(t,Ca)}createBucket(t){return new da(t)}queryRadius(t){const e=t;return Sa("circle-radius",this,e)+Sa("circle-stroke-width",this,e)+Aa(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a,o){const l=za(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),n.angle,a),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e){return t.map((t=>Ka(t,e)))}(l,o),p=h?c*a:c;for(const t of r)for(const e of t){const t=h?e:Ka(e,o);let i=p;const r=Xa([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r[3]),fa(u,t,i))return!0}return!1}},heatmap:class extends Ss{constructor(t){super(t,Ja),this._updateColorRamp()}createBucket(t){return new Ya(t)}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=so({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}},hillshade:class extends Ss{constructor(t){super(t,no)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}},fill:class extends Ss{constructor(t){super(t,Go)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new jo(t)}queryRadius(){return Aa(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a){return _a(za(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),n.angle,a),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Ss{constructor(t){super(t,ml)}createBucket(t){return new ul(t)}queryRadius(){return Aa(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,s,n,a,o){const l=za(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),n.angle,a),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e,i,r){const s=[];for(const i of t){const t=[i.x,i.y,0,1];Xa(t,t,e),s.push(new k(t[0]/t[3],t[1]/t[3]))}return s}(l,o),p=function(t,e,i,r){const s=[],n=[],a=r[8]*e,o=r[9]*e,l=r[10]*e,c=r[11]*e,h=r[8]*i,u=r[9]*i,p=r[10]*i,d=r[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x,n=s.y,m=r[0]*e+r[4]*n+r[12],f=r[1]*e+r[5]*n+r[13],_=r[2]*e+r[6]*n+r[14],g=r[3]*e+r[7]*n+r[15],y=_+l,x=g+c,v=m+h,b=f+u,w=_+p,T=g+d,I=new k((m+a)/x,(f+o)/x);I.z=y/x,t.push(I);const S=new k(v/T,b/T);S.z=w/T,i.push(S)}s.push(t),n.push(i)}return[s,n]}(r,h,c,o);return function(t,e,i){let r=1/0;_a(i,e)&&(r=_l(i,e[0]));for(let s=0;s<e.length;s++){const n=e[s],a=t[s];for(let t=0;t<n.length-1;t++){const e=n[t],s=[e,n[t+1],a[t+1],a[t],e];ma(i,s)&&(r=Math.min(r,_l(i,s)))}}return r!==1/0&&r}(p[0],p[1],u)}},line:class extends Ss{constructor(t){super(t,Al),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof Be,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"]=zl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Il(t)}queryRadius(t){const e=t,i=El(Sa("line-width",this,e),Sa("line-gap-width",this,e)),r=Sa("line-offset",this,e);return i/2+Math.abs(r)+Aa(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,s,n,a){const o=za(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),n.angle,a),l=a/2*El(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[];for(let r=0;r<t.length;r++){const s=t[r],n=[];for(let t=0;t<s.length;t++){const i=s[t-1],r=s[t],a=s[t+1],o=0===t?new k(0,0):r.sub(i)._unit()._perp(),l=t===s.length-1?new k(0,0):a.sub(r)._unit()._perp(),c=o._add(l)._unit(),h=c.x*l.x+c.y*l.y;0!==h&&c._mult(1/h),n.push(c._mult(e)._add(r))}i.push(n)}return i}(r,c*a)),function(t,e,i){for(let r=0;r<e.length;r++){const s=e[r];if(t.length>=3)for(let e=0;e<s.length;e++)if(Ta(t,s[e]))return!0;if(ga(t,s,i))return!0}return!1}(o,r,l)}isTileClipped(){return!0}},symbol:Ec,background:class extends Ss{constructor(t){super(t,Pc)}},raster:class extends Ss{constructor(t){super(t,kc)}}};function Lc(t){return"custom"===t.type?new Mc(t):new Dc[t.type](t)}class Bc{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:s}=t,n=!(this.size&&this.size[0]===r&&this.size[1]===s||i),{context:a}=this,{gl:o}=a;if(this.useMipmap=Boolean(e&&e.useMipmap),o.bindTexture(o.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA&&(!e||!1!==e.premultiply)),n)this.size=[r,s],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||C(t)?o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,o.UNSIGNED_BYTE,t):o.texImage2D(o.TEXTURE_2D,0,this.format,r,s,0,this.format,o.UNSIGNED_BYTE,t.data);else{const{x:e,y:n}=i||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||C(t)?o.texSubImage2D(o.TEXTURE_2D,0,e,n,o.RGBA,o.UNSIGNED_BYTE,t):o.texSubImage2D(o.TEXTURE_2D,0,e,n,r,s,o.RGBA,o.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.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 Rc(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class Fc extends dt{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new ro({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0;return this._validateStretch(e.stretchX,e.data&&e.data.width)||(this.fire(new pt(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,e.data&&e.data.height)||(this.fire(new pt(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new pt(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(t,e){const i={};for(const e of t){this.images[e]||this.fire(new ut("styleimagemissing",{id:e}));const t=this.images[e];t?i[e]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:v(`Image "${e}" 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.`)}e(null,i)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const e=this.patterns[t],i=this.getImage(t);if(!i)return null;if(e&&e.position.version===i.version)return e.position;if(e)e.position.version=i.version;else{const e={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new cc(e,i);this.patterns[t]={bin:e,position:r}}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 Bc(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:e,h:i}=lc(t),r=this.atlasImage;r.resize({width:e||1,height:i||1});for(const t in this.patterns){const{bin:e}=this.patterns[t],i=e.x+1,s=e.y+1,n=this.images[t].data,a=n.width,o=n.height;ro.copy(n,r,{x:0,y:0},{x:i,y:s},{width:a,height:o}),ro.copy(n,r,{x:0,y:o-1},{x:i,y:s-1},{width:a,height:1}),ro.copy(n,r,{x:0,y:0},{x:i,y:s+o},{width:a,height:1}),ro.copy(n,r,{x:a-1,y:0},{x:i-1,y:s},{width:1,height:o}),ro.copy(n,r,{x:0,y:0},{x:i+a,y:s},{width:1,height:o})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];Rc(t)&&this.updateImage(e,t)}}}const Oc=1e20;function Vc(t,e,i,r,s,n,a,o,l){for(let c=e;c<e+r;c++)Uc(t,i*n+c,n,s,a,o,l);for(let c=i;c<i+s;c++)Uc(t,c*n+e,1,r,a,o,l)}function Uc(t,e,i,r,s,n,a){n[0]=0,a[0]=-Oc,a[1]=Oc,s[0]=t[e];for(let o=1,l=0,c=0;o<r;o++){s[o]=t[e+o*i];const r=o*o;do{const t=n[l];c=(s[o]-s[t]+r-t*t)/(o-t)/2}while(c<=a[l]&&--l>-1);l++,n[l]=o,a[l]=c,a[l+1]=Oc}for(let o=0,l=0;o<r;o++){for(;a[l+1]<o;)l++;const r=n[l],c=o-r;t[e+o*i]=s[r]+c*c}}class Nc{constructor(t,e){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});h(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let s=r.glyphs[e];if(void 0!==s)return void i(null,{stack:t,id:e,glyph:s});if(s=this._tinySDF(r,t,e),s)return r.glyphs[e]=s,void i(null,{stack:t,id:e,glyph:s});const n=Math.floor(e/256);if(256*n>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[n])return void i(null,{stack:t,id:e,glyph:s});let a=r.requests[n];a||(a=r.requests[n]=[],Nc.loadGlyphRange(t,n,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[n]=!0}for(const i of a)i(t,e);delete r.requests[n]}))),a.push(((r,s)=>{r?i(r):s&&i(null,{stack:t,id:e,glyph:s[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:s}of i)(t[e]||(t[e]={}))[r]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};e(null,t)}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(jr(t)||Zr(t)||$r(t)||qr(t))}_tinySDF(t,e,i){const r=this.localIdeographFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(i))return;let s=t.tinySDF;if(!s){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),s=t.tinySDF=new Nc.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:r,fontWeight:i})}const n=s.draw(String.fromCharCode(i));return{id:i,bitmap:new io({width:n.width||30,height:n.height||30},n.data),metrics:{width:n.glyphWidth||24,height:n.glyphHeight||24,left:n.glyphLeft||0,top:n.glyphTop-27||-8,advance:n.glyphAdvance||24}}}}Nc.loadGlyphRange=function(t,e,i,r,s){const n=256*e,a=n+255,o=r.transformRequest(i.replace("{fontstack}",t).replace("{range}",`${n}-${a}`),H.Glyphs);et(o,((t,e)=>{if(t)s(t);else if(e){const t={};for(const i of function(t){return new Rl(t).readFields(nc,[])}(e))t[i.id]=i;s(null,t)}}))},Nc.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:n="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const o=this.size=t+4*e,l=this._createCanvas(o),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${n} ${t}px ${s}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:n}=this.ctx.measureText(t),a=Math.ceil(i),o=Math.min(this.size-this.buffer,Math.ceil(n-s)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=o+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return d;const{ctx:m,buffer:f,gridInner:_,gridOuter:g}=this;m.clearRect(f,f,o,l),m.fillText(t,f,f+a);const y=m.getImageData(f,f,o,l);g.fill(Oc,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<o;e++){const i=y.data[4*(t*o+e)+3]/255;if(0===i)continue;const r=(t+f)*c+e+f;if(1===i)g[r]=0,_[r]=Oc;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}Vc(g,0,0,c,h,c,this.f,this.v,this.z),Vc(_,f,f,o,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};const $c=new Ts({anchor:new ys(mt.light.anchor),position:new class{constructor(){this.specification=mt.light.position}possiblyEvaluate(t,e){return function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Re(t.x,e.x,i),y:Re(t.y,e.y,i),z:Re(t.z,e.z,i)}}},color:new ys(mt.light.color),intensity:new ys(mt.light.intensity)}),qc="-transition";class jc extends dt{constructor(t){super(),this._transitionable=new ps($c),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,e={}){if(!this._validate(kr,t,e))for(const e in t){const i=t[e];e.endsWith(qc)?this._transitionable.setTransition(e.slice(0,-qc.length),i):this._transitionable.setValue(e,i)}}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,e,i){return(!i||!1!==i.validate)&&Lr(this,t.call(Pr,u({value:e,style:{glyphs:!0,sprite:!0},styleSpec:mt})))}}class Zc{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 i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}getDashRanges(t,e,i){const r=[];let s=t.length%2==1?-t[t.length-1]*i:0,n=t[0]*i,a=!0;r.push({left:s,right:n,isDash:a,zeroLength:0===t[0]});let o=t[0];for(let e=1;e<t.length;e++){a=!a;const l=t[e];s=o*i,o+=l,n=o*i,r.push({left:s,right:n,isDash:a,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const s=this.width*(this.nextRow+i+e);let n=0,a=t[n];for(let o=0;o<this.width;o++){o/a.right>1&&(a=t[++n]);const l=Math.abs(o-a.left),c=Math.abs(o-a.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(a.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[s+o]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let s=0,n=t[s];for(let e=0;e<this.width;e++){e/n.right>1&&(n=t[++s]);const i=Math.abs(e-n.left),a=Math.abs(e-n.right),o=Math.min(i,a);this.data[r+e]=Math.max(0,Math.min(255,(n.isDash?o:-o)+128))}}addDash(t,e){const i=e?7:0,r=2*i+1;if(this.nextRow+r>this.height)return v("LineAtlas out of space"),null;let s=0;for(let e=0;e<t.length;e++)s+=t[e];if(0!==s){const r=this.width/s,n=this.getDashRanges(t,this.width,r);e?this.addRoundDash(n,r,i):this.addRegularDash(n)}const n={y:(this.nextRow+i+.5)/this.height,height:2*i/this.height,width:s};return this.nextRow+=r,this.dirty=!0,n}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}class Gc{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){delete this._channel,this._callback=()=>{}}}class Xc{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=m();const i=this.workerPool.acquire(this.id);for(let t=0;t<i.length;t++){const r=new Xc.Actor(i[t],e,this.id);r.name=`Worker ${t}`,this.actors.push(r)}}broadcast(t,e,i){h(this.actors,((i,r)=>{i.send(t,e,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function Wc(t,e,i){const r=function(e,r){if(e)return i(e);if(r){const e=p(u(r,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(e.vectorLayers=r.vector_layers,e.vectorLayerIds=e.vectorLayers.map((t=>t.id))),i(null,e)}};return t.url?tt(e.transformRequest(t.url,H.Source),r):P.frame((()=>r(null,t)))}Xc.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},f(["receive","process"],this),this.invoker=new Gc(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=T()?t:window}send(t,e,i,r,s=!1){const n=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(this.callbacks[n]=i);const a=E(this.globalScope)?void 0:[];return this.target.postMessage({id:n,type:t,hasCallback:!!i,targetMapId:r,mustQueue:s,sourceMapId:this.mapId,data:Vr(e,a)},a),{cancel:()=>{i&&delete this.callbacks[n],this.target.postMessage({id:n,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){delete this.tasks[i];const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t()}else T()||e.mustQueue?(this.tasks[i]=e,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,e)}process(){if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ur(e.error)):i(null,Ur(e.data)))}else{let i=!1;const r=E(this.globalScope)?void 0:[],s=e.hasCallback?(e,s)=>{i=!0,delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Vr(e):null,data:Vr(s,r)},r)}:t=>{i=!0};let n=null;const a=Ur(e.data);if(this.parent[e.type])n=this.parent[e.type](e.sourceMapId,a,s);else if(this.parent.getWorkerSource){const t=e.type.split(".");n=this.parent.getWorkerSource(e.sourceMapId,t[0],a.source)[t[1]](a,s)}else s(new Error(`Could not find function ${e.type}`));!i&&n&&n.cancel&&(this.cancelCallbacks[t]=n.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}};const Hc=6371008.8;class Kc{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 Kc(c(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,i=this.lat*e,r=t.lat*e,s=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Hc*Math.acos(Math.min(s,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Yc(new Kc(this.lng-i,this.lat-e),new Kc(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Kc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Kc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Kc(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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Yc{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):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 Kc?new Kc(t.lng,t.lat):Kc.convert(t),this}setSouthWest(t){return this._sw=t instanceof Kc?new Kc(t.lng,t.lat):Kc.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,s;if(t instanceof Kc)r=t,s=t;else{if(!(t instanceof Yc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Yc.convert(t)):this.extend(Kc.convert(t)):this;if(r=t._sw,s=t._ne,!r||!s)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(s.lng,i.lng),i.lat=Math.max(s.lat,i.lat)):(this._sw=new Kc(r.lng,r.lat),this._ne=new Kc(s.lng,s.lat)),this}getCenter(){return new Kc((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 Kc(this.getWest(),this.getNorth())}getSouthEast(){return new Kc(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:e,lat:i}=Kc.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return t instanceof Yc?t:t?new Yc(t):t}}const Jc=2*Math.PI*Hc;function Qc(t){return Jc*Math.cos(t*Math.PI/180)}function th(t){return(180+t)/360}function eh(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ih(t,e){return t/Qc(e)}function rh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class sh{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Kc.convert(t);return new sh(th(i.lng),eh(i.lat),ih(e,i.lat))}toLngLat(){return new Kc(360*this.x-180,rh(this.y))}toAltitude(){return this.z*Qc(rh(this.y))}meterInMercatorCoordinateUnits(){return 1/Jc*(t=rh(this.y),1/Math.cos(t*Math.PI/180));var t}}class nh{constructor(t,e,i){this.bounds=Yc.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||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 e=Math.pow(2,t.z),i=Math.floor(th(this.bounds.getWest())*e),r=Math.floor(eh(this.bounds.getNorth())*e),s=Math.ceil(th(this.bounds.getEast())*e),n=Math.ceil(eh(this.bounds.getSouth())*e);return t.x>=i&&t.x<s&&t.y>=r&&t.y<n}}class ah extends dt{constructor(t,e,i,r){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,u(this,p(e,["url","scheme","tileSize","promoteId"])),this._options=u({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}load(){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this._tileJSONRequest=Wc(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),t?this.fire(new pt(t)):e&&(u(this,e),e.bounds&&(this.tileBounds=new nh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),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}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return u({},this._options)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:this.map._requestManager.transformRequest(i,H.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};function s(i,r){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),$(this.dispatcher),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state?"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",r,s.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class oh extends dt{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=u({type:"raster"},e),u(this,p(e,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this._tileJSONRequest=Wc(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new pt(t)):e&&(u(this,e),e.bounds&&(this.tileBounds=new nh(e.bounds,this.minzoom,this.maxzoom)),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return u({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=at(this.map._requestManager.transformRequest(i,H.Tile),((i,r,s)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(r){this.map._refreshExpiredTiles&&t.setExpiryData(s);const i=this.map.painter.context,n=i.gl;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new Bc(i,r,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),i.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",$(this.dispatcher),e(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let lh;function ch(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class hh{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=dh(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(n=this.y,a=this.z,o=ch(256*(s=this.x),256*(n=Math.pow(2,a)-n-1),a),l=ch(256*(s+1),256*(n+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var s,n,a,o,l;const c=function(t,e,i){let r,s="";for(let n=t;n>0;n--)r=1<<n-1,s+=(e&r?1:0)+(i&r?2:0);return s}(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"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}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 k((t.x*e-this.x)*oa,(t.y*e-this.y)*oa)}toString(){return`${this.z}/${this.x}/${this.y}`}}class uh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=dh(t,e.z,e.z,e.x,e.y)}}class ph{constructor(t,e,i,r,s){this.overscaledZ=t,this.wrap=e,this.canonical=new hh(i,+r,+s),this.key=dh(e,t,i,r,s)}clone(){return new ph(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){const e=this.canonical.z-t;return t>this.canonical.z?new ph(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ph(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){const i=this.canonical.z-t;return t>this.canonical.z?dh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):dh(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new ph(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new ph(e,this.wrap,e,i,r),new ph(e,this.wrap,e,i+1,r),new ph(e,this.wrap,e,i,r+1),new ph(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new ph(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new ph(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new uh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new sh(t.x-this.wrap,t.y))}}function dh(t,e,i,r,s){(t*=2)<0&&(t=-1*t-1);const n=1<<i;return(n*n*t+n*s+r).toString(36)+i.toString(36)+e.toString(36)}Fr("CanonicalTileID",hh),Fr("OverscaledTileID",ph,{omit:["posMatrix"]}),Fr("DEMData",class{constructor(t,e,i){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void v(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const r=this.dim=e.height-2;this.data=new Uint32Array(e.data.buffer),this.encoding=i||"mapbox";for(let t=0;t<r;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(r,t)]=this.data[this._idx(r-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,r)]=this.data[this._idx(t,r-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(r,-1)]=this.data[this._idx(r-1,0)],this.data[this._idx(-1,r)]=this.data[this._idx(0,r-1)],this.data[this._idx(r,r)]=this.data[this._idx(r-1,r-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<r;t++)for(let e=0;e<r;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(i[r],i[r+1],i[r+2])}getUnpackVector(){return"terrarium"===this.encoding?[256,1,1/256,32768]:[6553.6,25.6,.1,1e4]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}getPixels(){return new ro({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,s=e*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=s-1;break;case 1:s=r+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const o=-e*this.dim,l=-i*this.dim;for(let e=n;e<a;e++)for(let i=r;i<s;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+o,e+l)]}});class mh extends oh{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=u({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(t,e){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function r(i,r){i&&(t.state="errored",e(i)),r&&(t.dem=r,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",e(null))}t.request=at(this.map._requestManager.transformRequest(i,H.Tile),function(i,s){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData(s),delete s.cacheControl,delete s.expires;const e=C(s)&&(null==lh&&(lh="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),lh)?s:P.getImageData(s,1),i={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:e,encoding:this.encoding};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",i,r.bind(this)))}}.bind(this)),t.neighboringTiles=this._getNeighboringTiles(t.tileID)}_getNeighboringTiles(t){const e=t.canonical,i=Math.pow(2,e.z),r=(e.x-1+i)%i,s=0===e.x?t.wrap-1:t.wrap,n=(e.x+1+i)%i,a=e.x+1===i?t.wrap+1:t.wrap,o={};return o[new ph(t.overscaledZ,s,e.z,r,e.y).key]={backfilled:!1},o[new ph(t.overscaledZ,a,e.z,n,e.y).key]={backfilled:!1},e.y>0&&(o[new ph(t.overscaledZ,s,e.z,r,e.y-1).key]={backfilled:!1},o[new ph(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},o[new ph(t.overscaledZ,a,e.z,n,e.y-1).key]={backfilled:!1}),e.y+1<i&&(o[new ph(t.overscaledZ,s,e.z,r,e.y+1).key]={backfilled:!1},o[new ph(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},o[new ph(t.overscaledZ,a,e.z,n,e.y+1).key]={backfilled:!1}),o}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&t.actor.send("removeDEMTile",{uid:t.uid,source:this.id})}}class fh extends dt{constructor(t,e,i,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=i.getActor(),this.setEventedParent(r),this._data=e.data,this._options=u({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const s=oa/this.tileSize;this.workerOptions=u({source:this.id,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(void 0!==e.buffer?e.buffer:128)*s,tolerance:(void 0!==e.tolerance?e.tolerance:.375)*s,extent:oa,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:void 0!==e.clusterMaxZoom?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:oa,radius:(e.clusterRadius||50)*s,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}load(){this._updateWorkerData("metadata")}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData("content"),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(t){const e=u({},this.workerOptions),i=this._data;"string"==typeof i?(e.request=this.map._requestManager.transformRequest(P.resolveURL(i),H.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(i),this._pendingLoads++,this.fire(new ut("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,e,((e,i)=>{if(this._pendingLoads--,this._removed||i&&i.abandoned)return void this.fire(new ut("dataabort",{dataType:"source",sourceDataType:t}));let r=null;if(i&&i.resourceTiming&&i.resourceTiming[this.id]&&(r=i.resourceTiming[this.id].slice(0)),e)return void this.fire(new pt(e));const s={dataType:"source",sourceDataType:t};this._collectResourceTiming&&r&&r.length>0&&u(s,{resourceTiming:r}),this.fire(new ut("data",s))}))}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";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.request=this.actor.send(i,r,((r,s)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(s,this.map.painter,"reloadTile"===i),e(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return u({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var _h=Cs([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class gh extends dt{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t,e){this._loaded=!1,this.fire(new ut("dataloading",{dataType:"source"})),this.url=this.options.url,at(this.map._requestManager.transformRequest(this.url,H.Image),((i,r)=>{this._loaded=!0,i?this.fire(new pt(i)):r&&(this.image=r,t&&(this.coordinates=t),e&&e(),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new ut("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}setCoordinates(t){this.coordinates=t;const e=t.map(sh.fromLngLat);this.tileID=function(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);const n=Math.max(r-e,s-i),a=Math.max(0,Math.floor(-Math.log(n)/Math.LN2)),o=Math.pow(2,a);return new hh(a,Math.floor((e+r)/2*o),Math.floor((i+s)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;const i=e.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new un,this._boundsArray.emplaceBack(i[0].x,i[0].y,0,0),this._boundsArray.emplaceBack(i[1].x,i[1].y,oa,0),this._boundsArray.emplaceBack(i[3].x,i[3].y,0,oa),this._boundsArray.emplaceBack(i[2].x,i[2].y,oa,oa),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new ut("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,_h.members)),this.boundsSegments||(this.boundsSegments=Pn.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Bc(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class yh extends gh{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,H.Source).url);!function(t,e){const i=window.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=window.document.createElement("source");it(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}}(this.urls,((t,e)=>{this._loaded=!0,t?this.fire(new pt(t)):e&&(this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new pt(new ft(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.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,e=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,_h.members)),this.boundsSegments||(this.boundsSegments=Pn.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new Bc(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class xh extends gh{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?Array.isArray(e.coordinates)&&4===e.coordinates.length&&!e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new pt(new ft(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new pt(new ft(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new pt(new ft(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"==typeof e.canvas||e.canvas instanceof HTMLCanvasElement||this.fire(new pt(new ft(`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 pt(new ft(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}load(){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 pt(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 e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,_h.members)),this.boundsSegments||(this.boundsSegments=Pn.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Bc(e,this.canvas,i.RGBA,{premultiply:!0});for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}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 vh={vector:ah,raster:oh,"raster-dem":mh,geojson:fh,video:yh,image:gh,canvas:xh};function bh(t,e){const i=Da();return Fa(i,i,[1,1,0]),Oa(i,i,[.5*t.width,.5*t.height,1]),Ra(i,i,t.calculatePosMatrix(e.toUnwrapped()))}function wh(t,e,i,r,s,n){const a=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(s&&s.layers,e,t.id),o=n.maxPitchScaleFactor(),l=t.tilesIn(r,o,a);l.sort(Th);const c=[];for(const r of l)c.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,s,n,o,bh(t.transform,r.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,s=r.wrappedTileID,n=i[s]=i[s]||{};for(const i in t){const r=t[i],s=n[i]=n[i]||{},a=e[i]=e[i]||[];for(const t of r)s[t.featureIndex]||(s[t.featureIndex]=!0,a.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function Th(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class Ih{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}class Sh{constructor(t,e,i,r,s){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=s}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}}function Ah(t,e,i,r,s){return _(t,((t,n)=>{const a=e instanceof gs?e.get(n):null;return a&&a.evaluate?a.evaluate(i,r,s):a}))}function zh(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return{minX:e,minY:i,maxX:r,maxY:s}}function Eh(t,e){return e-t}Fr("FeatureIndex",class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Br(oa,16,0),this.grid3D=new Br(oa,16,0),this.featureIndexArray=new cn,this.promoteId=e}insert(t,e,i,r,s,n){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,s);const o=n?this.grid3D:this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<oa&&r[1]<oa&&r[2]>=0&&r[3]>=0&&o.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ko.VectorTile(new Rl(this.rawTileData)).layers,this.sourceLayerCoder=new Ih(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const s=t.params||{},n=oa/t.tileSize/t.scale,a=nr(s.filter),o=t.queryGeometry,l=t.queryPadding*n,c=zh(o),h=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),u=zh(t.cameraQueryGeometry),p=this.grid3D.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l,((e,i,r,s)=>function(t,e,i,r,s){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&s>=n.y)return!0;const n=[new k(e,i),new k(e,s),new k(r,s),new k(r,i)];if(t.length>2)for(const e of n)if(Ta(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Ia(t[e],t[e+1],n))return!0;return!1}(t.cameraQueryGeometry,e-l,i-l,r+l,s+l)));for(const t of p)h.push(t);h.sort(Eh);const d={};let m;for(let l=0;l<h.length;l++){const c=h[l];if(c===m)continue;m=c;const u=this.featureIndexArray.get(c);let p=null;this.loadMatchingFeature(d,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,a,s.layers,s.availableImages,e,i,r,((e,i,r)=>(p||(p=ha(e)),i.queryIntersectsFeature(o,e,r,p,this.z,t.transform,n,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,i,r,s,n,a,o,l,c,h){const p=this.bucketLayerIDs[e];if(n&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(n,p))return;const d=this.sourceLayerCoder.decode(i),m=this.vtLayers[d].feature(r);if(s.needGeometry){const t=ua(m,!0);if(!s.filter(new cs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new cs(this.tileID.overscaledZ),m))return;const f=this.getId(m,d);for(let e=0;e<p.length;e++){const i=p[e];if(n&&n.indexOf(i)<0)continue;const s=o[i];if(!s)continue;let d={};f&&c&&(d=c.getState(s.sourceLayer||"_geojsonTileLayer",f));const _=u({},l[i]);_.paint=Ah(_.paint,s.paint,m,d,a),_.layout=Ah(_.layout,s.layout,m,d,a);const g=!h||h(m,s,d);if(!g)continue;const y=new Sh(m,this.z,this.x,this.y,f);y.layer=_;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:r,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,s,n,a,o){const l={};this.loadVTLayers();const c=nr(s);for(const s of t)this.loadMatchingFeature(l,i,r,s,c,n,a,o,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}},{omit:["rawTileData","sourceLayerCoder"]});class Ch{constructor(t,e){this.tileID=t,this.uid=m(),this.uses=0,this.tileSize=e,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;e<P.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.textures.forEach((e=>t.saveTileTexture(e))),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(t,e,i){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ic){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ic&&e.hasRTLText){this.hasRTLText=!0,ls.isLoading()||ls.isLoaded()||"deferred"!==as()||os();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new tn}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Bc(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Bc(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,s,n,a,o,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:s,scale:n,tileSize:this.tileSize,pixelPosMatrix:c,transform:o,params:a,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),s=e?e.sourceLayer:"",n=r._geojsonTileLayer||r[s];if(!n)return;const a=nr(e&&e.filter),{z:o,x:l,y:c}=this.tileID.canonical,h={z:o,x:l,y:c};for(let e=0;e<n.length;e++){const r=n.feature(e);if(a.needGeometry){const t=ua(r,!0);if(!a.filter(new cs(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new cs(this.tileID.overscaledZ),r))continue;const u=i.getId(r,s),p=new Sh(r,o,l,c,u);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=I(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const i=this.latestFeatureIndex.loadVTLayers();for(const r in this.buckets){if(!e.style.hasLayer(r))continue;const s=this.buckets[r],n=s.layers[0].sourceLayer||"_geojsonTileLayer",a=i[n],o=t[n];if(!a||!o||0===Object.keys(o).length)continue;s.update(o,a,this.imageAtlas&&this.imageAtlas.patternPositions||{});const l=e&&e.style&&e.style.getLayer(r);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(s)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<P.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=P.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class Ph{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const s={value:e,timeout:void 0};if(void 0!==i&&(s.timeout=setTimeout((()=>{this.remove(t,s)}),i)),this.data[r].push(s),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][r];return this.data[i].splice(r,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class kh{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},u(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=u({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),u(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},u(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class Mh extends dt{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=function(t,e,i,r){const s=new vh[e.type](t,e,i,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return f(["load","abort","unload","serialize","prepare"],s),s}(t,e,i,this),this._tiles={},this._cache=new Ph(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new kh}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize: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;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,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,(()=>{})),this._source.fire(new ut("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 i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(Dh).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,s=new k(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),n=new k(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||n.y-s.y||n.x-s.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Dh).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)return t.state="errored",void(404!==r.status?this._source.fire(new pt(r,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=P.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new ut("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const s=e[r];if(t.neighboringTiles&&t.neighboringTiles[s]){const e=this.getTileByID(s);i(t,e),i(e,t)}}function i(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,s=Math.pow(2,t.tileID.canonical.z),n=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const s in this._tiles){let n=this._tiles[s];if(r[s]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(a=t)}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const e=Math.ceil(t.width/this._source.tileSize)+1,i=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*i*5),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t])}}update(t,e){if(this.transform=t,this.terrain=e,!this._sourceLoaded||this._paused)return;let i;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new ph(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=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:e}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[];const r=t.coveringZoomLevel(this._source),s=Math.max(r-Mh.maxOverzooming,this._source.minzoom),n=Math.max(r+Mh.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of i)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}i=i.concat(Object.values(t))}const a=this._updateRetainedTiles(i,r);if(Lh(this._source.type)){const t={},o={},l=Object.keys(a);for(const e of l){const i=a[e],r=this._tiles[e];if(!r||r.fadeEndTime&&r.fadeEndTime<=P.now())continue;const n=this.findLoadedParent(i,s);n&&(this._addTile(n.tileID),t[n.tileID.key]=n.tileID),o[e]=i}this._retainLoadedChildren(o,r,n,a);for(const e in t)a[e]||(this._coveredTiles[e]=!0,a[e]=t[e]);if(e){const t={},e={};for(const r of i)this._tiles[r.key].hasData()?t[r.key]=r:e[r.key]=r;for(const i in e){const r=e[i].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=a[r[0].key]=r[0],t[r[1].key]=a[r[1].key]=r[1],t[r[2].key]=a[r[2].key]=r[2],t[r[3].key]=a[r[3].key]=r[3],delete e[i])}for(const i in e){const r=this.findLoadedParent(e[i],this._source.minzoom);if(r){t[r.tileID.key]=a[r.tileID.key]=r.tileID;for(const e in t)t[e].isChildOf(r.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}for(const t in a)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,a);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){const i={},r={},s=Math.max(e-Mh.maxOverzooming,this._source.minzoom),n=Math.max(e+Mh.maxUnderzooming,this._source.minzoom),a={};for(const r of t){const t=this._addTile(r);i[r.key]=r,t.hasData()||e<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,e,n,i);for(const n of t){let t=this._tiles[n.key];if(t.hasData())continue;if(e+1>this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let e=n.overscaledZ-1;e>=s;--e){const s=n.scaledTo(e);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&a&&(t=this._addTile(s)),t&&(i[s.key]=s,a=t.wasRequested(),t.hasData()))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=e;return e||(e=new Ch(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))),e.uses++,this._tiles[t.key]=e,i||this._source.fire(new ut("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,e,i){const r=[],s=this.transform;if(!s)return r;const n=i?s.getCameraQueryGeometry(t):t,a=t.map((t=>s.pointCoordinate(t,this.terrain))),o=n.map((t=>s.pointCoordinate(t,this.terrain))),l=this.getIds();let c=1/0,h=1/0,u=-1/0,p=-1/0;for(const t of o)c=Math.min(c,t.x),h=Math.min(h,t.y),u=Math.max(u,t.x),p=Math.max(p,t.y);for(let t=0;t<l.length;t++){const i=this._tiles[l[t]];if(i.holdingForFade())continue;const n=i.tileID,d=Math.pow(2,s.zoom-i.tileID.overscaledZ),m=e*i.queryPadding*oa/i.tileSize/d,f=[n.getTilePoint(new sh(c,h)),n.getTilePoint(new sh(u,p))];if(f[0].x-m<oa&&f[0].y-m<oa&&f[1].x+m>=0&&f[1].y+m>=0){const t=a.map((t=>n.getTilePoint(t))),e=o.map((t=>n.getTilePoint(t)));r.push({tile:i,tileID:n,queryGeometry:t,cameraQueryGeometry:e,scale:d})}}return r}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(Lh(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=P.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function Dh(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Lh(t){return"raster"===t||"image"===t||"video"===t}Mh.maxOverzooming=10,Mh.maxUnderzooming=3;const Bh="mapboxgl_preloaded_worker_pool";class Rh{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Rh.workerCount;)this.workers.push(new Worker(vf.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Bh]}numActive(){return Object.keys(this.active).length}}const Fh=Math.floor(P.hardwareConcurrency/2);let Oh;function Vh(){return Oh||(Oh=new Rh),Oh}Rh.workerCount=Math.max(Math.min(Fh,6),1);const Uh=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Nh(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return Uh.forEach((t=>{t in e&&(i[t]=e[t])})),i}function $h(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Nh(t[i],e[t[i].ref]));return t}const qh={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight"};function jh(t,e,i){i.push({command:qh.addSource,args:[t,e[t]]})}function Zh(t,e,i){e.push({command:qh.removeSource,args:[t]}),i[t]=!0}function Gh(t,e,i,r){Zh(t,i,r),jh(t,e,i)}function Xh(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!n(t[i][r],e[i][r]))return!1;return!0}function Wh(t,e,i,r,s,a){let o;for(o in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,o)&&(n(t[o],e[o])||i.push({command:a,args:[r,o,e[o],s]}));for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(n(t[o],e[o])||i.push({command:a,args:[r,o,e[o],s]}))}function Hh(t){return t.id}function Kh(t,e){return t[e.id]=e,t}class Yh{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=l(t,0,1);let e=1,i=this._distances[e];const r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];const s=e-1,n=this._distances[s],a=i-n,o=a>0?(r-n)/a:0;return this.points[s].mult(1-o).add(this.points[e].mult(o))}}function Jh(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class Qh{constructor(t,e,i){const r=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,s,n){this.boxCells[s].push(n)}_insertCircleCell(t,e,i,r,s,n){this.circleCells[s].push(n)}_query(t,e,i,r,s,n,a){if(i<0||t>this.width||r<0||e>this.height)return[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)o.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];o.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,o,{hitTest:s,overlapMode:n,seenUids:{box:{},circle:{}}},a);return o}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,s,n){return this._query(t,e,i,r,!0,s,n).length>0}hitTestCircle(t,e,i,r,s){const n=t-i,a=t+i,o=e-i,l=e+i;if(a<0||n>this.width||l<0||o>this.height)return!1;const c=[];return this._forEachCell(n,o,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),c.length>0}_queryCell(t,e,i,r,s,n,a,o){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const s=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,p=this.boxKeys[a];if(t<=s[u+2]&&e<=s[u+3]&&i>=s[u+0]&&r>=s[u+1]&&(!o||o(p))&&(!c||!Jh(h,p.overlapMode))&&(n.push({key:p,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),c))return!0}}const p=this.circleCells[s];if(null!==p){const s=this.circles;for(const a of p)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,p=this.circleKeys[a];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,r)&&(!o||o(p))&&(!c||!Jh(h,p.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(n.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,s,n,a,o){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!o||o(r))&&!Jh(h,r.overlapMode))return n.push(!0),!0}}const p=this.circleCells[s];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!o||o(r))&&!Jh(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(s.call(this,t,e,i,r,this.xCellCount*l+p,n,a,o))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,i,r,s,n){const a=r-t,o=s-e,l=i+n;return l*l>a*a+o*o}_circleAndRectCollide(t,e,i,r,s,n,a){const o=(n-r)/2,l=Math.abs(t-(r+o));if(l>o+i)return!1;const c=(a-s)/2,h=Math.abs(e-(s+c));if(h>c+i)return!1;if(l<=o||h<=c)return!0;const u=l-o,p=h-c;return u*u+p*p<=i*i}}function tu(t,e,i,r,s){const n=Da();return e?(Oa(n,n,[1/s,1/s,1]),i||Va(n,n,r.angle)):Ra(n,r.labelPlaneMatrix,t),n}function eu(t,e,i,r,s){if(e){const e=(n=t,(a=new ka(16))[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],a[4]=n[4],a[5]=n[5],a[6]=n[6],a[7]=n[7],a[8]=n[8],a[9]=n[9],a[10]=n[10],a[11]=n[11],a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15],a);return Oa(e,e,[s,s,1]),i||Va(e,e,-r.angle),e}return r.glCoordMatrix;var n,a}function iu(t,e,i){let r;i?(r=[t.x,t.y,i(t.x,t.y),1],Xa(r,r,e)):(r=[t.x,t.y,0,1],du(r,r,e));const s=r[3];return{point:new k(r[0]/s,r[1]/s),signedDistanceFromCamera:s}}function ru(t,e){return.5+t/e*.5}function su(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function nu(t,e,i,r,s,n,a,o,l,c){const h=r?t.textSizeData:t.iconSizeData,u=dc(h,i.transform.zoom),p=[256/i.width*2+1,256/i.height*2+1],d=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;d.clear();const m=t.lineVertexArray,f=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,_=i.transform.width/i.transform.height;let g=!1;for(let r=0;r<f.length;r++){const y=f.get(r);if(y.hidden||y.writingMode===Ul.vertical&&!g){pu(y.numGlyphs,d);continue}let x;if(g=!1,c?(x=[y.anchorX,y.anchorY,c(y.anchorX,y.anchorY),1],Xa(x,x,e)):(x=[y.anchorX,y.anchorY,0,1],du(x,x,e)),!su(x,p)){pu(y.numGlyphs,d);continue}const v=ru(i.transform.cameraToCenterDistance,x[3]),b=pc(h,u,y),w=a?b/v:b*v,T=new k(y.anchorX,y.anchorY),I=iu(T,s,c).point,S={},A=lu(y,w,!1,o,e,s,n,t.glyphOffsetArray,m,d,I,T,S,_,l,c);g=A.useVertical,(A.notEnoughRoom||g||A.needsFlipping&&lu(y,w,!0,o,e,s,n,t.glyphOffsetArray,m,d,I,T,S,_,l,c).notEnoughRoom)&&pu(y.numGlyphs,d)}r?t.text.dynamicLayoutVertexBuffer.updateData(d):t.icon.dynamicLayoutVertexBuffer.updateData(d)}function au(t,e,i,r,s,n,a,o,l,c,h,u,p){const d=o.glyphStartIndex+o.numGlyphs,m=o.lineStartIndex,f=o.lineStartIndex+o.lineLength,_=e.getoffsetX(o.glyphStartIndex),g=e.getoffsetX(d-1),y=hu(t*_,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);if(!y)return null;const x=hu(t*g,i,r,s,n,a,o.segment,m,f,l,c,h,u,p);return x?{first:y,last:x}:null}function ou(t,e,i,r){return t===Ul.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:(t===Ul.vertical?e.y<i.y:e.x>i.x)?{needsFlipping:!0}:null}function lu(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f){const _=e/24,g=t.lineOffsetX*_,y=t.lineOffsetY*_;let x;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,s=t.lineStartIndex,c=t.lineStartIndex+t.lineLength,v=au(_,o,g,y,i,h,u,t,l,n,p,m,f);if(!v)return{notEnoughRoom:!0};const b=iu(v.first.point,a,f).point,w=iu(v.last.point,a,f).point;if(r&&!i){const e=ou(t.writingMode,b,w,d);if(e)return e}x=[v.first];for(let r=t.glyphStartIndex+1;r<e-1;r++)x.push(hu(_*o.getoffsetX(r),g,y,i,h,u,t.segment,s,c,l,n,p,m,f));x.push(v.last)}else{if(r&&!i){const e=iu(u,s,f).point,i=t.lineStartIndex+t.segment+1,r=new k(l.getx(i),l.gety(i)),n=iu(r,s,f),a=n.signedDistanceFromCamera>0?n.point:cu(u,r,e,1,s,f),o=ou(t.writingMode,e,a,d);if(o)return o}const e=hu(_*o.getoffsetX(t.glyphStartIndex),g,y,i,h,u,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,l,n,p,m,f);if(!e)return{notEnoughRoom:!0};x=[e]}for(const t of x)vc(c,t.point,t.angle);return{}}function cu(t,e,i,r,s,n){const a=iu(t.add(t.sub(e)._unit()),s,n).point,o=i.sub(a);return i.add(o._mult(r/o.mag()))}function hu(t,e,i,r,s,n,a,o,l,c,h,u,p,d){const m=r?t-e:t+e;let f=m>0?1:-1,_=0;r&&(f*=-1,_=Math.PI),f<0&&(_+=Math.PI);let g=f>0?o+a:o+a+1,y=s,x=s,v=0,b=0;const w=Math.abs(m),T=[];for(;v+b<=w;){if(g+=f,g<o||g>=l)return null;if(x=y,T.push(y),y=u[g],void 0===y){const t=new k(c.getx(g),c.gety(g)),e=iu(t,h,d);if(e.signedDistanceFromCamera>0)y=u[g]=e.point;else{const e=g-f;y=cu(0===v?n:new k(c.getx(e),c.gety(e)),t,x,w-v+1,h,d)}}v+=b,b=x.dist(y)}const I=(w-v)/b,S=y.sub(x),A=S.mult(I)._add(x);A._add(S._unit()._perp()._mult(i*f));const z=_+Math.atan2(y.y-x.y,y.x-x.x);return T.push(A),{point:A,angle:p?z:0,path:T}}const uu=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function pu(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(uu,3*t)}}function du(t,e,i){const r=e[0],s=e[1];return t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t[3]=i[3]*r+i[7]*s+i[15],t}const mu=100;class fu{constructor(t,e=new Qh(t.width+200,t.height+200,25),i=new Qh(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+mu,this.screenBottomBoundary=t.height+mu,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,s,n){const a=this.projectAndGetPerspectiveRatio(r,t.anchorPointX,t.anchorPointY,n),o=i*a.perspectiveRatio,l=t.x1*o+a.point.x,c=t.y1*o+a.point.y,h=t.x2*o+a.point.x,u=t.y2*o+a.point.y;return!this.isInsideGrid(l,c,h,u)||"always"!==e&&this.grid.hitTest(l,c,h,u,e,s)||a.perspectiveRatio<this.perspectiveRatioCutoff?{box:[],offscreen:!1}:{box:[l,c,h,u],offscreen:this.isOffscreen(l,c,h,u)}}placeCollisionCircles(t,e,i,r,s,n,a,o,l,c,h,u,p,d){const m=[],f=new k(e.anchorX,e.anchorY),_=iu(f,n,d),g=ru(this.transform.cameraToCenterDistance,_.signedDistanceFromCamera),y=(c?s/g:s*g)/24,x=iu(f,a,d).point,v=au(y,r,e.lineOffsetX*y,e.lineOffsetY*y,!1,x,f,e,i,a,{},!1,d);let b=!1,w=!1,T=!0;if(v){const e=.5*u*g+p,i=new k(-100,-100),r=new k(this.screenRightBoundary,this.screenBottomBoundary),s=new Yh,n=v.first,a=v.last;let c=[];for(let t=n.path.length-1;t>=1;t--)c.push(n.path[t]);for(let t=1;t<a.path.length;t++)c.push(a.path[t]);const f=2.5*e;if(o){const t=c.map((t=>iu(t,o,d)));c=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(c.length>0){const t=c[0].clone(),e=c[0].clone();for(let i=1;i<c.length;i++)t.x=Math.min(t.x,c[i].x),t.y=Math.min(t.y,c[i].y),e.x=Math.max(e.x,c[i].x),e.y=Math.max(e.y,c[i].y);_=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[c]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:function(t,e,i,r,s){const n=[];for(let a=0;a<t.length;a++){const o=t[a];let l;for(let t=0;t<o.length-1;t++){let a=o[t],c=o[t+1];a.x<e&&c.x<e||(a.x<e?a=new k(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x<e&&(c=new k(e,a.y+(e-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y<i&&c.y<i||(a.y<i?a=new k(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y<i&&(c=new k(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),a.x>=r&&c.x>=r||(a.x>=r?a=new k(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=r&&(c=new k(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=s&&c.y>=s||(a.y>=s?a=new k(a.x+(s-a.y)/(c.y-a.y)*(c.x-a.x),s)._round():c.y>=s&&(c=new k(a.x+(s-a.y)/(c.y-a.y)*(c.x-a.x),s)._round()),l&&a.equals(l[l.length-1])||(l=[a],n.push(l)),l.push(c)))))}}return n}([c],i.x,i.y,r.x,r.y)}for(const i of _){s.reset(i,.25*e);let r=0;r=s.length<=.5*e?1:Math.ceil(s.paddedLength/f)+1;for(let i=0;i<r;i++){const n=i/Math.max(r-1,1),a=s.lerp(n),o=a.x+mu,c=a.y+mu;m.push(o,c,e,0);const u=o-e,p=c-e,d=o+e,f=c+e;if(T=T&&this.isOffscreen(u,p,d,f),w=w||this.isInsideGrid(u,p,d,f),"always"!==t&&this.grid.hitTestCircle(o,c,e,t,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||g<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const e=[];let i=1/0,r=1/0,s=-1/0,n=-1/0;for(const a of t){const t=new k(a.x+mu,a.y+mu);i=Math.min(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.x),n=Math.max(n,t.y),e.push(t)}const a=this.grid.query(i,r,s,n).concat(this.ignoredGrid.query(i,r,s,n)),o={},l={};for(const t of a){const i=t.key;void 0===o[i.bucketInstanceId]&&(o[i.bucketInstanceId]={}),o[i.bucketInstanceId][i.featureIndex]||ma(e,[new k(t.x1,t.y1),new k(t.x2,t.y1),new k(t.x2,t.y2),new k(t.x1,t.y2)])&&(o[i.bucketInstanceId][i.featureIndex]=!0,void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]=[]),l[i.bucketInstanceId].push(i.featureIndex))}return l}insertCollisionBox(t,e,i,r,s,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,s,n){const a=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e};for(let e=0;e<t.length;e+=4)a.insertCircle(o,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r){let s;return r?(s=[e,i,r(e,i),1],Xa(s,s,t)):(s=[e,i,0,1],du(s,s,t)),{point:new k((s[0]/s[3]+1)/2*this.transform.width+mu,(-s[1]/s[3]+1)/2*this.transform.height+mu),perspectiveRatio:.5+this.transform.cameraToCenterDistance/s[3]*.5}}isOffscreen(t,e,i,r){return i<mu||t>=this.screenRightBoundary||r<mu||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=La([]);return Fa(t,t,[-100,-100,0]),t}}function _u(t,e,i){return e*(oa/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}class gu{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class yu{constructor(t,e,i,r,s){this.text=new gu(t?t.text:null,e,i,s),this.icon=new gu(t?t.icon:null,e,r,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class xu{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class vu{constructor(){this.invProjMatrix=Da(),this.viewportMatrix=Da(),this.circles=[]}}class bu{constructor(t,e,i,r,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=s}}class wu{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 Tu(t,e,i,r,s){const{horizontalAlign:n,verticalAlign:a}=hc(t),o=-(n-.5)*e,l=-(a-.5)*i,c=_c(t,r);return new k(o+c[0]*s,l+c[1]*s)}function Iu(t,e,i,r,s,n){const{x1:a,x2:o,y1:l,y2:c,anchorPointX:h,anchorPointY:u}=t,p=new k(e,i);return r&&p._rotate(s?n:-n),{x1:a+p.x,y1:l+p.y,x2:o+p.x,y2:c+p.y,anchorPointX:h,anchorPointY:u}}class Su{constructor(t,e,i,r,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new fu(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new wu(r),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,e,i,r){const s=i.getBucket(e),n=i.latestFeatureIndex;if(!s||!n||e.id!==s.layerIds[0])return;const a=i.collisionBoxArray,o=s.layers[0].layout,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/oa,h=this.transform.calculatePosMatrix(i.tileID.toUnwrapped()),u="map"===o.get("text-pitch-alignment"),p="map"===o.get("text-rotation-alignment"),d=_u(i,1,this.transform.zoom),m=tu(h,u,p,this.transform,d);let f=null;if(u){const t=eu(h,u,p,this.transform,d);f=Ra([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[s.bucketInstanceId]=new bu(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);const _={bucket:s,layout:o,posMatrix:h,textLabelPlaneMatrix:m,labelToScreenMatrix:f,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:dc(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s,parameters:_})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:_})}attemptAnchorPlacement(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f){const _=[u.textOffset0,u.textOffset1],g=Tu(t,i,r,_,s),y=this.collisionIndex.placeCollisionBox(Iu(e,g.x,g.y,n,a,this.transform.angle),h,o,l,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(Iu(m,g.x,g.y,n,a,this.transform.angle),h,o,l,c.predicate,f).box.length)&&y.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:_,width:i,height:r,anchor:t,textBoxScale:s,prevAnchor:e},this.markUsedJustification(p,t,u,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,u),this.placedOrientations[u.crossTileID]=d),{shift:g,placedGlyphBoxes:y}}}placeLayerBucketPart(t,e,i){const{bucket:r,layout:s,posMatrix:n,textLabelPlaneMatrix:a,labelToScreenMatrix:o,textPixelRatio:l,holdingForFade:c,collisionBoxArray:h,partiallyEvaluatedTextSize:u,collisionGroup:p}=t.parameters,d=s.get("text-optional"),m=s.get("icon-optional"),f=Cc(s,"text-overlap","text-allow-overlap"),_="always"===f,g=Cc(s,"icon-overlap","icon-allow-overlap"),y="always"===g,x="map"===s.get("text-rotation-alignment"),v="map"===s.get("text-pitch-alignment"),b="none"!==s.get("icon-text-fit"),w="viewport-y"===s.get("symbol-z-order"),T=_&&(y||!r.hasIconData()||m),I=y&&(_||!r.hasTextData()||d);!r.collisionArrays&&h&&r.deserializeCollisionBoxes(h);const S=(t,h)=>{if(e[t.crossTileID])return;if(c)return void(this.placements[t.crossTileID]=new xu(!1,!1,!1));let y=!1,w=!1,S=!0,A=null,z={box:null,offscreen:null},E={box:null,offscreen:null},C=null,P=null,k=null,M=0,D=0,L=0;h.textFeatureIndex?M=h.textFeatureIndex:t.useRuntimeCollisionCircles&&(M=t.featureIndex),h.verticalTextFeatureIndex&&(D=h.verticalTextFeatureIndex);const B=this.retainedQueryData[r.bucketInstanceId].tileID,R=this.terrain?(t,e)=>this.terrain.getElevation(B,t,e):null;for(const t of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const e=h[t];e&&(e.elevation=R?R(e.anchorPointX,e.anchorPointY):0)}const F=h.textBox;if(F){const e=e=>{let i=Ul.horizontal;if(r.allowVerticalPlacement&&!e&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(r,i,t))}return i},i=(e,i)=>{if(r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&h.verticalTextBox){for(const t of r.writingModes)if(t===Ul.vertical?(z=i(),E=z):z=e(),z&&z.box&&z.box.length)break}else z=e()};if(s.get("text-variable-anchor")){let a=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];a.indexOf(e.anchor)>0&&(a=a.filter((t=>t!==e.anchor)),a.unshift(e.anchor))}const o=(e,i,s)=>{const o=e.x2-e.x1,c=e.y2-e.y1,h=t.textBoxScale,u=b&&"never"===g?i:null;let d={box:[],offscreen:!1};const m="never"!==f?2*a.length:a.length;for(let i=0;i<m;++i){const m=this.attemptAnchorPlacement(a[i%a.length],e,o,c,h,x,v,l,n,p,i>=a.length?f:"never",t,r,s,u,R);if(m&&(d=m.placedGlyphBoxes,d&&d.box&&d.box.length)){y=!0,A=m.shift;break}}return d};i((()=>o(F,h.iconBox,Ul.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&!(z&&z.box&&z.box.length)&&t.numVerticalGlyphVertices>0&&e?o(e,h.verticalIconBox,Ul.vertical):{box:null,offscreen:null}})),z&&(y=z.box,S=z.offscreen);const c=e(z&&z.box);if(!y&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(r,e.anchor,t,c))}}else{const s=(e,i)=>{const s=this.collisionIndex.placeCollisionBox(e,f,l,n,p.predicate,R);return s&&s.box&&s.box.length&&(this.markUsedOrientation(r,i,t),this.placedOrientations[t.crossTileID]=i),s};i((()=>s(F,Ul.horizontal)),(()=>{const e=h.verticalTextBox;return r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?s(e,Ul.vertical):{box:null,offscreen:null}})),e(z&&z.box&&z.box.length)}}if(C=z,y=C&&C.box&&C.box.length>0,S=C&&C.offscreen,t.useRuntimeCollisionCircles){const e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),l=pc(r.textSizeData,u,e),c=s.get("text-padding");P=this.collisionIndex.placeCollisionCircles(f,e,r.lineVertexArray,r.glyphOffsetArray,l,n,a,o,i,v,p.predicate,t.collisionCircleDiameter,c,R),y=_||P.circles.length>0&&!P.collisionDetected,S=S&&P.offscreen}if(h.iconFeatureIndex&&(L=h.iconFeatureIndex),h.iconBox){const t=t=>{const e=b&&A?Iu(t,A.x,A.y,x,v,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,g,l,n,p.predicate,R)};E&&E.box&&E.box.length&&h.verticalIconBox?(k=t(h.verticalIconBox),w=k.box.length>0):(k=t(h.iconBox),w=k.box.length>0),S=S&&k.offscreen}const O=d||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,V=m||0===t.numIconVertices;if(O||V?V?O||(w=w&&y):y=w&&y:w=y=w&&y,y&&C&&C.box&&this.collisionIndex.insertCollisionBox(C.box,f,s.get("text-ignore-placement"),r.bucketInstanceId,E&&E.box&&D?D:M,p.ID),w&&k&&this.collisionIndex.insertCollisionBox(k.box,g,s.get("icon-ignore-placement"),r.bucketInstanceId,L,p.ID),P&&(y&&this.collisionIndex.insertCollisionCircles(P.circles,f,s.get("text-ignore-placement"),r.bucketInstanceId,M,p.ID),i)){const t=r.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new vu);for(let t=0;t<P.circles.length;t+=4)e.circles.push(P.circles[t+0]),e.circles.push(P.circles[t+1]),e.circles.push(P.circles[t+2]),e.circles.push(P.collisionDetected?1:0)}this.placements[t.crossTileID]=new xu(y||T,w||I,S||r.justReloaded),e[t.crossTileID]=!0};if(w){const t=r.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];S(r.symbolInstances.get(i),r.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)S(r.symbolInstances.get(e),r.collisionArrays[e]);if(i&&r.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[r.bucketInstanceId];Ba(t.invProjMatrix,n),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}r.justReloaded=!1}markUsedJustification(t,e,i,r){let s;s=r===Ul.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(e)];const n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const e of n)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:i.crossTileID)}markUsedOrientation(t,e,i){const r=e===Ul.horizontal||e===Ul.horizontalOnly?e:0,s=e===Ul.vertical?e:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of n)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=s)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},n=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=s[t];n?(this.opacities[t]=new yu(n,r,e.text,e.icon),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new yu(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new yu(e,r,!1,!1);s.isHidden()||(this.opacities[t]=s,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in a)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=a[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,s=new yu(null,0,!1,!1,!0),n=r.get("text-allow-overlap"),a=r.get("icon-allow-overlap"),o=r.get("text-variable-anchor"),l="map"===r.get("text-rotation-alignment"),c="map"===r.get("text-pitch-alignment"),h="none"!==r.get("icon-text-fit"),u=new yu(null,0,n&&(a||!t.hasIconData()||r.get("icon-optional")),a&&(n||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const p=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};for(let i=0;i<t.symbolInstances.length;i++){const r=t.symbolInstances.get(i),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:a,crossTileID:d}=r;let m=this.opacities[d];e[d]?m=s:m||(m=u,this.opacities[d]=m),e[d]=!0;const f=r.numIconVertices>0,_=this.placedOrientations[r.crossTileID],g=_===Ul.vertical,y=_===Ul.horizontal||_===Ul.horizontalOnly;if(n>0||a>0){const e=Lu(m.text);p(t.text,n,g?Bu:e),p(t.text,a,y?Bu:e);const i=m.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||g?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||y?1:0);const s=this.variableOffsets[r.crossTileID];s&&this.markUsedJustification(t,s.anchor,r,_);const o=this.placedOrientations[r.crossTileID];o&&(this.markUsedJustification(t,"left",r,o),this.markUsedOrientation(t,o,r))}if(f){const e=Lu(m.icon),i=!(h&&r.verticalPlacedIconSymbolIndex&&g);r.placedIconSymbolIndex>=0&&(p(t.icon,r.numIconVertices,i?e:Bu),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=m.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(p(t.icon,r.numVerticalIconVertices,i?Bu:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=m.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const e=t.collisionArrays[i];if(e){let i=new k(0,0);if(e.textBox||e.verticalTextBox){let r=!0;if(o){const t=this.variableOffsets[d];t?(i=Tu(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),l&&i._rotate(c?this.transform.angle:-this.transform.angle)):r=!1}e.textBox&&Au(t.textCollisionBox.collisionVertexArray,m.text.placed,!r||g,i.x,i.y),e.verticalTextBox&&Au(t.textCollisionBox.collisionVertexArray,m.text.placed,!r||y,i.x,i.y)}const r=Boolean(!y&&e.verticalIconBox);e.iconBox&&Au(t.iconCollisionBox.collisionVertexArray,m.icon.placed,r,h?i.x:0,h?i.y:0),e.verticalIconBox&&Au(t.iconCollisionBox.collisionVertexArray,m.icon.placed,!r,h?i.x:0,h?i.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.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.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function Au(t,e,i,r,s){t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0),t.emplaceBack(e?1:0,i?1:0,r||0,s||0)}const zu=Math.pow(2,25),Eu=Math.pow(2,24),Cu=Math.pow(2,17),Pu=Math.pow(2,16),ku=Math.pow(2,9),Mu=Math.pow(2,8),Du=Math.pow(2,1);function Lu(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*zu+e*Eu+i*Cu+e*Pu+i*ku+e*Mu+i*Du+e}const Bu=0;class Ru{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,i,r,s){const n=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(n,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<n.length;)if(e.placeLayerBucketPart(n[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,s())return!0;return!1}}class Fu{constructor(t,e,i,r,s,n,a,o){this.placement=new Su(t,e,n,a,o),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=P.now(),s=()=>{const t=P.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Ru(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}class Ou{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),s=r.key;this.indexedSymbolInstances[s]||(this.indexedSymbolInstances[s]=[]),this.indexedSymbolInstances[s].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(t,e){const i=.03125/Math.pow(2,e.canonical.z-this.tileID.canonical.z);return{x:Math.floor((e.canonical.x*oa+t.anchorX)*i),y:Math.floor((e.canonical.y*oa+t.anchorY)*i)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let s=0;s<t.length;s++){const n=t.get(s);if(n.crossTileID)continue;const a=this.indexedSymbolInstances[n.key];if(!a)continue;const o=this.getScaledCoordinates(n,e);for(const t of a)if(Math.abs(t.coord.x-o.x)<=r&&Math.abs(t.coord.y-o.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,n.crossTileID=t.crossTileID;break}}}}class Vu{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Uu{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 i=this.indexes[t],r={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),r[s.tileID.key]=s}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){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;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const s=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in s){const n=s[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=s[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const s=e.symbolInstances.get(t);s.crossTileID||(s.crossTileID=i.generate(),r[s.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ou(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const s in r)t[r[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[s]),delete r[s],e=!0)}return e}}class Nu{constructor(){this.layerIndexes={},this.crossTileIDs=new Vu,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Uu);let s=!1;const n={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),n[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(s=!0),s}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var $u=Cs([{name:"a_pos",type:"Int16",components:2}]);class qu extends dt{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=t._cache.max,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const t in this._tiles){const e=this._tiles[t];e.textures.forEach((t=>t.destroy())),e.textures=[]}}update(t,e){this.sourceCache.update(t,e),this._renderableTilesKeys=[];for(const i of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e}))this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.posMatrix=new Float64Array(16),Ua(i.posMatrix,0,oa,0,oa,0,1),this._tiles[i.key]=new Ch(i,this.tileSize))}removeOutdated(t){const e={};this.renderHistory=this.renderHistory.filter(((t,e)=>this.renderHistory.indexOf(t)===e)).slice(0,this.renderHistorySize);for(const t of this._renderableTilesKeys)e[t]=!0;for(const t of this.renderHistory)e[t]=!0;for(const i in this._tiles)e[i]||(this._tiles[i].clearTextures(t),delete this._tiles[i])}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const e={};for(const i of this._renderableTilesKeys){const r=this._tiles[i].tileID;if(r.canonical.equals(t.canonical)){const r=t.clone();r.posMatrix=new Float64Array(16),Ua(r.posMatrix,0,oa,0,oa,0,1),e[i]=r}else if(r.canonical.isChildOf(t.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=r.canonical.z-t.canonical.z,a=r.canonical.x-(r.canonical.x>>n<<n),o=r.canonical.y-(r.canonical.y>>n<<n),l=oa>>n;Ua(s.posMatrix,0,l,0,l,0,1),Fa(s.posMatrix,s.posMatrix,[-a*l,-o*l,0]),e[i]=s}else if(t.canonical.isChildOf(r.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16);const n=t.canonical.z-r.canonical.z,a=t.canonical.x-(t.canonical.x>>n<<n),o=t.canonical.y-(t.canonical.y>>n<<n),l=oa>>n;Ua(s.posMatrix,0,oa,0,oa,0,1),Fa(s.posMatrix,s.posMatrix,[a*l,o*l,0]),Oa(s.posMatrix,s.posMatrix,[1/2**n,1/2**n,0]),e[i]=s}}return e}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let s=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!s||!s.dem)&&e)for(;r>=i.minzoom&&(!s||!s.dem);)s=this.sourceCache.getTileByID(t.scaledTo(r--).key);return s}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeLoaded>=t))}}class ju{constructor(t,e,i){this.style=t,this.sourceCache=new qu(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.elevationOffset="number"==typeof i.elevationOffset?i.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(t,e,i,r=8192){if(!(e>=0&&e<r&&i>=0&&i<r))return this.elevationOffset;let s=0;const n=this.getTerrainData(t);if(n.tile&&n.tile.dem){const t=function(t,e,i){var r=e[0],s=e[1];return t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t}([],[e/r*oa,i/r*oa],n.u_terrain_matrix),a=[t[0]*n.tile.dem.dim,t[1]*n.tile.dem.dim],o=[Math.floor(a[0]),Math.floor(a[1])],l=n.tile.dem.get(o[0],o[1]),c=n.tile.dem.get(o[0],o[1]+1),h=n.tile.dem.get(o[0]+1,o[1]),u=n.tile.dem.get(o[0]+1,o[1]+1);s=Re(Re(l,c,a[0]-o[0]),Re(h,u,a[0]-o[0]),a[1]-o[1])}return s}rememberForRerender(t,e){for(const i in this.sourceCache._tiles){const r=this.sourceCache._tiles[i];(r.tileID.equals(e)||r.tileID.isChildOf(e))&&(t===this.sourceCache.sourceCache.id&&(r.timeLoaded=Date.now()),this._rerender[t]=this._rerender[t]||{},this._rerender[t][r.tileID.key]=!0)}}needsRerender(t,e){return this._rerender[t]&&this._rerender[t][e.key]}clearRerenderCache(){this._rerender={}}getElevation(t,e,i,r=8192){return(this.getDEMElevation(t,e,i,r)+this.elevationOffset)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const t=this.style.map.painter.context,e=new ro({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Bc(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Bc(t,new ro({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=La([])}const e=this.sourceCache.getSourceTile(t,!0);if(e&&e.dem&&(!e.demTexture||e.needsTerrainPrepare)){const t=this.style.map.painter.context;e.demTexture=this.style.map.painter.getTileTexture(e.dem.stride),e.demTexture?e.demTexture.update(e.dem.getPixels(),{premultiply:!1}):e.demTexture=new Bc(t,e.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),e.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),e.needsTerrainPrepare=!1}const i=e&&e+e.tileID.key+t.key;if(i&&!this._demMatrixCache[i]){const i=this.sourceCache.sourceCache._source.maxzoom;let n=t.canonical.z-e.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=i?n=t.canonical.z-i:v("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=t.canonical.x-(t.canonical.x>>n<<n),o=t.canonical.y-(t.canonical.y>>n<<n),l=((r=new Float64Array(16))[0]=(s=[1/(oa<<n),1/(oa<<n),0])[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=s[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=s[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r);Fa(l,l,[a*oa,o*oa,0]),this._demMatrixCache[t.key]={matrix:l,coord:t}}var r,s;return{u_depth:2,u_terrain:3,u_terrain_dim:e&&e.dem&&e.dem.dim||1,u_terrain_matrix:i?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:e&&e.dem&&e.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_offset:this.elevationOffset,u_terrain_exaggeration:this.exaggeration,texture:(e&&e.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:e}}getRTTFramebuffer(){const t=this.style.map.painter;if(!this._rttFramebuffer){const e=this.sourceCache.tileSize*this.qualityFactor;this._rttFramebuffer=t.context.createFramebuffer(e,e,!0),this._rttFramebuffer.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,e,e))}return this._rttFramebuffer}getFramebuffer(t){const e=this.style.map.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Bc(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Bc(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.style.map.painter.context;if(this._coordsTexture)return this._coordsTexture;const e=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,i=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,i+=4)e[i+0]=255&r,e[i+1]=255&t,e[i+2]=r>>8<<4|t>>8,e[i+3]=0;const i=new ro({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(e.buffer)),r=new Bc(t,i,t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){const e=new Uint8Array(4),i=this.style.map.painter,r=i.context,s=r.gl;r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),s.readPixels(t.x,i.height/devicePixelRatio-t.y-1,1,1,s.RGBA,s.UNSIGNED_BYTE,e),r.bindFramebuffer.set(null);const n=e[0]+(e[2]>>4<<8),a=e[1]+((15&e[2])<<8),o=this.coordsIndex[255-e[3]],l=o&&this.sourceCache.getTileByID(o);if(!l)return null;const c=this._coordsTextureSize,h=(1<<l.tileID.canonical.z)*c;return new sh((l.tileID.canonical.x*c+n)/h,(l.tileID.canonical.y*c+a)/h,this.getElevation(l.tileID,n,a,c))}getTerrainMesh(){if(this._mesh)return this._mesh;const t=this.style.map.painter.context,e=new hn,i=new Sn,r=this.meshSize,s=oa/r,n=r*r;for(let t=0;t<=r;t++)for(let i=0;i<=r;i++)e.emplaceBack(i*s,t*s);for(let t=0;t<n;t+=r+1)for(let e=0;e<r;e++)i.emplaceBack(e+t,r+e+t+1,r+e+t+2),i.emplaceBack(e+t,r+e+t+2,e+t+1);return this._mesh={indexBuffer:t.createIndexBuffer(i),vertexBuffer:t.createVertexBuffer(e,$u.members),segments:Pn.simpleSegment(0,0,e.length,i.length)},this._mesh}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=(e.dem.min+this.elevationOffset)*this.exaggeration,i.maxElevation=(e.dem.max+this.elevationOffset)*this.exaggeration),i}}const Zu=(t,e)=>Lr(t,e&&e.filter((t=>"source.canvas"!==t.identifier))),Gu=p(qh,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),Xu=p(qh,["setCenter","setZoom","setBearing","setPitch"]),Wu=function(){const t={},e=mt.$version;for(const i in mt.$root){const r=mt.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t}();class Hu extends dt{constructor(t,e={}){super(),this.map=t,this.dispatcher=new Xc(Vh(),this),this.imageManager=new Fc,this.imageManager.setEventedParent(this),this.glyphManager=new Nc(t._requestManager,e.localIdeographFontFamily),this.lineAtlas=new Zc(256,512),this.crossTileSymbolIndex=new Nu,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new Nr,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Y());const i=this;this._rtlTextPluginCallback=Hu.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,e)=>{if(rs(t),e&&e.every((t=>t)))for(const t in i.sourceCaches)i.sourceCaches[t].reload()}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,e={}){this.fire(new ut("dataloading",{dataType:"style"}));const i="boolean"!=typeof e.validate||e.validate,r=this.map._requestManager.transformRequest(t,H.Style);this._request=tt(r,((t,e)=>{this._request=null,t?this.fire(new pt(t)):e&&this._load(e,i)}))}loadJSON(t,e={}){this.fire(new ut("dataloading",{dataType:"style"})),this._request=P.frame((()=>{this._request=null,this._load(t,!1!==e.validate)}))}loadEmpty(){this.fire(new ut("dataloading",{dataType:"style"})),this._load(Wu,!1)}_load(t,e){if(e&&Zu(this,Pr(t)))return;this._loaded=!0,this.stylesheet=t;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});t.sprite?this._loadSprite(t.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(t.glyphs);const i=$h(this.stylesheet.layers);this._order=i.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let t of i)t=Lc(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new jc(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new ut("data",{dataType:"style"})),this.fire(new ut("style.load"))}_loadSprite(t){this._spriteRequest=function(t,e,i,r){let s,n,a;const o=i>1?"@2x":"";let l=tt(e.transformRequest(e.normalizeSpriteURL(t,o,".json"),H.SpriteJSON),((t,e)=>{l=null,a||(a=t,s=e,h())})),c=at(e.transformRequest(e.normalizeSpriteURL(t,o,".png"),H.SpriteImage),((t,e)=>{c=null,a||(a=t,n=e,h())}));function h(){if(a)r(a);else if(s&&n){const t=P.getImageData(n),e={};for(const i in s){const{width:r,height:n,x:a,y:o,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:p}=s[i],d=new ro({width:r,height:n});ro.copy(t,d,{x:a,y:o},{x:0,y:0},{width:r,height:n}),e[i]={data:d,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:p}}r(null,e)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,this.map.getPixelRatio(),((t,e)=>{if(this._spriteRequest=null,t)this.fire(new pt(t));else if(e)for(const t in e)this.imageManager.addImage(t,e[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new ut("data",{dataType:"style"}))}))}_validateLayer(t){const e=this.sourceCaches[t.source];if(!e)return;const i=t.sourceLayer;if(!i)return;const r=e.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new pt(new Error(`Source layer "${i}" does not exist on source "${r.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()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.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 e=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const i={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];i[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in i){const e=this.sourceCaches[t];i[t]!==e.used&&e.fire(new ut("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.z=t.zoom,e&&this.fire(new ut("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={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(t){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),t){const e=this.sourceCaches[t.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);this.terrain=new ju(this,e,t),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=t=>{t.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=e=>{e.tile&&(e.sourceId===t.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(e.sourceId,e.tile.tileID)):"geojson"===e.source.type&&this.terrain.rememberForRerender(e.sourceId,e.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new ut("terrain",{terrain:t}))}setState(t){if(this._checkLoaded(),Zu(this,Pr(t)))return!1;(t=y(t)).layers=$h(t.layers);const e=function(t,e){if(!t)return[{command:qh.setStyle,args:[e]}];let i=[];try{if(!n(t.version,e.version))return[{command:qh.setStyle,args:[e]}];n(t.center,e.center)||i.push({command:qh.setCenter,args:[e.center]}),n(t.zoom,e.zoom)||i.push({command:qh.setZoom,args:[e.zoom]}),n(t.bearing,e.bearing)||i.push({command:qh.setBearing,args:[e.bearing]}),n(t.pitch,e.pitch)||i.push({command:qh.setPitch,args:[e.pitch]}),n(t.sprite,e.sprite)||i.push({command:qh.setSprite,args:[e.sprite]}),n(t.glyphs,e.glyphs)||i.push({command:qh.setGlyphs,args:[e.glyphs]}),n(t.transition,e.transition)||i.push({command:qh.setTransition,args:[e.transition]}),n(t.light,e.light)||i.push({command:qh.setLight,args:[e.light]});const r={},s=[];!function(t,e,i,r){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||Zh(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?n(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&Xh(t,e,s)?i.push({command:qh.setGeoJSONSourceData,args:[s,e[s].data]}):Gh(s,e,i,r)):jh(s,e,i))}(t.sources,e.sources,s,r);const a=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:qh.removeLayer,args:[t.id]}):a.push(t)})),i=i.concat(s),function(t,e,i){e=e||[];const r=(t=t||[]).map(Hh),s=e.map(Hh),a=t.reduce(Kh,{}),o=e.reduce(Kh,{}),l=r.slice(),c=Object.create(null);let h,u,p,d,m,f,_;for(h=0,u=0;h<r.length;h++)p=r[h],Object.prototype.hasOwnProperty.call(o,p)?u++:(i.push({command:qh.removeLayer,args:[p]}),l.splice(l.indexOf(p,u),1));for(h=0,u=0;h<s.length;h++)p=s[s.length-1-h],l[l.length-1-h]!==p&&(Object.prototype.hasOwnProperty.call(a,p)?(i.push({command:qh.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-u),1)):u++,f=l[l.length-h],i.push({command:qh.addLayer,args:[o[p],f]}),l.splice(l.length-h,0,p),c[p]=!0);for(h=0;h<s.length;h++)if(p=s[h],d=a[p],m=o[p],!c[p]&&!n(d,m))if(n(d.source,m.source)&&n(d["source-layer"],m["source-layer"])&&n(d.type,m.type)){for(_ in Wh(d.layout,m.layout,i,p,null,qh.setLayoutProperty),Wh(d.paint,m.paint,i,p,null,qh.setPaintProperty),n(d.filter,m.filter)||i.push({command:qh.setFilter,args:[p,m.filter]}),n(d.minzoom,m.minzoom)&&n(d.maxzoom,m.maxzoom)||i.push({command:qh.setLayerZoomRange,args:[p,m.minzoom,m.maxzoom]}),d)Object.prototype.hasOwnProperty.call(d,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Wh(d[_],m[_],i,p,_.slice(6),qh.setPaintProperty):n(d[_],m[_])||i.push({command:qh.setLayerProperty,args:[p,_,m[_]]}));for(_ in m)Object.prototype.hasOwnProperty.call(m,_)&&!Object.prototype.hasOwnProperty.call(d,_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Wh(d[_],m[_],i,p,_.slice(6),qh.setPaintProperty):n(d[_],m[_])||i.push({command:qh.setLayerProperty,args:[p,_,m[_]]}))}else i.push({command:qh.removeLayer,args:[p]}),f=l[l.lastIndexOf(p)+1],i.push({command:qh.addLayer,args:[m,f]})}(a,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:qh.setStyle,args:[e]}]}return i}(this.serialize(),t).filter((t=>!(t.command in Xu)));if(0===e.length)return!1;const i=e.filter((t=>!(t.command in Gu)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((t=>t.command)).join(", ")}.`);return e.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=t,!0}addImage(t,e){if(this.getImage(t))return this.fire(new pt(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,e),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 pt(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("setImages",this._availableImages),this.fire(new ut("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(Pr.source,`sources.${t}`,e,null,i))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const r=this.sourceCaches[t]=new Mh(t,e,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:this.loaded(),source:r.serialize(),sourceId:t}))),r.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 e in this._layers)if(this._layers[e].source===t)return this.fire(new pt(new Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));const e=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],e.fire(new ut("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),e.setEventedParent(null),e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,e,i={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new pt(new Error(`Layer "${r}" already exists on this map.`)));let s;if("custom"===t.type){if(Zu(this,function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e}(t)))return;s=Lc(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=u(t=y(t),{source:r})),this._validate(Pr.layer,`layers.${r}`,t,{arrayIndex:-1},i))return;s=Lc(t),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[s.id]=s.serialize()}const n=e?this._order.indexOf(e):this._order.length;if(e&&-1===n)this.fire(new pt(new Error(`Cannot add layer "${r}" before non-existing layer "${e}".`)));else{if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=s,this._removedLayers[r]&&s.source&&"custom"!==s.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.sourceCaches[s.source].pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map)}}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new pt(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;const i=this._order.indexOf(t);this._order.splice(i,1);const r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new pt(new Error(`Cannot move layer "${t}" before non-existing layer "${e}".`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const e=this._layers[t];if(!e)return void this.fire(new pt(new Error(`Cannot remove non-existing layer "${t}".`)));e.setEventedParent(null);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,e,i){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===e&&r.maxzoom===i||(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new pt(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,e,i={}){this._checkLoaded();const r=this.getLayer(t);if(r){if(!n(r.filter,e))return null==e?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Pr.filter,`layers.${r.id}.filter`,e,null,i)||(r.filter=y(e),this._updateLayer(r)))}else this.fire(new pt(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return y(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?n(s.getLayoutProperty(e),i)||(s.setLayoutProperty(e,i,r),this._updateLayer(s)):this.fire(new pt(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){const i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new pt(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();const s=this.getLayer(t);s?n(s.getPaintProperty(e),i)||(s.setPaintProperty(e,i,r)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new pt(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();const i=t.source,r=t.sourceLayer,s=this.sourceCaches[i];if(void 0===s)return void this.fire(new pt(new Error(`The source '${i}' does not exist in the map's style.`)));const n=s.getSource().type;"geojson"===n&&r?this.fire(new pt(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==n||r?(void 0===t.id&&this.fire(new pt(new Error("The feature id parameter must be provided."))),s.setFeatureState(r,t.id,e)):this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,e){this._checkLoaded();const i=t.source,r=this.sourceCaches[i];if(void 0===r)return void this.fire(new pt(new Error(`The source '${i}' does not exist in the map's style.`)));const s=r.getSource().type,n="vector"===s?t.sourceLayer:void 0;"vector"!==s||n?e&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new pt(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,t.id,e):this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const e=t.source,i=t.sourceLayer,r=this.sourceCaches[e];if(void 0!==r)return"vector"!==r.getSource().type||i?(void 0===t.id&&this.fire(new pt(new Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id)):void this.fire(new pt(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new pt(new Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return u({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return g({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:_(this.sourceCaches,(t=>t.serialize())),layers:this._serializeLayers(this._order)},(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._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){const n=this._order[s];if(e(n)){i[n]=s;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let n=this._order.length-1;n>=0;n--){const a=this._order[n];if(e(a))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<n)break;s.push(e),r.pop()}else for(const e of t){const t=e[a];if(t)for(const e of t)s.push(e.feature)}}return s}queryRenderedFeatures(t,e,i){e&&e.filter&&this._validate(Pr.filter,"queryRenderedFeatures.filter",e.filter,null,e);const r={};if(e&&e.layers){if(!Array.isArray(e.layers))return this.fire(new pt(new Error("parameters.layers must be an Array."))),[];for(const t of e.layers){const e=this._layers[t];if(!e)return this.fire(new pt(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}const s=[];e.availableImages=this._availableImages;for(const n in this.sourceCaches)e.layers&&!r[n]||s.push(wh(this.sourceCaches[n],this._layers,this._serializedLayers,t,e,i));return this.placement&&s.push(function(t,e,i,r,s,n,a){const o={},l=n.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(a[t]);c.sort(Th);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,s.filter,s.layers,s.availableImages,t);for(const t in r){const e=o[t]=o[t]||[],s=r[t];s.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of s)e.push(t)}}for(const e in o)o[e].forEach((r=>{const s=r.feature,n=i[t[e].source].getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=n}));return o}(this._layers,this._serializedLayers,this.sourceCaches,t,e,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(t,e){e&&e.filter&&this._validate(Pr.filter,"querySourceFeatures.filter",e.filter,null,e);const i=this.sourceCaches[t];return i?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],s={};for(let t=0;t<i.length;t++){const n=i[t],a=n.tileID.canonical.key;s[a]||(s[a]=!0,n.querySourceFeatures(r,e))}return r}(i,e):[]}addSourceType(t,e,i){return Hu.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Hu.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const e in t)if(!n(t[e],i[e])){r=!0;break}if(!r)return;const s={now:P.now(),transition:u({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(s)}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&Zu(this,t.call(Pr,u({key:e,style:this.serialize(),value:i,styleSpec:mt},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),ns.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.sourceCaches){const e=this.sourceCaches[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const e in this.sourceCaches)this.sourceCaches[e].update(t,this.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,e,i,r,s=!1){let n=!1,a=!1;const o={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!o[i.source]){const t=this.sourceCaches[i.source];o[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,o[i.source],t.center.lng);n=n||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((s=s||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(P.now(),t.zoom))&&(this.pauseablePlacement=new Fu(t,this.terrain,this._order,s,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(P.now()),a=!0),n&&this.pauseablePlacement.placement.setStale()),a||n)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,o[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(P.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(t,e,i){return Q(e,i)}}Hu.getSourceType=function(t){return vh[t]},Hu.setSourceType=function(t,e){vh[t]=e},Hu.registerForPluginStateChange=function(t){return t({pluginStatus:es,pluginURL:is}),ns.on("pluginStateChange",t),t};var Ku="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}";const Yu={prelude:Ju("#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","#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_offset;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_offset)*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:Ju("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}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:Ju("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}","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);}"),circle:Ju("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}","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);}"),clippingMask:Ju("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Ju("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}","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;}"),heatmapTexture:Ju("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}","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;}"),collisionBox:Ju("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;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Ju("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;}","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);}"),debug:Ju("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);}","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);}"),fill:Ju("#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}","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);}"),fillOutline:Ju("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}","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;}"),fillOutlinePattern:Ju("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}","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;}"),fillPattern:Ju("#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}","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);}"),fillExtrusion:Ju("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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;}"),fillExtrusionPattern:Ju("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}","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 baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);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;}"),hillshadePrepare:Ju("#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}","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;}"),hillshade:Ju("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}","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;}"),line:Ju("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}","\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);}"),lineGradient:Ju("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}","\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);}"),linePattern:Ju("#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}","\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;}"),lineSDF:Ju("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}","\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);}"),raster:Ju("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}","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;}"),symbolIcon:Ju("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}","const float PI=3.141592653589793;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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);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));}"),symbolSDF:Ju("#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 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}","const float PI=3.141592653589793;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 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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;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);}"),symbolTextAndIcon:Ju("#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}","const float PI=3.141592653589793;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;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\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;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);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=u_matrix*vec4(a_pos+vec2(1,0),ele,1);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=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;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);}"),terrain:Ju("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",Ku),terrainDepth:Ju("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);}",Ku),terrainCoords:Ju("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);}",Ku)};function Ju(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=n?n.concat(s):s,o={};return{fragmentSource:t=t.replace(i,((t,e,i,r,s)=>(o[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,s)=>{const n="float"===r?"vec2":"vec4",a=s.match(/color/)?"color":n;return o[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class Qu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,s,n,a,o,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===s&&this.boundVertexOffset===n&&this.boundDynamicVertexBuffer===a&&this.boundDynamicVertexBuffer2===o&&this.boundDynamicVertexBuffer3===l?(t.bindVertexArrayOES.set(this.vao),a&&a.bind(),s&&s.dynamicDraw&&s.bind(),o&&o.bind(),l&&l.bind()):this.freshBind(e,i,r,s,n,a,o,l)}freshBind(t,e,i,r,s,n,a,o){let l;const c=t.numAttributes,h=this.context,u=h.gl;if(h.extVertexArrayObject)this.vao&&this.destroy(),this.vao=h.extVertexArrayObject.createVertexArrayOES(),h.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=s,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=a,this.boundDynamicVertexBuffer3=o;else{l=h.currentNumAttributes||0;for(let t=c;t<l;t++)u.disableVertexAttribArray(t)}e.enableAttributes(u,t);for(const e of i)e.enableAttributes(u,t);n&&n.enableAttributes(u,t),a&&a.enableAttributes(u,t),o&&o.enableAttributes(u,t),e.bind(),e.setVertexAttribPointers(u,t,s);for(const e of i)e.bind(),e.setVertexAttribPointers(u,t,s);n&&(n.bind(),n.setVertexAttribPointers(u,t,s)),r&&r.bind(),a&&(a.bind(),a.setVertexAttribPointers(u,t,s)),o&&(o.bind(),o.setVertexAttribPointers(u,t,s)),h.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function tp(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class ep{constructor(t,e,i,r,s,n,a){const o=t.gl;this.program=o.createProgram();const l=tp(i.staticAttributes),c=r?r.getBinderAttributes():[],h=l.concat(c),u=Yu.prelude.staticUniforms?tp(Yu.prelude.staticUniforms):[],p=i.staticUniforms?tp(i.staticUniforms):[],d=r?r.getBinderUniforms():[],m=u.concat(p).concat(d),f=[];for(const t of m)f.indexOf(t)<0&&f.push(t);const _=r?r.defines():[];n&&_.push("#define OVERDRAW_INSPECTOR;"),a&&_.push("#define TERRAIN3D;");const g=_.concat(Yu.prelude.fragmentSource,i.fragmentSource).join("\n"),y=_.concat(Yu.prelude.vertexSource,i.vertexSource).join("\n"),x=o.createShader(o.FRAGMENT_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(x,g),o.compileShader(x),o.attachShader(this.program,x);const v=o.createShader(o.VERTEX_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(v,y),o.compileShader(v),o.attachShader(this.program,v),this.attributes={};const b={};this.numAttributes=h.length;for(let t=0;t<this.numAttributes;t++)h[t]&&(o.bindAttribLocation(this.program,t,h[t]),this.attributes[h[t]]=t);o.linkProgram(this.program),o.deleteShader(v),o.deleteShader(x);for(let t=0;t<f.length;t++){const e=f[t];if(e&&!b[e]){const t=o.getUniformLocation(this.program,e);t&&(b[e]=t)}}this.fixedUniforms=s(t,b),this.terrainUniforms=((t,e)=>({u_depth:new qn(t,e.u_depth),u_terrain:new qn(t,e.u_terrain),u_terrain_dim:new jn(t,e.u_terrain_dim),u_terrain_matrix:new Kn(t,e.u_terrain_matrix),u_terrain_unpack:new Xn(t,e.u_terrain_unpack),u_terrain_offset:new jn(t,e.u_terrain_offset),u_terrain_exaggeration:new jn(t,e.u_terrain_exaggeration)}))(t,b),this.binderUniforms=r?r.getUniforms(t,b):[]}draw(t,e,i,r,s,n,a,o,l,c,h,u,p,d,m,f,_,g){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(s),t.setCullFace(n),o){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,o.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,o.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(o[t])}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(a[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});const x={[y.LINES]:2,[y.TRIANGLES]:3,[y.LINE_STRIP]:1}[e];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[l]||(r[l]=new Qu)).bind(t,this,c,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,f,_,g),y.drawElements(e,i.primitiveLength*x,y.UNSIGNED_SHORT,i.primitiveOffset*x*2)}}}function ip(t,e,i){const r=1/_u(i,1,e.transform.tileZoom),s=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,a=n*(i.tileID.canonical.x+i.tileID.wrap*s),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}const rp=(t,e,i,r)=>{const s=e.style.light,n=s.properties.get("position"),a=[n.x,n.y,n.z],o=Ma();var l,c,h,u;"viewport"===s.properties.get("anchor")&&(l=o,c=-e.transform.angle,h=Math.sin(c),u=Math.cos(c),l[0]=u,l[1]=h,l[2]=0,l[3]=-h,l[4]=u,l[5]=0,l[6]=0,l[7]=0,l[8]=1),function(t,e,i){var r=e[0],s=e[1],n=e[2];t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8]}(a,a,o);const p=s.properties.get("color");return{u_matrix:t,u_lightpos:a,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[p.r,p.g,p.b],u_vertical_gradient:+i,u_opacity:r}},sp=(t,e,i,r,s,n,a)=>u(rp(t,e,i,r),ip(n,e,a),{u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8}),np=t=>({u_matrix:t}),ap=(t,e,i,r)=>u(np(t),ip(i,e,r)),op=(t,e)=>({u_matrix:t,u_world:e}),lp=(t,e,i,r,s)=>u(ap(t,e,i,r),{u_world:s}),cp=(t,e,i,r)=>{const s=t.transform;let n,a;if("map"===r.paint.get("circle-pitch-alignment")){const t=_u(i,1,s.zoom);n=!0,a=[t,t]}else n=!1,a=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+n,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},hp=(t,e,i)=>{const r=_u(i,1,e.zoom),s=Math.pow(2,e.zoom-i.tileID.overscaledZ),n=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*s),e.pixelsToGLUnits[1]/(r*s)],u_overscale_factor:n}},up=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),pp=t=>({u_matrix:t}),dp=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:_u(e,1,i),u_intensity:r});function mp(t,e){const i=Math.pow(2,e.canonical.z),r=e.canonical.y;return[new sh(0,r/i).toLngLat().lat,new sh(0,(r+1)/i).toLngLat().lat]}const fp=(t,e,i,r)=>{const s=t.transform;return{u_matrix:vp(t,e,i,r),u_ratio:1/_u(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},_p=(t,e,i,r,s)=>u(fp(t,e,i,s),{u_image:0,u_image_height:r}),gp=(t,e,i,r,s)=>{const n=t.transform,a=xp(e,n);return{u_matrix:vp(t,e,i,s),u_texsize:e.imageAtlasTexture.size,u_ratio:1/_u(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},yp=(t,e,i,r,s,n)=>{const a=t.lineAtlas,o=xp(e,t.transform),l="round"===i.layout.get("line-cap"),c=a.getDash(r.from,l),h=a.getDash(r.to,l),p=c.width*s.fromScale,d=h.width*s.toScale;return u(fp(t,e,i,n),{u_patternscale_a:[o/p,-c.height/2],u_patternscale_b:[o/d,-h.height/2],u_sdfgamma:a.width/(256*Math.min(p,d)*t.pixelRatio)/2,u_image:0,u_tex_y_a:c.y,u_tex_y_b:h.y,u_mix:s.t})};function xp(t,e){return 1/_u(t,1,e.tileZoom)}function vp(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const bp=(t,e,i,r,s)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(a=s.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(n=s.paint.get("raster-contrast"),n>0?1/(1-n):1+n),u_spin_weights:wp(s.paint.get("raster-hue-rotate"))};var n,a};function wp(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Tp=(t,e,i,r,s,n,a,o,l,c)=>{const h=s.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:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:o,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},Ip=(t,e,i,r,s,n,a,o,l,c,h)=>{const p=s.transform;return u(Tp(t,e,i,r,s,n,a,o,l,c),{u_gamma_scale:r?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+h})},Sp=(t,e,i,r,s,n,a,o,l,c)=>u(Ip(t,e,i,r,s,n,a,o,!0,l,!0),{u_texsize_icon:c,u_texture_icon:1}),Ap=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),zp=(t,e,i,r,s,n)=>u(function(t,e,i,r){const s=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:a,height:o}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[a,o],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/_u(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,n,i,s),{u_matrix:t,u_opacity:e}),Ep={fillExtrusion:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_lightpos:new Gn(t,e.u_lightpos),u_lightintensity:new jn(t,e.u_lightintensity),u_lightcolor:new Gn(t,e.u_lightcolor),u_vertical_gradient:new jn(t,e.u_vertical_gradient),u_opacity:new jn(t,e.u_opacity)}),fillExtrusionPattern:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_lightpos:new Gn(t,e.u_lightpos),u_lightintensity:new jn(t,e.u_lightintensity),u_lightcolor:new Gn(t,e.u_lightcolor),u_vertical_gradient:new jn(t,e.u_vertical_gradient),u_height_factor:new jn(t,e.u_height_factor),u_image:new qn(t,e.u_image),u_texsize:new Zn(t,e.u_texsize),u_pixel_coord_upper:new Zn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Zn(t,e.u_pixel_coord_lower),u_scale:new Gn(t,e.u_scale),u_fade:new jn(t,e.u_fade),u_opacity:new jn(t,e.u_opacity)}),fill:(t,e)=>({u_matrix:new Kn(t,e.u_matrix)}),fillPattern:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_texsize:new Zn(t,e.u_texsize),u_pixel_coord_upper:new Zn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Zn(t,e.u_pixel_coord_lower),u_scale:new Gn(t,e.u_scale),u_fade:new jn(t,e.u_fade)}),fillOutline:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_world:new Zn(t,e.u_world)}),fillOutlinePattern:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_world:new Zn(t,e.u_world),u_image:new qn(t,e.u_image),u_texsize:new Zn(t,e.u_texsize),u_pixel_coord_upper:new Zn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Zn(t,e.u_pixel_coord_lower),u_scale:new Gn(t,e.u_scale),u_fade:new jn(t,e.u_fade)}),circle:(t,e)=>({u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_scale_with_map:new qn(t,e.u_scale_with_map),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_extrude_scale:new Zn(t,e.u_extrude_scale),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_matrix:new Kn(t,e.u_matrix)}),collisionBox:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_pixels_to_tile_units:new jn(t,e.u_pixels_to_tile_units),u_extrude_scale:new Zn(t,e.u_extrude_scale),u_overscale_factor:new jn(t,e.u_overscale_factor)}),collisionCircle:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_inv_matrix:new Kn(t,e.u_inv_matrix),u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_viewport_size:new Zn(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new Wn(t,e.u_color),u_matrix:new Kn(t,e.u_matrix),u_overlay:new qn(t,e.u_overlay),u_overlay_scale:new jn(t,e.u_overlay_scale)}),clippingMask:(t,e)=>({u_matrix:new Kn(t,e.u_matrix)}),heatmap:(t,e)=>({u_extrude_scale:new jn(t,e.u_extrude_scale),u_intensity:new jn(t,e.u_intensity),u_matrix:new Kn(t,e.u_matrix)}),heatmapTexture:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_world:new Zn(t,e.u_world),u_image:new qn(t,e.u_image),u_color_ramp:new qn(t,e.u_color_ramp),u_opacity:new jn(t,e.u_opacity)}),hillshade:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_latrange:new Zn(t,e.u_latrange),u_light:new Zn(t,e.u_light),u_shadow:new Wn(t,e.u_shadow),u_highlight:new Wn(t,e.u_highlight),u_accent:new Wn(t,e.u_accent)}),hillshadePrepare:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_image:new qn(t,e.u_image),u_dimension:new Zn(t,e.u_dimension),u_zoom:new jn(t,e.u_zoom),u_unpack:new Xn(t,e.u_unpack)}),line:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_ratio:new jn(t,e.u_ratio),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_units_to_pixels:new Zn(t,e.u_units_to_pixels)}),lineGradient:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_ratio:new jn(t,e.u_ratio),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_units_to_pixels:new Zn(t,e.u_units_to_pixels),u_image:new qn(t,e.u_image),u_image_height:new jn(t,e.u_image_height)}),linePattern:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_texsize:new Zn(t,e.u_texsize),u_ratio:new jn(t,e.u_ratio),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_image:new qn(t,e.u_image),u_units_to_pixels:new Zn(t,e.u_units_to_pixels),u_scale:new Gn(t,e.u_scale),u_fade:new jn(t,e.u_fade)}),lineSDF:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_ratio:new jn(t,e.u_ratio),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_units_to_pixels:new Zn(t,e.u_units_to_pixels),u_patternscale_a:new Zn(t,e.u_patternscale_a),u_patternscale_b:new Zn(t,e.u_patternscale_b),u_sdfgamma:new jn(t,e.u_sdfgamma),u_image:new qn(t,e.u_image),u_tex_y_a:new jn(t,e.u_tex_y_a),u_tex_y_b:new jn(t,e.u_tex_y_b),u_mix:new jn(t,e.u_mix)}),raster:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_tl_parent:new Zn(t,e.u_tl_parent),u_scale_parent:new jn(t,e.u_scale_parent),u_buffer_scale:new jn(t,e.u_buffer_scale),u_fade_t:new jn(t,e.u_fade_t),u_opacity:new jn(t,e.u_opacity),u_image0:new qn(t,e.u_image0),u_image1:new qn(t,e.u_image1),u_brightness_low:new jn(t,e.u_brightness_low),u_brightness_high:new jn(t,e.u_brightness_high),u_saturation_factor:new jn(t,e.u_saturation_factor),u_contrast_factor:new jn(t,e.u_contrast_factor),u_spin_weights:new Gn(t,e.u_spin_weights)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new jn(t,e.u_size_t),u_size:new jn(t,e.u_size),u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_pitch:new jn(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new jn(t,e.u_aspect_ratio),u_fade_change:new jn(t,e.u_fade_change),u_matrix:new Kn(t,e.u_matrix),u_label_plane_matrix:new Kn(t,e.u_label_plane_matrix),u_coord_matrix:new Kn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new Zn(t,e.u_texsize),u_texture:new qn(t,e.u_texture)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new jn(t,e.u_size_t),u_size:new jn(t,e.u_size),u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_pitch:new jn(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new jn(t,e.u_aspect_ratio),u_fade_change:new jn(t,e.u_fade_change),u_matrix:new Kn(t,e.u_matrix),u_label_plane_matrix:new Kn(t,e.u_label_plane_matrix),u_coord_matrix:new Kn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new Zn(t,e.u_texsize),u_texture:new qn(t,e.u_texture),u_gamma_scale:new jn(t,e.u_gamma_scale),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_is_halo:new qn(t,e.u_is_halo)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new qn(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new qn(t,e.u_is_size_feature_constant),u_size_t:new jn(t,e.u_size_t),u_size:new jn(t,e.u_size),u_camera_to_center_distance:new jn(t,e.u_camera_to_center_distance),u_pitch:new jn(t,e.u_pitch),u_rotate_symbol:new qn(t,e.u_rotate_symbol),u_aspect_ratio:new jn(t,e.u_aspect_ratio),u_fade_change:new jn(t,e.u_fade_change),u_matrix:new Kn(t,e.u_matrix),u_label_plane_matrix:new Kn(t,e.u_label_plane_matrix),u_coord_matrix:new Kn(t,e.u_coord_matrix),u_is_text:new qn(t,e.u_is_text),u_pitch_with_map:new qn(t,e.u_pitch_with_map),u_texsize:new Zn(t,e.u_texsize),u_texsize_icon:new Zn(t,e.u_texsize_icon),u_texture:new qn(t,e.u_texture),u_texture_icon:new qn(t,e.u_texture_icon),u_gamma_scale:new jn(t,e.u_gamma_scale),u_device_pixel_ratio:new jn(t,e.u_device_pixel_ratio),u_is_halo:new qn(t,e.u_is_halo)}),background:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_opacity:new jn(t,e.u_opacity),u_color:new Wn(t,e.u_color)}),backgroundPattern:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_opacity:new jn(t,e.u_opacity),u_image:new qn(t,e.u_image),u_pattern_tl_a:new Zn(t,e.u_pattern_tl_a),u_pattern_br_a:new Zn(t,e.u_pattern_br_a),u_pattern_tl_b:new Zn(t,e.u_pattern_tl_b),u_pattern_br_b:new Zn(t,e.u_pattern_br_b),u_texsize:new Zn(t,e.u_texsize),u_mix:new jn(t,e.u_mix),u_pattern_size_a:new Zn(t,e.u_pattern_size_a),u_pattern_size_b:new Zn(t,e.u_pattern_size_b),u_scale_a:new jn(t,e.u_scale_a),u_scale_b:new jn(t,e.u_scale_b),u_pixel_coord_upper:new Zn(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Zn(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new jn(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_texture:new qn(t,e.u_texture)}),terrainDepth:(t,e)=>({u_matrix:new Kn(t,e.u_matrix)}),terrainCoords:(t,e)=>({u_matrix:new Kn(t,e.u_matrix),u_texture:new qn(t,e.u_texture),u_terrain_coords_id:new jn(t,e.u_terrain_coords_id)})};class Cp{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Pp={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class kp{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const s=this.attributes[r],n=e.attributes[s.name];void 0!==n&&t.vertexAttribPointer(n,s.components,t[Pp[s.type]],!1,this.itemSize,s.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Mp{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Dp extends Mp{getDefault(){return Zt.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Lp extends Mp{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Bp extends Mp{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Rp extends Mp{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Fp extends Mp{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Op extends Mp{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Vp extends Mp{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Up extends Mp{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Np extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class $p extends Mp{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class qp extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class jp extends Mp{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Zp extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Gp extends Mp{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Xp extends Mp{getDefault(){return Zt.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Wp extends Mp{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Hp extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Kp extends Mp{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Yp extends Mp{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Jp extends Mp{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Qp extends Mp{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class td extends Mp{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ed extends Mp{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class id extends Mp{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class rd extends Mp{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class sd extends Mp{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class nd extends Mp{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ad extends Mp{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class od extends Mp{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class ld extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class cd extends Mp{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class hd extends Mp{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class ud extends hd{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class pd extends hd{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class dd{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const s=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new ud(t,s),r&&(this.depthAttachment=new pd(t,s))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class md{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}md.Replace=[1,0],md.disabled=new md(md.Replace,Zt.transparent,[!1,!1,!1,!1]),md.unblended=new md(md.Replace,Zt.transparent,[!0,!0,!0,!0]),md.alphaBlended=new md([1,771],Zt.transparent,[!0,!0,!0,!0]);class fd{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Dp(this),this.clearDepth=new Lp(this),this.clearStencil=new Bp(this),this.colorMask=new Rp(this),this.depthMask=new Fp(this),this.stencilMask=new Op(this),this.stencilFunc=new Vp(this),this.stencilOp=new Up(this),this.stencilTest=new Np(this),this.depthRange=new $p(this),this.depthTest=new qp(this),this.depthFunc=new jp(this),this.blend=new Zp(this),this.blendFunc=new Gp(this),this.blendColor=new Xp(this),this.blendEquation=new Wp(this),this.cullFace=new Hp(this),this.cullFaceSide=new Kp(this),this.frontFace=new Yp(this),this.program=new Jp(this),this.activeTexture=new Qp(this),this.viewport=new td(this),this.bindFramebuffer=new ed(this),this.bindRenderbuffer=new id(this),this.bindTexture=new rd(this),this.bindVertexBuffer=new sd(this),this.bindElementBuffer=new nd(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ad(this),this.pixelStoreUnpack=new od(this),this.pixelStoreUnpackPremultiplyAlpha=new ld(this),this.pixelStoreUnpackFlipY=new cd(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new Cp(this,t,e)}createVertexBuffer(t,e,i){return new kp(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,s=r.createRenderbuffer();return this.bindRenderbuffer.set(s),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),s}createFramebuffer(t,e,i){return new dd(this,t,e,i)}clear({color:t,depth:e}){const i=this.gl;let r=0;t&&(r|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),i.clear(r)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){n(t.blendFunction,md.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class _d{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}_d.ReadOnly=!1,_d.ReadWrite=!0,_d.disabled=new _d(519,_d.ReadOnly,[0,1]);const gd=7680;class yd{constructor(t,e,i,r,s,n){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=s,this.pass=n}}yd.disabled=new yd({func:519,mask:0},0,0,gd,gd,gd);class xd{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}let vd;function bd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=t.useProgram("collisionBox"),h=[];let u=0,p=0;for(let d=0;d<r.length;d++){const m=r[d],f=e.getTile(m),_=f.getBucket(i);if(!_)continue;let g=m.posMatrix;0===s[0]&&0===s[1]||(g=t.translatePosMatrix(m.posMatrix,f,s,n));const y=a?_.textCollisionBox:_.iconCollisionBox,x=_.collisionCircleArray;if(x.length>0){const e=Da(),i=g;Na(e,_.placementInvProjMatrix,t.transform.glCoordMatrix),Na(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:p,transform:i,invTransform:e,coord:m}),u+=x.length/4,p=u}y&&c.draw(o,l.LINES,_d.disabled,yd.disabled,t.colorModeForRenderPass(),xd.disabled,hp(g,t.transform,f),t.style.terrain&&t.style.terrain.getTerrainData(m),i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,null,y.collisionVertexBuffer)}if(!a||!h.length)return;const d=t.useProgram("collisionCircle"),m=new wn;m.resize(4*u),m._trim();let f=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],s=t.circleArray[i+1],n=t.circleArray[i+2],a=t.circleArray[i+3];m.emplace(f++,r,s,n,a,0),m.emplace(f++,r,s,n,a,1),m.emplace(f++,r,s,n,a,2),m.emplace(f++,r,s,n,a,3)}(!vd||vd.length<2*u)&&(vd=function(t){const e=2*t,i=new In;i.resize(e),i._trim();for(let t=0;t<e;t++){const e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));const _=o.createIndexBuffer(vd,!0),g=o.createVertexBuffer(m,Dl.members,!0);for(const e of h){const r={u_matrix:e.transform,u_inv_matrix:e.invTransform,u_camera_to_center_distance:(y=t.transform).cameraToCenterDistance,u_viewport_size:[y.width,y.height]};d.draw(o,l.TRIANGLES,_d.disabled,yd.disabled,t.colorModeForRenderPass(),xd.disabled,r,t.style.terrain&&t.style.terrain.getTerrainData(e.coord),i.id,g,_,Pn.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}var y;g.destroy(),_.destroy()}xd.disabled=new xd(!1,1029,2305),xd.backCCW=new xd(!0,1029,2305);const wd=La(new Float32Array(16));function Td(t,e,i,r,s,n){const{horizontalAlign:a,verticalAlign:o}=hc(t),l=-(a-.5)*e,c=-(o-.5)*i,h=_c(t,r);return new k((l/s+h[0])*n,(c/s+h[1])*n)}function Id(t,e,i,r,s,n,a,o,l,c,h){const u=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,d=t.icon.dynamicLayoutVertexArray,m={};p.clear();for(let d=0;d<u.length;d++){const f=u.get(d),_=t.allowVerticalPlacement&&!f.placedOrientation,g=f.hidden||!f.crossTileID||_?null:r[f.crossTileID];if(g){const r=new k(f.anchorX,f.anchorY),u=iu(r,i?a:n,h),d=ru(s.cameraToCenterDistance,u.signedDistanceFromCamera);let _=pc(t.textSizeData,l,f)*d/24;i&&(_*=t.tilePixelRatio/o);const{width:y,height:x,anchor:v,textOffset:b,textBoxScale:w}=g,T=Td(v,y,x,b,w,_),I=i?iu(r.add(T),n,h).point:u.point.add(e?T.rotate(-s.angle):T),S=t.allowVerticalPlacement&&f.placedOrientation===Ul.vertical?Math.PI/2:0;for(let t=0;t<f.numGlyphs;t++)vc(p,I,S);c&&f.associatedIconIndex>=0&&(m[f.associatedIconIndex]={shiftedAnchor:I,angle:S})}else pu(f.numGlyphs,p)}if(c){d.clear();const e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){const i=e.get(t);if(i.hidden)pu(i.numGlyphs,d);else{const e=m[t];if(e)for(let t=0;t<i.numGlyphs;t++)vc(d,e.shiftedAnchor,e.angle);else pu(i.numGlyphs,d)}}t.icon.dynamicLayoutVertexBuffer.updateData(d)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function Sd(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function Ad(t,e,i,r,s,n,a,o,l,c,h,u){const p=t.context,d=p.gl,m=t.transform,f="map"===o,_="map"===l,g="viewport"!==o&&"point"!==i.layout.get("symbol-placement"),y=f&&!_&&!g,x=!i.layout.get("symbol-sort-key").isConstant();let v=!1;const b=t.depthModeForSublayer(0,_d.ReadOnly),w=i.layout.get("text-variable-anchor"),T=[];for(const o of r){const r=e.getTile(o),l=r.getBucket(i);if(!l)continue;const h=s?l.text:l.icon;if(!h||!h.segments.get().length)continue;const u=h.programConfigurations.get(i.id),p=s||l.sdfIcons,b=s?l.textSizeData:l.iconSizeData,I=_||0!==m.pitch,S=t.useProgram(Sd(p,s,l),u),A=dc(b,m.zoom),z=t.style.terrain&&t.style.terrain.getTerrainData(o);let E,C,P,k,M=[0,0],D=null;if(s){if(C=r.glyphAtlasTexture,P=d.LINEAR,E=r.glyphAtlasTexture.size,l.iconsInText){M=r.imageAtlasTexture.size,D=r.imageAtlasTexture;const e="composite"===b.kind||"camera"===b.kind;k=I||t.options.rotating||t.options.zooming||e?d.LINEAR:d.NEAREST}}else{const e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;C=r.imageAtlasTexture,P=p||t.options.rotating||t.options.zooming||e||I?d.LINEAR:d.NEAREST,E=r.imageAtlasTexture.size}const L=_u(r,1,t.transform.zoom),B=tu(o.posMatrix,_,f,t.transform,L),R=eu(o.posMatrix,_,f,t.transform,L),F=w&&l.hasTextData(),O="none"!==i.layout.get("icon-text-fit")&&F&&l.hasIconData();if(g){const e=t.style.terrain?(e,i)=>t.style.terrain.getElevation(o,e,i):null,r="map"===i.layout.get("text-rotation-alignment");nu(l,o.posMatrix,t,s,B,R,_,c,r,e)}const V=t.translatePosMatrix(o.posMatrix,r,n,a),U=g||s&&w||O?wd:B,N=t.translatePosMatrix(R,r,n,a,!0),$=p&&0!==i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let q;q=p?l.iconsInText?Sp(b.kind,A,y,_,t,V,U,N,E,M):Ip(b.kind,A,y,_,t,V,U,N,s,E,!0):Tp(b.kind,A,y,_,t,V,U,N,s,E);const j={program:S,buffers:h,uniformValues:q,atlasTexture:C,atlasTextureIcon:D,atlasInterpolation:P,atlasInterpolationIcon:k,isSDF:p,hasHalo:$};if(x&&l.canOverlap){v=!0;const t=h.segments.get();for(const e of t)T.push({segments:new Pn([e]),sortKey:e.sortKey,state:j,terrainData:z})}else T.push({segments:h.segments,sortKey:0,state:j,terrainData:z})}v&&T.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of T){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 s=r.uniformValues;r.hasHalo&&(s.u_is_halo=1,zd(r.buffers,e.segments,i,t,r.program,b,h,u,s,e.terrainData)),s.u_is_halo=0}zd(r.buffers,e.segments,i,t,r.program,b,h,u,r.uniformValues,e.terrainData)}}function zd(t,e,i,r,s,n,a,o,l,c){const h=r.context;s.draw(h,h.gl.TRIANGLES,n,a,o,xd.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Ed(t,e,i,r,s,n,a){const o=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,m,f;a?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=o.LINES):(p=c?"fillPattern":"fill",u=o.TRIANGLES);for(const _ of r){const r=e.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;const y=g.programConfigurations.get(i.id),x=t.useProgram(p,y),v=t.style.terrain&&t.style.terrain.getTerrainData(_);c&&(t.context.activeTexture.set(o.TEXTURE0),r.imageAtlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const b=l.constantOr(null);if(b&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const w=v?_:null,T=t.translatePosMatrix(w?w.posMatrix:_.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){m=g.indexBuffer2,f=g.segments2;const e=[o.drawingBufferWidth,o.drawingBufferHeight];d="fillOutlinePattern"===p&&c?lp(T,t,h,r,e):op(T,e)}else m=g.indexBuffer,f=g.segments,d=c?ap(T,t,h,r):np(T);x.draw(t.context,u,s,t.stencilModeForClipping(_),n,xd.disabled,d,v,i.id,g.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,y)}}function Cd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.paint.get("fill-extrusion-pattern"),h=c.constantOr(1),u=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity");for(const d of r){const r=e.getTile(d),m=r.getBucket(i);if(!m)continue;const f=t.style.terrain&&t.style.terrain.getTerrainData(d),_=m.programConfigurations.get(i.id),g=t.useProgram(h?"fillExtrusionPattern":"fillExtrusion",_);h&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.updatePaintBuffers(u));const y=c.constantOr(null);if(y&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[y.to.toString()],i=t.patternPositions[y.from.toString()];e&&i&&_.setConstantPatternPositions(e,i)}const x=t.translatePosMatrix(d.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=h?sp(x,t,v,p,d,u,r):rp(x,t,v,p);g.draw(o,o.gl.TRIANGLES,s,n,a,xd.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,_,t.style.terrain&&m.centroidVertexBuffer)}}function Pd(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.terrain&&t.style.terrain.getTerrainData(e);o.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(o,l.TRIANGLES,s,n,a,xd.disabled,((t,e,i,r)=>{const s=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let o=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:mp(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),o],u_shadow:s,u_highlight:n,u_accent:a}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function kd(t,e,i,r,s,n){const a=t.context,o=a.gl,l=e.dem;if(l&&l.data){const c=l.dim,h=l.stride,u=l.getPixels();if(a.activeTexture.set(o.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||t.getTileTexture(h),e.demTexture){const t=e.demTexture;t.update(u,{premultiply:!1}),t.bind(o.NEAREST,o.CLAMP_TO_EDGE)}else e.demTexture=new Bc(a,u,o.RGBA,{premultiply:!1}),e.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);a.activeTexture.set(o.TEXTURE0);let p=e.fbo;if(!p){const t=new Bc(a,{width:c,height:c,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),p=e.fbo=a.createFramebuffer(c,c,!0),p.colorAttachment.set(t.texture)}a.bindFramebuffer.set(p.framebuffer),a.viewport.set([0,0,c,c]),t.useProgram("hillshadePrepare").draw(a,o.TRIANGLES,r,s,n,xd.disabled,((t,e)=>{const i=e.stride,r=Da();return Ua(r,0,oa,-8192,0,0,1),Fa(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}})(e.tileID,l),null,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function Md(t,e,i,r,s,n){const a=r.paint.get("raster-fade-duration");if(!n&&a>0){const r=P.now(),n=(r-t.timeAdded)/a,o=e?(r-e.timeAdded)/a:-1,c=i.getSource(),h=s.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!e||Math.abs(e.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),p=u&&t.refreshedUponExpiration?1:l(u?n:1-o,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),e?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const Dd=new Zt(1,0,0,1),Ld=new Zt(0,1,0,1),Bd=new Zt(0,0,1,1),Rd=new Zt(1,0,1,1),Fd=new Zt(0,1,1,1);function Od(t,e,i,r){Ud(t,0,e+i/2,t.transform.width,i,r)}function Vd(t,e,i,r){Ud(t,e-i/2,0,i,t.transform.height,r)}function Ud(t,e,i,r,s,n){const a=t.context,o=a.gl;o.enable(o.SCISSOR_TEST),o.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,s*t.pixelRatio),a.clear({color:n}),o.disable(o.SCISSOR_TEST)}function Nd(t,e,i){const r=t.context,s=r.gl,n=i.posMatrix,a=t.useProgram("debug"),o=_d.disabled,l=yd.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.terrain&&t.style.terrain.getTerrainData(i);r.activeTexture.set(s.TEXTURE0),t.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const p=e.getTileByID(i.key).latestRawTileData,d=Math.floor((p&&p.byteLength||0)/1024),m=e.getTile(i).tileSize,f=512/Math.min(m,512)*(i.overscaledZ/t.transform.zoom)*.5;let _=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${d}kB`),a.draw(r,s.TRIANGLES,o,l,md.alphaBlended,xd.disabled,up(n,Zt.transparent,f),null,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),a.draw(r,s.LINE_STRIP,o,l,c,xd.disabled,up(n,Zt.red),u,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function $d(t,e,i){const r=t.context,s=r.gl,n=t.colorModeForRenderPass(),a=new _d(s.LEQUAL,_d.ReadWrite,t.depthRangeFor3D),o=t.useProgram("terrain"),l=e.getTerrainMesh(),c=e.getTerrainData(i.tileID);r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]),r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,e.getRTTFramebuffer().colorAttachment.get());const h=t.transform.calculatePosMatrix(i.tileID.toUnwrapped());o.draw(r,s.TRIANGLES,a,yd.disabled,n,xd.backCCW,{u_matrix:h,u_texture:0},c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}function qd(t,e,i,r){const s=t.context,n=i.tileSize*e.qualityFactor;i.textures[r]||(i.textures[r]=t.getTileTexture(n)||new Bc(s,{width:n,height:n,data:null},s.gl.RGBA),i.textures[r].bind(s.gl.LINEAR,s.gl.CLAMP_TO_EDGE),0===r&&e.sourceCache.renderHistory.unshift(i.tileID.key));const a=e.getRTTFramebuffer();a.colorAttachment.set(i.textures[r].texture),s.bindFramebuffer.set(a.framebuffer),s.viewport.set([0,0,n,n])}class jd{constructor(t){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=t,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=t.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const t=this.painter.style,e=t.terrain;for(const i in t.sourceCaches){this._coordsDescendingInv[i]={};const r=t.sourceCaches[i].getVisibleCoordinates();for(const t of r){const r=e.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[i][t]||(this._coordsDescendingInv[i][t]=[]),this._coordsDescendingInv[i][t].push(r[t])}}for(const e of t._order){const i=t._layers[e],r=i.source;if(this._renderToTexture[i.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}return this._renderableTiles.forEach((t=>{for(const i in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[i][t.tileID.key];r&&r!==t.textureCoords[i]&&t.clearTextures(this.painter),e.needsRerender(i,t.tileID)&&t.clearTextures(this.painter)}this._rerender[t.tileID.key]=!t.textures.length})),e.clearRerenderCache(),e.sourceCache.removeOutdated(this.painter),this}renderLayer(t){const e=t.type,i=this.painter,r=i.style._order,s=i.currentLayer,n=s+1===r.length;if(this._renderToTexture[e]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=e,this._stacks[this._stacks.length-1].push(r[s]),!n))return!0;if(this._renderToTexture[this._prevType]||"hillshade"===e||this._renderToTexture[e]&&n){this._prevType=e;const n=this._stacks.length-1,a=this._stacks[n]||[];for(const t of this._renderableTiles){if(qd(i,i.style.terrain,t,n),this._rerender[t.tileID.key]){i.context.clear({color:Zt.transparent});for(let e=0;e<a.length;e++){const r=i.style._layers[a[e]],s=r.source?this._coordsDescendingInv[r.source][t.tileID.key]:[t.tileID];i._renderTileClippingMasks(r,s),i.renderLayer(i,i.style.sourceCaches[r.source],r,s),r.source&&(t.textureCoords[r.source]=this._coordsDescendingInvStr[r.source][t.tileID.key])}}$d(i,i.style.terrain,t)}if("hillshade"===e){this._stacks.push([r[s]]);for(const e of this._renderableTiles){const r=this._coordsDescendingInv[t.source][e.tileID.key];qd(i,i.style.terrain,e,this._stacks.length-1),i.context.clear({color:Zt.transparent}),i._renderTileClippingMasks(t,r),i.renderLayer(i,i.style.sourceCaches[t.source],t,r),$d(i,i.style.terrain,e)}return!0}return this._renderToTexture[e]}return!1}}const Zd={symbol:function(t,e,i,r,s){if("translucent"!==t.renderPass)return;const n=yd.disabled,a=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,e,i,r,s,n,a){const o=e.transform,l="map"===s,c="map"===n;for(const s of t){const t=r.getTile(s),n=t.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const h=dc(n.textSizeData,o.zoom),u=_u(t,1,e.transform.zoom),p=tu(s.posMatrix,c,l,e.transform,u),d="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(h){const i=Math.pow(2,o.zoom-t.tileID.overscaledZ);Id(n,l,c,a,o,p,s.posMatrix,i,h,d,e.style.terrain?(t,i)=>e.style.terrain.getElevation(s,t,i):null)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),s),0!==i.paint.get("icon-opacity").constantOr(1)&&Ad(t,e,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,a),0!==i.paint.get("text-opacity").constantOr(1)&&Ad(t,e,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),n,a),e.map.showCollisionBoxes&&(bd(t,e,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),bd(t,e,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("circle-opacity"),n=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),o=!i.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const l=t.context,c=l.gl,h=t.depthModeForSublayer(0,_d.ReadOnly),u=yd.disabled,p=t.colorModeForRenderPass(),d=[];for(let s=0;s<r.length;s++){const n=r[s],a=e.getTile(n),l=a.getBucket(i);if(!l)continue;const c=l.programConfigurations.get(i.id),h=t.useProgram("circle",c),u=l.layoutVertexBuffer,p=l.indexBuffer,m=t.style.terrain&&t.style.terrain.getTerrainData(n),f={programConfiguration:c,program:h,layoutVertexBuffer:u,indexBuffer:p,uniformValues:cp(t,n,a,i),terrainData:m};if(o){const t=l.segments.get();for(const e of t)d.push({segments:new Pn([e]),sortKey:e.sortKey,state:f})}else d.push({segments:l.segments,sortKey:0,state:f})}o&&d.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of d){const{programConfiguration:r,program:s,layoutVertexBuffer:n,indexBuffer:a,uniformValues:o,terrainData:d}=e.state;s.draw(l,c.TRIANGLES,h,u,p,xd.disabled,o,d,i.id,n,a,e.segments,i.paint,t.transform.zoom,r)}},heatmap:function(t,e,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,n=s.gl,a=yd.disabled,o=new md([n.ONE,n.ONE],Zt.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let s=i.heatmapFbo;if(s)r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer);else{const n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),s=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,e.width/4,e.height/4,0,s.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,n,s)}}(s,t,i),s.clear({color:Zt.transparent});for(let l=0;l<r.length;l++){const c=r[l];if(e.hasRenderableParent(c))continue;const h=e.getTile(c),u=h.getBucket(i);if(!u)continue;const p=u.programConfigurations.get(i.id),d=t.useProgram("heatmap",p),{zoom:m}=t.transform;d.draw(s,n.TRIANGLES,_d.disabled,a,o,xd.disabled,dp(c.posMatrix,h,m,i.paint.get("heatmap-intensity")),null,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,t.transform.zoom,p)}s.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,e){const i=t.context,r=i.gl,s=e.heatmapFbo;if(!s)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let n=e.colorRampTexture;n||(n=e.colorRampTexture=new Bc(i,e.colorRamp,r.RGBA)),n.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,_d.disabled,yd.disabled,t.colorModeForRenderPass(),xd.disabled,((t,e,i,r)=>{const s=Da();Ua(s,0,t.width,t.height,0,0,1);const n=t.context.gl;return{u_matrix:s,u_world:[n.drawingBufferWidth,n.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}})(t,e),null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom)}(t,i))},line:function(t,e,i,r){if("translucent"!==t.renderPass)return;const s=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===s.constantOr(1)||0===n.constantOr(1))return;const a=t.depthModeForSublayer(0,_d.ReadOnly),o=t.colorModeForRenderPass(),c=i.paint.get("line-dasharray"),h=i.paint.get("line-pattern"),u=h.constantOr(1),p=i.paint.get("line-gradient"),d=i.getCrossfadeParameters(),m=u?"linePattern":c?"lineSDF":p?"lineGradient":"line",f=t.context,_=f.gl;let g=!0;for(const s of r){const r=e.getTile(s);if(u&&!r.patternsLoaded())continue;const n=r.getBucket(i);if(!n)continue;const x=n.programConfigurations.get(i.id),v=t.context.program.get(),b=t.useProgram(m,x),w=g||b.program!==v,T=t.style.terrain&&t.style.terrain.getTerrainData(s),I=h.constantOr(null);if(I&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[I.to.toString()],i=t.patternPositions[I.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const S=T?s:null,A=u?gp(t,r,i,d,S):c?yp(t,r,i,c,d,S):p?_p(t,r,i,n.lineClipsArray.length,S):fp(t,r,i,S);if(u)f.activeTexture.set(_.TEXTURE0),r.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),x.updatePaintBuffers(d);else if(c&&(w||t.lineAtlas.dirty))f.activeTexture.set(_.TEXTURE0),t.lineAtlas.bind(f);else if(p){const r=n.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let o=256;if(i.stepInterpolant){const i=e.getSource().maxzoom,r=s.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-s.canonical.z):1;o=l((y=n.maxLineLength/oa*1024*r)<=1?1:Math.pow(2,Math.ceil(Math.log(y)/Math.LN2)),256,f.maxTextureSize)}r.gradient=so({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:o,image:r.gradient||void 0,clips:n.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new Bc(f,r.gradient,_.RGBA),r.version=i.gradientVersion,a=r.texture}f.activeTexture.set(_.TEXTURE0),a.bind(i.stepInterpolant?_.NEAREST:_.LINEAR,_.CLAMP_TO_EDGE)}b.draw(f,_.TRIANGLES,a,t.stencilModeForClipping(s),o,xd.disabled,A,T,i.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,i.paint,t.transform.zoom,x,n.layoutVertexBuffer2),g=!1}var y},fill:function(t,e,i,r){const s=i.paint.get("fill-color"),n=i.paint.get("fill-opacity");if(0===n.constantOr(1))return;const a=t.colorModeForRenderPass(),o=i.paint.get("fill-pattern"),l=t.opaquePassEnabledForLayer()&&!o.constantOr(1)&&1===s.constantOr(Zt.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";if(t.renderPass===l){const s=t.depthModeForSublayer(1,"opaque"===t.renderPass?_d.ReadWrite:_d.ReadOnly);Ed(t,e,i,r,s,a,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const s=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,_d.ReadOnly);Ed(t,e,i,r,s,a,!0)}},"fill-extrusion":function(t,e,i,r){const s=i.paint.get("fill-extrusion-opacity");if(0!==s&&"translucent"===t.renderPass){const n=new _d(t.context.gl.LEQUAL,_d.ReadWrite,t.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))Cd(t,e,i,r,n,yd.disabled,md.disabled),Cd(t,e,i,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass());else{const s=t.colorModeForRenderPass();Cd(t,e,i,r,n,yd.disabled,s)}}},hillshade:function(t,e,i,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const s=t.context,n=t.depthModeForSublayer(0,_d.ReadOnly),a=t.colorModeForRenderPass(),[o,l]="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r];for(const r of l){const s=e.getTile(r);void 0!==s.needsHillshadePrepare&&s.needsHillshadePrepare&&"offscreen"===t.renderPass?kd(t,s,i,n,yd.disabled,a):"translucent"===t.renderPass&&Pd(t,r,s,i,n,o[r.overscaledZ],a)}s.viewport.set([0,0,t.width,t.height])},raster:function(t,e,i,r){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const s=t.context,n=s.gl,a=e.getSource(),o=t.useProgram("raster"),l=t.colorModeForRenderPass(),[c,h]=a instanceof gh?[{},r]:t.stencilConfigForOverlap(r),u=h[h.length-1].overscaledZ,p=!t.options.moving;for(const r of h){const h=t.depthModeForSublayer(r.overscaledZ-u,1===i.paint.get("raster-opacity")?_d.ReadWrite:_d.ReadOnly,n.LESS),d=e.getTile(r);d.registerFadeDuration(i.paint.get("raster-fade-duration"));const m=e.findLoadedParent(r,0),f=Md(d,m,e,i,t.transform,t.style.terrain);let _,g;const y="nearest"===i.paint.get("raster-resampling")?n.NEAREST:n.LINEAR;s.activeTexture.set(n.TEXTURE0),d.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),s.activeTexture.set(n.TEXTURE1),m?(m.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST),_=Math.pow(2,m.tileID.overscaledZ-d.tileID.overscaledZ),g=[d.tileID.canonical.x*_%1,d.tileID.canonical.y*_%1]):d.texture.bind(y,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST);const x=t.style.terrain&&t.style.terrain.getTerrainData(r),v=x?r:null,b=v?v.posMatrix:t.transform.calculatePosMatrix(r.toUnwrapped(),p),w=bp(b,g||[0,0],_||1,f,i);a instanceof gh?o.draw(s,n.TRIANGLES,h,yd.disabled,l,xd.disabled,w,x,i.id,a.boundsBuffer,t.quadTriangleIndexBuffer,a.boundsSegments):o.draw(s,n.TRIANGLES,h,c[r.overscaledZ],l,xd.disabled,w,x,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}},background:function(t,e,i,r){const s=i.paint.get("background-color"),n=i.paint.get("background-opacity");if(0===n)return;const a=t.context,o=a.gl,l=t.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const u=!h&&1===s.a&&1===n&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const p=yd.disabled,d=t.depthModeForSublayer(0,"opaque"===u?_d.ReadWrite:_d.ReadOnly),m=t.colorModeForRenderPass(),f=t.useProgram(h?"backgroundPattern":"background"),_=r||l.coveringTiles({tileSize:c,terrain:t.style.terrain});h&&(a.activeTexture.set(o.TEXTURE0),t.imageManager.bind(t.context));const g=i.getCrossfadeParameters();for(const e of _){const l=r?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=h?zp(l,n,t,h,{tileID:e,tileSize:c},g):Ap(l,n,s),_=t.style.terrain&&t.style.terrain.getTerrainData(e);f.draw(a,o.TRIANGLES,d,p,m,xd.disabled,u,_,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}},debug:function(t,e,i){for(let r=0;r<i.length;r++)Nd(t,e,i[r])},custom:function(t,e,i){const r=t.context,s=i.implementation;if("offscreen"===t.renderPass){const e=s.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(s,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(yd.disabled);const e="3d"===s.renderingMode?new _d(t.context.gl.LEQUAL,_d.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,_d.ReadOnly);r.setDepthMode(e),s.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class Gd{constructor(t,e){this.context=new fd(t),this.transform=e,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:Da(),renderTime:0},this.setup(),this.numSublayers=Mh.maxUnderzooming+Mh.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Nu,this.gpuTimers={}}resize(t,e,i){if(this.width=t*i,this.height=e*i,this.pixelRatio=i,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,e=new hn;e.emplaceBack(0,0),e.emplaceBack(oa,0),e.emplaceBack(0,oa),e.emplaceBack(oa,oa),this.tileExtentBuffer=t.createVertexBuffer(e,$u.members),this.tileExtentSegments=Pn.simpleSegment(0,0,4,2);const i=new hn;i.emplaceBack(0,0),i.emplaceBack(oa,0),i.emplaceBack(0,oa),i.emplaceBack(oa,oa),this.debugBuffer=t.createVertexBuffer(i,$u.members),this.debugSegments=Pn.simpleSegment(0,0,4,5);const r=new un;r.emplaceBack(0,0,0,0),r.emplaceBack(oa,0,oa,0),r.emplaceBack(0,oa,0,oa),r.emplaceBack(oa,oa,oa,oa),this.rasterBoundsBuffer=t.createVertexBuffer(r,_h.members),this.rasterBoundsSegments=Pn.simpleSegment(0,0,4,2);const s=new hn;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,$u.members),this.viewportSegments=Pn.simpleSegment(0,0,4,2);const n=new zn;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(n);const a=new Sn;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new Bc(t,{width:1,height:1,data:new Uint8Array([0,0,0,0])},t.gl.RGBA);const o=this.context.gl;this.stencilClearMode=new yd({func:o.ALWAYS,mask:0},0,255,o.ZERO,o.ZERO,o.ZERO)}clearStencil(){const t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const i=Da();Ua(i,0,this.width,this.height,0,0,1),Oa(i,i,[e.drawingBufferWidth,e.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,e.TRIANGLES,_d.disabled,this.stencilClearMode,md.disabled,xd.disabled,pp(i),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 i=this.context,r=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(md.disabled),i.setDepthMode(_d.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,n=this.style.terrain&&this.style.terrain.getTerrainData(t);s.draw(i,r.TRIANGLES,_d.disabled,new yd({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),md.disabled,xd.disabled,pp(t.posMatrix),n,"$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 yd({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new yd({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i<s;i++)t[i+r]=new yd({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=s,[t,i]}return[{[r]:yd.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const e=1/8;return new md([t.CONSTANT_COLOR,t.ONE],new Zt(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?md.unblended:md.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return _d.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new _d(i||this.context.gl.LEQUAL,e,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,e){this.style=t,this.options=e,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(P.now()),this.imageManager.beginFrame();const i=this.style._order,r=this.style.sourceCaches,s=this.style.terrain&&new jd(this);for(const t in r){const e=r[t];e.used&&e.prepare(this.context)}const n={},a={},o={};for(const t in r){const e=r[t];n[t]=e.getVisibleCoordinates(),a[t]=n[t].slice().reverse(),o[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}if(s){this.opaquePassCutoff=0;const t=this.style.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);!this.terrainFacilitator.dirty&&(h=(l=this.terrainFacilitator.matrix)[0],u=l[1],p=l[2],d=l[3],m=l[4],f=l[5],_=l[6],g=l[7],y=l[8],x=l[9],v=l[10],b=l[11],w=l[12],T=l[13],I=l[14],S=l[15],A=(c=this.transform.projMatrix)[0],z=c[1],E=c[2],C=c[3],k=c[4],M=c[5],D=c[6],L=c[7],B=c[8],R=c[9],F=c[10],O=c[11],V=c[12],U=c[13],N=c[14],$=c[15],Math.abs(h-A)<=Pa*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(u-z)<=Pa*Math.max(1,Math.abs(u),Math.abs(z))&&Math.abs(p-E)<=Pa*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(d-C)<=Pa*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(m-k)<=Pa*Math.max(1,Math.abs(m),Math.abs(k))&&Math.abs(f-M)<=Pa*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(_-D)<=Pa*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-L)<=Pa*Math.max(1,Math.abs(g),Math.abs(L))&&Math.abs(y-B)<=Pa*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(x-R)<=Pa*Math.max(1,Math.abs(x),Math.abs(R))&&Math.abs(v-F)<=Pa*Math.max(1,Math.abs(v),Math.abs(F))&&Math.abs(b-O)<=Pa*Math.max(1,Math.abs(b),Math.abs(O))&&Math.abs(w-V)<=Pa*Math.max(1,Math.abs(w),Math.abs(V))&&Math.abs(T-U)<=Pa*Math.max(1,Math.abs(T),Math.abs(U))&&Math.abs(I-N)<=Pa*Math.max(1,Math.abs(I),Math.abs(N))&&Math.abs(S-$)<=Pa*Math.max(1,Math.abs(S),Math.abs($)))&&!t.length||(function(t,e){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]}(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,e){const i=t.context,r=i.gl,s=md.unblended,n=new _d(r.LEQUAL,_d.ReadWrite,[0,1]),a=e.getTerrainMesh(),o=e.sourceCache.getRenderableTiles(),l=t.useProgram("terrainDepth");i.bindFramebuffer.set(e.getFramebuffer("depth").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:Zt.transparent,depth:1});for(const c of o){const o=e.getTerrainData(c.tileID),h=t.transform.calculatePosMatrix(c.tileID.toUnwrapped());l.draw(i,r.TRIANGLES,n,yd.disabled,s,xd.backCCW,{u_matrix:h},o,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}(this,this.style.terrain),function(t,e){const i=t.context,r=i.gl,s=md.unblended,n=new _d(r.LEQUAL,_d.ReadWrite,[0,1]),a=e.getTerrainMesh(),o=e.getCoordsTexture(),l=e.sourceCache.getRenderableTiles(),c=t.useProgram("terrainCoords");i.bindFramebuffer.set(e.getFramebuffer("coords").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:Zt.transparent,depth:1}),e.coordsIndex=[];for(const h of l){const l=e.getTerrainData(h.tileID);i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.texture);const u=t.transform.calculatePosMatrix(h.tileID.toUnwrapped());c.draw(i,r.TRIANGLES,n,yd.disabled,s,xd.backCCW,{u_matrix:u,u_terrain_coords_id:(255-e.coordsIndex.length)/255,u_texture:0},l,"terrain",a.vertexBuffer,a.indexBuffer,a.segments),e.coordsIndex.push(h.tileID.key)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}(this,this.style.terrain))}var l,c,h,u,p,d,m,f,_,g,y,x,v,b,w,T,I,S,A,z,E,C,k,M,D,L,B,R,F,O,V,U,N,$;this.renderPass="offscreen";for(const t of i){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=a[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,r[e.source],e,i)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:e.showOverdrawInspector?Zt.black:Zt.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=e.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!s)for(this.renderPass="opaque",this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[i[this.currentLayer]],e=r[t.source],s=n[t.source];this._renderTileClippingMasks(t,s),this.renderLayer(this,e,t,s)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const t=this.style._layers[i[this.currentLayer]],e=r[t.source];if(s&&s.renderLayer(t))continue;const l=("symbol"===t.type?o:a)[t.source];this._renderTileClippingMasks(t,n[t.source]),this.renderLayer(this,e,t,l)}if(this.options.showTileBoundaries){let t,e;Object.values(this.style._layers).forEach((i=>{i.source&&!i.isHidden(this.transform.zoom)&&(i.source!==(e&&e.id)&&(e=this.style.sourceCaches[i.source]),(!t||t.getSource().maxzoom<e.getSource().maxzoom)&&(t=e))})),t&&Zd.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;Od(t,t.transform.height-(e.top||0),3,Dd),Od(t,e.bottom||0,3,Ld),Vd(t,e.left||0,3,Bd),Vd(t,t.transform.width-(e.right||0),3,Rd);const i=t.transform.centerPoint;!function(t,e,i,r){Ud(t,e-1,i-10,2,20,r),Ud(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,Fd)}(this),this.context.setDefault()}renderLayer(t,e,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"custom"===i.type||(r||[]).length)&&(this.id=i.id,this.gpuTimingStart(i),Zd[i.type](t,e,i,r,this.style.placement.variableOffsets),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],s=this.context.extTimerQuery,n=s.getQueryObjectEXT(r.query,s.QUERY_RESULT_EXT)/1e6;s.deleteQueryEXT(r.query),e[i]=n}return e}translatePosMatrix(t,e,i,r,s){if(!i[0]&&!i[1])return t;const n=s?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(n){const t=Math.sin(n),e=Math.cos(n);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}const a=[s?i[0]:_u(e,i[0],this.transform.zoom),s?i[1]:_u(e,i[1],this.transform.zoom),0],o=new Float32Array(16);return Fa(o,t,a),o}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()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new ep(this.context,t,Yu[t],e,Ep[t],this._showOverdrawInspector,this.style.terrain)),this.cache[i]}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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Bc(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class Xd{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i){const r=Math.pow(2,i),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const s=1/(i=Xa([],i,t))[3]/e*r;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(i,i,[s,s,1/i[3],s])})),n=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}([],function(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}([],Ga([],s[t[0]],s[t[1]]),Ga([],s[t[2]],s[t[1]]))),i=-((r=e)[0]*(n=s[t[1]])[0]+r[1]*n[1]+r[2]*n[2]);var r,n;return e.concat(i)}));return new Xd(s,n)}}class Wd{constructor(t,e){var i,r,s;this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],((i=[])[0]=(r=this.min)[0]+(s=this.max)[0],i[1]=r[1]+s[1],i[2]=r[2]+s[2],i))}quadrant(t){const e=[t%2==0,t<2],i=qa(this.min),r=qa(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],r[t]=e[t]?this.center[t]:this.max[t];return r[2]=this.max[2],new Wd(i,r)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){const e=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let i=!0;for(let n=0;n<t.planes.length;n++){const a=t.planes[n];let o=0;for(let t=0;t<e.length;t++)(r=a)[0]*(s=e[t])[0]+r[1]*s[1]+r[2]*s[2]+r[3]*s[3]>=0&&o++;if(0===o)return 0;o!==e.length&&(i=!1)}var r,s;if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let s=0;s<t.points.length;s++){const n=t.points[s][e]-this.min[e];i=Math.min(i,n),r=Math.max(r,n)}if(r<0||i>this.max[e]-this.min[e])return 0}return 1}}class Hd{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<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=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=Re(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=Re(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=Re(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=Re(t.right,e.right,i)),this}getCenter(t,e){const i=l((this.left+t-this.right)/2,0,t),r=l((this.top+e-this.bottom)/2,0,e);return new k(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Hd(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class Kd{constructor(t,e,i,r,s){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=void 0===s||!!s,this._minZoom=t||0,this._maxZoom=e||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setMaxBounds(),this.width=0,this.height=0,this._center=new Kc(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Hd,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new Kd(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}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 k(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const e=-c(t,-180,180)*Math.PI/180;var i;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=(i=new ka(4),ka!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*o,t[1]=s*l+a*o,t[2]=r*-o+n*l,t[3]=s*-o+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const e=l(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,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.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,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,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),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 e=[new uh(0,t)];if(this._renderWorldCopies){const i=this.pointCoordinate(new k(0,0)),r=this.pointCoordinate(new k(this.width,0)),s=this.pointCoordinate(new k(this.width,this.height)),n=this.pointCoordinate(new k(0,this.height)),a=Math.floor(Math.min(i.x,r.x,s.x,n.x)),o=Math.floor(Math.max(i.x,r.x,s.x,n.x)),l=1;for(let i=a-l;i<=o+l;i++)0!==i&&e.push(new uh(i,t))}return e}coveringTiles(t){var e,i;let r=this.coveringZoomLevel(t);const s=r;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);const n=this.pointCoordinate(this.getCameraPoint()),a=sh.fromLngLat(this.center),o=Math.pow(2,r),l=[o*n.x,o*n.y,0],c=[o*a.x,o*a.y,0],h=Xd.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r);let u=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(u=r);const p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,d=t=>({aabb:new Wd([t*o,0,0],[(t+1)*o,o,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],f=[],_=r,g=t.reparseOverscaled?s:r;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 r=m.pop(),s=r.x,n=r.y;let a=r.fullyVisible;if(!a){const t=r.aabb.intersects(h);if(0===t)continue;a=2===t}const o=t.terrain?l:c,d=r.aabb.distanceX(o),y=r.aabb.distanceY(o),x=Math.max(Math.abs(d),Math.abs(y)),v=p+(1<<_-r.zoom)-2;if(r.zoom===_||x>v&&r.zoom>=u){const t=_-r.zoom,e=l[0]-.5-(s<<t),i=l[1]-.5-(n<<t);f.push({tileID:new ph(r.zoom===_?g:r.zoom,r.wrap,r.zoom,s,n),distanceSq:Ha([c[0]-.5-s,c[1]-.5-n]),tileDistanceToCamera:Math.sqrt(e*e+i*i)})}else for(let o=0;o<4;o++){const l=(s<<1)+o%2,c=(n<<1)+(o>>1),h=r.zoom+1;let u=r.aabb.quadrant(o);if(t.terrain){const s=new ph(h,r.wrap,h,l,c),n=t.terrain.getMinMaxElevation(s),a=null!==(e=n.minElevation)&&void 0!==e?e:this.elevation,o=null!==(i=n.maxElevation)&&void 0!==i?i:this.elevation;u=new Wd([u.min[0],u.min[1],a],[u.max[0],u.max[1],o])}m.push({aabb:u,zoom:h,x:l,y:c,wrap:r.wrap,fullyVisible:a})}}return f.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 e=l(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new k(th(t.lng)*this.worldSize,eh(e)*this.worldSize)}unproject(t){return new sh(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(t,e){const i=sh.fromLngLat(t),r=(1<<this.tileZoom)*oa,s=i.x*r,n=i.y*r,a=Math.floor(s/oa),o=Math.floor(n/oa),l=new ph(this.tileZoom,0,this.tileZoom,a,o);return e.getElevation(l,s%oa,n%oa,oa)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const e=this.pointLocation(this.centerPoint,t),i=this.getElevation(e,t);if(!(this.elevation-i))return;const r=this.getCameraPosition(),s=sh.fromLngLat(r.lngLat,r.altitude),n=sh.fromLngLat(e,i),a=s.x-n.x,o=s.y-n.y,l=s.z-n.z,c=Math.sqrt(a*a+o*o+l*l),h=this.scaleZoom(this.cameraToCenterDistance/c/this.tileSize);this._elevation=i,this._center=e,this.zoom=h}setLocationAtPoint(t,e){const i=this.pointCoordinate(e),r=this.pointCoordinate(this.centerPoint),s=this.locationCoordinate(t),n=new sh(s.x-(i.x-r.x),s.y-(i.y-r.y));this.center=this.coordinateLocation(n),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),this.getElevation(t,e),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return sh.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];Xa(i,i,this.pixelMatrixInverse),Xa(r,r,this.pixelMatrixInverse);const s=i[3],n=r[3],a=i[1]/s,o=r[1]/n,l=i[2]/s,c=r[2]/n,h=l===c?0:(0-l)/(c-l);return new sh(Re(i[0]/s,r[0]/n,h)/this.worldSize,Re(a,o,h)/this.worldSize)}coordinatePoint(t,e=0,i=this.pixelMatrix){const r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return Xa(r,r,i),new k(r[0]/r[3],r[1]/r[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new Yc).extend(this.pointLocation(new k(0,t))).extend(this.pointLocation(new k(this.width,t))).extend(this.pointLocation(new k(this.width,this.height))).extend(this.pointLocation(new k(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new Yc([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=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,e=!1){const i=t.key,r=e?this._alignedPosMatrixCache:this._posMatrixCache;if(r[i])return r[i];const s=t.canonical,n=this.worldSize/this.zoomScale(s.z),a=s.x+Math.pow(2,s.z)*t.wrap,o=La(new Float64Array(16));return Fa(o,o,[a*n,s.y*n,0]),Oa(o,o,[n/oa,n/oa,1]),Ra(o,e?this.alignedProjMatrix:this.projMatrix,o),r[i]=new Float32Array(o),r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,e,i,r,s=-90,n=90,a=-180,o=180;const l=this.size,h=this._unmodified;if(this.latRange){const e=this.latRange;s=eh(e[1])*this.worldSize,n=eh(e[0])*this.worldSize,t=n-s<l.y?l.y/(n-s):0}if(this.lngRange){const t=this.lngRange;a=c(th(t[0])*this.worldSize,0,this.worldSize),o=c(th(t[1])*this.worldSize,0,this.worldSize),o<a&&(o+=this.worldSize),e=o-a<l.x?l.x/(o-a):0}const u=this.point,p=Math.max(e||0,t||0);if(p)return this.center=this.unproject(new k(e?(o+a)/2:u.x,t?(n+s)/2:u.y)),this.zoom+=this.scaleZoom(p),this._unmodified=h,void(this._constraining=!1);if(this.latRange){const t=u.y,e=l.y/2;t-e<s&&(r=s+e),t+e>n&&(r=n-e)}if(this.lngRange){const t=(a+o)/2,e=c(u.x,t-this.worldSize/2,t+this.worldSize/2),r=l.x/2;e-r<a&&(i=a+r),e+r>o&&(i=o-r)}void 0===i&&void 0===r||(this.center=this.unproject(new k(void 0!==i?i:u.x,void 0!==r?r:u.y)).wrap()),this._unmodified=h,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,e=this.point.x,i=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=ih(1,this.center.lat)*this.worldSize;let r=La(new Float64Array(16));Oa(r,r,[this.width/2,-this.height/2,1]),Fa(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=La(new Float64Array(16)),Oa(r,r,[1,-1,1]),Fa(r,r,[-1,-1,0]),Oa(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const s=Math.PI/2+this._pitch,n=this._fov*(.5+t.y/this.height),a=Math.sin(n)*this.cameraToSeaLevelDistance/Math.sin(l(Math.PI-s-n,.01,Math.PI-.01)),o=this.getHorizon(),c=2*Math.atan(o/this.cameraToCenterDistance)*(.5+t.y/(2*o)),h=Math.sin(c)*this.cameraToSeaLevelDistance/Math.sin(l(Math.PI-s-c,.01,Math.PI-.01)),u=Math.cos(Math.PI/2-this._pitch)*a+this.cameraToSeaLevelDistance,p=Math.cos(Math.PI/2-this._pitch)*h+this.cameraToSeaLevelDistance,d=1.01*Math.min(u,p),m=this.height/50;var f,_,g,y,x,v,b,w,T,I,S,A,z;r=new Float64Array(16),function(t,e,i,r,s){var n,a=1/Math.tan(e/2);t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0?(t[10]=(s+r)*(n=1/(r-s)),t[14]=2*s*r*n):(t[10]=-1,t[14]=-2*r)}(r,this._fov,this.width/this.height,m,d),r[8]=2*-t.x/this.width,r[9]=2*t.y/this.height,Oa(r,r,[1,-1,1]),Fa(r,r,[0,0,-this.cameraToCenterDistance]),f=r,_=r,g=this._pitch,y=Math.sin(g),x=Math.cos(g),v=_[4],b=_[5],w=_[6],T=_[7],I=_[8],S=_[9],A=_[10],z=_[11],_!==f&&(f[0]=_[0],f[1]=_[1],f[2]=_[2],f[3]=_[3],f[12]=_[12],f[13]=_[13],f[14]=_[14],f[15]=_[15]),f[4]=v*x+I*y,f[5]=b*x+S*y,f[6]=w*x+A*y,f[7]=T*x+z*y,f[8]=I*x-v*y,f[9]=S*x-b*y,f[10]=A*x-w*y,f[11]=z*x-T*y,Va(r,r,this.angle),Fa(r,r,[-e,-i,0]),this.mercatorMatrix=Oa([],r,[this.worldSize,this.worldSize,this.worldSize]),Oa(r,r,[1,1,this._pixelPerMeter]),this.pixelMatrix=Ra(new Float64Array(16),this.labelPlaneMatrix,r),Fa(r,r,[0,0,-this.elevation]),this.projMatrix=r,this.invProjMatrix=Ba([],r),this.pixelMatrix3D=Ra(new Float64Array(16),this.labelPlaneMatrix,r);const E=this.width%2/2,C=this.height%2/2,P=Math.cos(this.angle),k=Math.sin(this.angle),M=e-Math.round(e)+P*E+k*C,D=i-Math.round(i)+P*C+k*E,L=new Float64Array(r);if(Fa(L,L,[M>.5?M-1:M,D>.5?D-1:D,0]),this.alignedProjMatrix=L,r=Ba(new Float64Array(16),this.pixelMatrix),!r)throw new Error("failed to invert matrix");this.pixelMatrixInverse=r,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new k(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Xa(e,e,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new k(0,t))}getCameraQueryGeometry(t){const e=this.getCameraPoint();if(1===t.length)return[t[0],e];{let i=e.x,r=e.y,s=e.x,n=e.y;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),n=Math.max(n,e.y);return[new k(i,r),new k(s,r),new k(s,n),new k(i,n),new k(i,r)]}}}class Yd{constructor(t){this._hashName=t&&encodeURIComponent(t),f(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(t,e){let i=!1,r=null;const s=()=>{r=null,i&&(t(),r=setTimeout(s,300),i=!1)};return()=>(i=!0,r||s(),r)}(this._updateHashUnthrottled.bind(this))}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()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),n=Math.round(e.lng*s)/s,a=Math.round(e.lat*s)/s,o=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${n}/${a}/${i}`:`${i}/${a}/${n}`,(o||l)&&(c+="/"+Math.round(10*o)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_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("/")}_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}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}}}const Jd={linearity:.3,easing:a(0,0,.3,1)},Qd=u({deceleration:2500,maxSpeed:1400},Jd),tm=u({deceleration:20,maxSpeed:1400},Jd),em=u({deceleration:1e3,maxSpeed:360},Jd),im=u({deceleration:1e3,maxSpeed:90},Jd);class rm{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:P.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=P.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const e={zoom:0,bearing:0,pitch:0,pan:new k(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){const s=nm(e.pan.mag(),i,u({},Qd,t||{}));r.offset=e.pan.mult(s.amount/e.pan.mag()),r.center=this._map.transform.center,sm(r,s)}if(e.zoom){const t=nm(e.zoom,i,tm);r.zoom=this._map.transform.zoom+t.amount,sm(r,t)}if(e.bearing){const t=nm(e.bearing,i,em);r.bearing=this._map.transform.bearing+l(t.amount,-179,179),sm(r,t)}if(e.pitch){const t=nm(e.pitch,i,im);r.pitch=this._map.transform.pitch+t.amount,sm(r,t)}if(r.zoom||r.bearing){const t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),u(r,{noMoveStart:!0})}}function sm(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function nm(t,e,i){const{maxSpeed:r,linearity:s,deceleration:n}=i,a=l(t*s/(e/1e3),-r,r),o=Math.abs(a)/(n*s);return{easing:i.easing,duration:1e3*o,amount:a*(o/2)}}class am extends ut{constructor(t,e,i,r={}){const s=D.mousePos(e.getCanvasContainer(),i);super(t,u({point:s,lngLat:e.unproject(s),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class om extends ut{constructor(t,e,i){const r="touchend"===t?i.changedTouches:i.touches,s=D.touchPos(e.getCanvasContainer(),r),n=s.map((t=>e.unproject(t))),a=s.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new k(0,0));super(t,{points:s,point:a,lngLats:n,lngLat:e.unproject(a),originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class lm extends ut{constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class cm{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new lm(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new am(t.type,this._map,t))}mouseup(t){this._map.fire(new am(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new am(t.type,this._map,t))}dblclick(t){return this._firePreventable(new am(t.type,this._map,t))}mouseover(t){this._map.fire(new am(t.type,this._map,t))}mouseout(t){this._map.fire(new am(t.type,this._map,t))}touchstart(t){return this._firePreventable(new om(t.type,this._map,t))}touchmove(t){this._map.fire(new om(t.type,this._map,t))}touchend(t){this._map.fire(new om(t.type,this._map,t))}touchcancel(t){this._map.fire(new om(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hm{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(t){this._map.fire(new am(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new am("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new am(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class um{constructor(t,e){this._map=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&&(D.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=D.create("div","maplibregl-boxzoom mapboxgl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair","mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const s=Math.min(r.x,i.x),n=Math.max(r.x,i.x),a=Math.min(r.y,i.y),o=Math.max(r.y,i.y);D.setTransform(this._box,`translate(${s}px,${a}px)`),this._box.style.width=n-s+"px",this._box.style.height=o-a+"px"}mouseupWindow(t,e){if(!this._active)return;if(0!==t.button)return;const i=this._startPos,r=e;if(this.reset(),D.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new ut("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._map.getBearing(),{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","mapboxgl-crosshair"),this._box&&(D.remove(this._box),this._box=null),D.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new ut(t,{originalEvent:e}))}}function pm(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class dm{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const e=new k(0,0);for(const i of t)e._add(i);return e.div(t.length)}(e),this.touches=pm(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=pm(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class mm{constructor(t){this.singleTap=new dm(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class fm{constructor(){this._zoomIn=new mm({numTouches:1,numTaps:2}),this._zoomOut=new mm({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(s)},{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}}const _m={0:1,2:2};class gm{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=D.mouseButton(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),function(t,e){const i=_m[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&D.mouseButton(t)===this._eventButton&&(this._moved&&D.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ym extends gm{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class xm extends gm{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class vm extends gm{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class bm{constructor(t,e){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new k(0,0),setTimeout((()=>{this._cancelCooperativeMessage=!1}),200)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._map._cooperativeGestures&&(2===this._minTouches&&i.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,i.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(i.length<this._minTouches))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);const r=pm(i,e),s=new k(0,0),n=new k(0,0);let a=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(s._add(e),n._add(e.sub(i)),a++,r[t]=e)}if(this._touches=r,a<this._minTouches||!n.mag())return;const o=n.div(a);return this._sum._add(o),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(a),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wm{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,s]=this._firstTwoTouches,n=Tm(i,e,r),a=Tm(i,e,s);if(!n||!a)return;const o=this._aroundCenter?null:n.add(a).div(2);return this._move([n,a],o,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,s]=this._firstTwoTouches,n=Tm(i,e,r),a=Tm(i,e,s);n&&a||(this._active&&D.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Tm(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Im(t,e){return Math.log(t/e)/Math.LN2}class Sm extends wm{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Im(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Im(this._distance,i),pinchAround:e}}}function Am(t,e){return 180*t.angleWith(e)/Math.PI}class zm extends wm{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Am(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Am(t,this._startVector);return Math.abs(i)<e}}function Em(t){return Math.abs(t.y)>Math.abs(t.x)}class Cm extends wm{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Em(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,s=e.mag()>=2;if(!r&&!s)return;if(!r||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return Em(t)&&Em(e)&&n}}const Pm={panStep:100,bearingStep:15,pitchStep:10};class km{constructor(){const t=Pm;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,s=0,n=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?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const o=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Mm,zoom:e?Math.round(o)+e*(t.shiftKey?2:1):o,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-s*this._panStep,-n*this._panStep],center:a.getCenter()},{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 Mm(t){return t*(2-t)}const Dm=4.000244140625;class Lm{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._handler=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,f(["_onTimeout"],this)}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)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;t.preventDefault()}let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=P.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Dm==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*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()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_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 e=D.mousePos(this._el,t);this._around=Kc.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(e)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Dm?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const e="number"==typeof this._targetZoom?this._targetZoom:t.zoom,i=this._startZoom,r=this._easing;let s,n=!1;if("wheel"===this._type&&i&&r){const t=Math.min((P.now()-this._lastWheelEventTime)/200,1);s=Re(i,e,r(t)),t<1?this._frameId||(this._frameId=!0):n=!0}else s=e,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!n,zoomDelta:s-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=o;if(this._prevEase){const t=this._prevEase,i=(P.now()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),s=.27/Math.sqrt(r*r+1e-4)*.01;e=a(s,Math.sqrt(.0729-s*s),.25,1)}return this._prevEase={start:P.now(),duration:t,easing:e},e}reset(){this._active=!1}}class Bm{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 Rm{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fm{constructor(){this._tap=new mm({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],s=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Om{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Vm{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}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 Um{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,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","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-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()}}const Nm=t=>t.zoom||t.drag||t.pitch||t.rotate;class $m extends ut{}function qm(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class jm{constructor(t,e){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new rm(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e),f(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)D.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)D.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new cm(e,t));const r=e.boxZoom=new um(e,t);this._add("boxZoom",r);const s=new fm,n=new Rm;e.doubleClickZoom=new Bm(n,s),this._add("tapZoom",s),this._add("clickZoom",n);const a=new Fm;this._add("tapDragZoom",a);const o=e.touchPitch=new Cm(e);this._add("touchPitch",o);const l=new xm(t),c=new vm(t);e.dragRotate=new Vm(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new ym(t),u=new bm(t,e);e.dragPan=new Om(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new zm,d=new Sm;e.touchZoomRotate=new Um(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]);const m=e.scrollZoom=new Lm(e,this);this._add("scrollZoom",m,["mousePan"]);const f=e.keyboard=new km;this._add("keyboard",f),this._add("blockableMapEvent",new hm(e));for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),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(Nm(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},s={},n={},a=t.touches,o=a?this._getMapTouches(a):void 0,l=o?D.touchPos(this._el,o):D.mousePos(this._el,t);for(const{handlerName:a,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(n,h,a)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,o),this.mergeHandlerResult(r,s,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(n[a]=c)}const c={};for(const t in this._previousActiveHandlers)n[t]||(c[t]=i);this._previousActiveHandlers=n,(Object.keys(c).length||qm(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(n).length||qm(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,e,i,r,s){if(!i)return;u(t,i);const n={handlerName:r,originalEvent:i.originalEvent||s};void 0!==i.zoomDelta&&(e.zoom=n),void 0!==i.panDelta&&(e.drag=n),void 0!==i.pitchDelta&&(e.pitch=n),void 0!==i.bearingDelta&&(e.rotate=n)}_applyChanges(){const t={},e={},i={};for(const[r,s,n]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new k(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),u(e,s),u(i,n);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,s=r.transform,n=r.style&&r.style.terrain;if(!(qm(t)||n&&this._drag))return this._fireEvents(e,i,!0);let{panDelta:a,zoomDelta:o,bearingDelta:l,pitchDelta:c,around:h,pinchAround:u}=t;void 0!==u&&(h=u),r._stop(!0),h=h||r.transform.centerPoint;const p=s.pointLocation(a?h.sub(a):h);l&&(s.bearing+=l),c&&(s.pitch+=c),o&&(s.zoom+=o),n?e.drag&&!this._drag?(this._drag={center:s.centerPoint,lngLat:s.pointLocation(h),point:h,handlerName:e.drag.handlerName},r.fire(new ut("freezeElevation",{freeze:!0}))):this._drag&&i[this._drag.handlerName]?(r.fire(new ut("freezeElevation",{freeze:!1})),this._drag=null):e.drag&&this._drag&&(s.center=s.pointLocation(s.centerPoint.sub(a))):s.setLocationAtPoint(p,h),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,e,i){const r=Nm(this._eventsInProgress),s=Nm(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const t in n)this._fireEvent(t,n[t]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let o;for(const t in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],o=e[i]||r,a[`${t}end`]=o)}for(const t in a)this._fireEvent(t,a[t]);const l=Nm(this._eventsInProgress);if(i&&(r||s)&&!l){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t?(e(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:o})):(this._map.fire(new ut("moveend",{originalEvent:o})),e(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,e){this._map.fire(new ut(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new $m("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Zm={extend:(t,...e)=>u(t,...e),run(t){t()},logToElement(t,e=!1,i="log"){const r=window.document.getElementById(i);r&&(e&&(r.innerHTML=""),r.innerHTML+=`<br>${t}`)}};class Gm extends dt{constructor(t,e){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,f(["_renderFrameCallback"],this)}getCenter(){return new Kc(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,e,i){return t=k.convert(t).mult(-1),this.panTo(this.transform.center,u({offset:t},e),i)}panTo(t,e,i){return this.easeTo(u({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(u({zoom:t},e),i)}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,e,i){return this.easeTo(u({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,u({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(u({bearing:0,pitch:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=Yc.convert(t);const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,e,i,r){const s={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=u({padding:s,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){const t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}r.padding=u(s,r.padding);const n=this.transform,a=n.padding,o=n.project(Kc.convert(t)),l=n.project(Kc.convert(e)),c=o.rotate(-i*Math.PI/180),h=l.rotate(-i*Math.PI/180),p=new k(Math.max(c.x,h.x),Math.max(c.y,h.y)),d=new k(Math.min(c.x,h.x),Math.min(c.y,h.y)),m=p.sub(d),f=(n.width-(a.left+a.right+r.padding.left+r.padding.right))/m.x,_=(n.height-(a.top+a.bottom+r.padding.top+r.padding.bottom))/m.y;if(_<0||f<0)return void v("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const g=Math.min(n.scaleZoom(n.scale*Math.min(f,_)),r.maxZoom),y=k.convert(r.offset),x=new k((r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2).rotate(i*Math.PI/180),b=y.add(x).mult(n.scale/n.zoomScale(g));return{center:n.unproject(o.add(l).div(2).sub(b)),zoom:g,bearing:i}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,e,i,r,s){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(k.convert(t)),this.transform.pointLocation(k.convert(e)),i,r),r,s)}_fitInternal(t,e,i){return t?(delete(e=u(t,e)).padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop();const i=this.transform;let r=!1,s=!1,n=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(r=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=Kc.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(s=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(n=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),this.fire(new ut("movestart",e)).fire(new ut("move",e)),r&&this.fire(new ut("zoomstart",e)).fire(new ut("zoom",e)).fire(new ut("zoomend",e)),s&&this.fire(new ut("rotatestart",e)).fire(new ut("rotate",e)).fire(new ut("rotateend",e)),n&&this.fire(new ut("pitchstart",e)).fire(new ut("pitch",e)).fire(new ut("pitchend",e)),this.fire(new ut("moveend",e))}easeTo(t,e){this._stop(!1,t.easeId),(!1===(t=u({offset:[0,0],duration:500,easing:o},t)).animate||!t.essential&&P.prefersReducedMotion)&&(t.duration=0);const i=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:n,p="padding"in t?t.padding:i.padding,d=k.convert(t.offset);let m=i.centerPoint.add(d);const f=i.pointLocation(m),_=Kc.convert(t.center||f);this._normalizeCenter(_);const g=i.project(f),y=i.project(_).sub(g),x=i.zoomScale(l-r);let v,b;t.around&&(v=Kc.convert(t.around),b=i.locationPoint(v));const w={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||l!==r,this._rotating=this._rotating||s!==c,this._pitching=this._pitching||h!==n,this._padding=!i.isPaddingEqual(p),this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,w),this._ease((t=>{if(this._zooming&&(i.zoom=Re(r,l,t)),this._rotating&&(i.bearing=Re(s,c,t)),this._pitching&&(i.pitch=Re(n,h,t)),this._padding&&(i.interpolatePadding(a,p,t),m=i.centerPoint.add(d)),v)i.setLocationAtPoint(v,b);else{const e=i.zoomScale(i.zoom-r),s=l>r?Math.min(2,x):Math.max(.5,x),n=Math.pow(s,1-t),a=i.unproject(g.add(y.mult(t*n)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,m)}this._fireMoveEvents(e)}),(t=>{this._afterEase(e,t)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,this.fire(new ut("freezeElevation",{freeze:!0})),e||i.moving||this.fire(new ut("movestart",t)),this._zooming&&!i.zooming&&this.fire(new ut("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new ut("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new ut("pitchstart",t))}_fireMoveEvents(t){this.fire(new ut("move",t)),this._zooming&&this.fire(new ut("zoom",t)),this._rotating&&this.fire(new ut("rotate",t)),this._pitching&&this.fire(new ut("pitch",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)return;delete this._easeId,this.fire(new ut("freezeElevation",{freeze:!1}));const i=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new ut("zoomend",t)),r&&this.fire(new ut("rotateend",t)),s&&this.fire(new ut("pitchend",t)),this.fire(new ut("moveend",t))}flyTo(t,e){if(!t.essential&&P.prefersReducedMotion){const i=p(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,e)}this.stop(),t=u({offset:[0,0],speed:1.2,curve:1.42,easing:o},t);const i=this.transform,r=this.getZoom(),s=this.getBearing(),n=this.getPitch(),a=this.getPadding(),c="zoom"in t?l(+t.zoom,i.minZoom,i.maxZoom):r,h="bearing"in t?this._normalizeBearing(t.bearing,s):s,d="pitch"in t?+t.pitch:n,m="padding"in t?t.padding:i.padding,f=i.zoomScale(c-r),_=k.convert(t.offset);let g=i.centerPoint.add(_);const y=i.pointLocation(g),x=Kc.convert(t.center||y);this._normalizeCenter(x);const v=i.project(y),b=i.project(x).sub(v);let w=t.curve;const T=Math.max(i.width,i.height),I=T/f,S=b.mag();if("minZoom"in t){const e=l(Math.min(t.minZoom,r,c),i.minZoom,i.maxZoom),s=T/i.zoomScale(e-r);w=Math.sqrt(s/S*2)}const A=w*w;function z(t){const e=(I*I-T*T+(t?-1:1)*A*A*S*S)/(2*(t?I:T)*A*S);return Math.log(Math.sqrt(e*e+1)-e)}function E(t){return(Math.exp(t)-Math.exp(-t))/2}function C(t){return(Math.exp(t)+Math.exp(-t))/2}const M=z(0);let D=function(t){return C(M)/C(M+w*t)},L=function(t){return T*((C(M)*(E(e=M+w*t)/C(e))-E(M))/A)/S;var e},B=(z(1)-M)/w;if(Math.abs(S)<1e-6||!isFinite(B)){if(Math.abs(T-I)<1e-6)return this.easeTo(t,e);const i=I<T?-1:1;B=Math.abs(Math.log(I/T))/w,L=function(){return 0},D=function(t){return Math.exp(i*w*t)}}return t.duration="duration"in t?+t.duration:1e3*B/("screenSpeed"in t?+t.screenSpeed/w:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==h,this._pitching=d!==n,this._padding=!i.isPaddingEqual(m),this._prepareEase(e,!1),this._ease((t=>{const o=t*B,l=1/D(o);i.zoom=1===t?c:r+i.scaleZoom(l),this._rotating&&(i.bearing=Re(s,h,t)),this._pitching&&(i.pitch=Re(n,d,t)),this._padding&&(i.interpolatePadding(a,m,t),g=i.centerPoint.add(_));const u=1===t?x:i.unproject(v.add(b.mult(L(o))).mult(l));i.setLocationAtPoint(i.renderWorldCopies?u.wrap():u,g),this._fireMoveEvents(e)}),(()=>this._afterEase(e)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){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)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=P.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((P.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,e){t=c(t,-180,180);const i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}}class Xm{constructor(t={}){this.options=t,f(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=D.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=D.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=D.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){D.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",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 i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_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","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||this._updateAttributions()}_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 i in e){const r=e[i];if(r.used){const e=r.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,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._editLink=null)}_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","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class Wm{constructor(t={}){this.options=t,f(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=D.create("div","maplibregl-ctrl mapboxgl-ctrl");const e=D.create("a","maplibregl-ctrl-logo mapboxgl-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(){D.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_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","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class Hm{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,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Km;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(Km||(Km={}));let Ym=null,Jm=[];const Qm=1e3/30,tf={mark(t){performance.mark(t)},frame(t){const e=t;null!=Ym&&Jm.push(e-Ym),Ym=e},clearMetrics(){Ym=null,Jm=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const t in Km)performance.clearMarks(Km[t])},getPerformanceMetrics(){performance.measure("loadTime",Km.create,Km.load),performance.measure("fullLoadTime",Km.create,Km.fullLoad);const t=performance.getEntriesByName("loadTime")[0].duration,e=performance.getEntriesByName("fullLoadTime")[0].duration,i=Jm.length,r=1/(Jm.reduce(((t,e)=>t+e),0)/i/1e3),s=Jm.filter((t=>t>Qm)).reduce(((t,e)=>t+(e-Qm)/Qm),0);return{loadTime:t,fullLoadTime:e,fps:r,percentDroppedFrames:s/(i+s)*100}}},ef={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"},rf={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},sf={showCompass:!0,showZoom:!0,visualizePitch:!1};class nf{constructor(t,e,i=!1){this._clickTolerance=10,this.element=e,this.mouseRotate=new xm({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new vm({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),f(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),D.addEventListener(e,"mousedown",this.mousedown),D.addEventListener(e,"touchstart",this.touchstart,{passive:!1}),D.addEventListener(e,"touchmove",this.touchmove),D.addEventListener(e,"touchend",this.touchend),D.addEventListener(e,"touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),D.disableDrag()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;D.removeEventListener(t,"mousedown",this.mousedown),D.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),D.removeEventListener(t,"touchmove",this.touchmove),D.removeEventListener(t,"touchend",this.touchend),D.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){D.enableDrag(),D.removeEventListener(window,"mousemove",this.mousemove),D.removeEventListener(window,"mouseup",this.mouseup)}mousedown(t){this.down(u({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),D.mousePos(this.element,t)),D.addEventListener(window,"mousemove",this.mousemove),D.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.move(t,D.mousePos(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=D.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=D.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function af(t,e,i){if(t=new Kc(t.lng,t.lat),e){const r=new Kc(t.lng-360,t.lat),s=new Kc(t.lng+360,t.lat),n=i.locationPoint(t).distSqr(e);i.locationPoint(r).distSqr(e)<n?t=r:i.locationPoint(s).distSqr(e)<n&&(t=s)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const of={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 lf(t,e,i){const r=t.classList;for(const t in of)r.remove(`maplibregl-${i}-anchor-${t}`,`mapboxgl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`,`mapboxgl-${i}-anchor-${e}`)}class cf extends dt{constructor(t,e){if(super(),(t instanceof HTMLElement||e)&&(t=u({element:t},e)),f(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),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._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,t&&t.element)this._element=t.element,this._offset=k.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=D.create("div"),this._element.setAttribute("aria-label","Map marker");const e=D.createNS("http://www.w3.org/2000/svg","svg"),i=41,r=27;e.setAttributeNS(null,"display","block"),e.setAttributeNS(null,"height",`${i}px`),e.setAttributeNS(null,"width",`${r}px`),e.setAttributeNS(null,"viewBox",`0 0 ${r} ${i}`);const s=D.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const n=D.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill-rule","nonzero");const a=D.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const o=[{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 o){const e=D.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),a.appendChild(e)}const l=D.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"fill",this._color);const c=D.createNS("http://www.w3.org/2000/svg","path");c.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"),l.appendChild(c);const h=D.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"opacity","0.25"),h.setAttributeNS(null,"fill","#000000");const u=D.createNS("http://www.w3.org/2000/svg","path");u.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"),h.appendChild(u);const p=D.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const d=D.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(8.0, 8.0)");const m=D.createNS("http://www.w3.org/2000/svg","circle");m.setAttributeNS(null,"fill","#000000"),m.setAttributeNS(null,"opacity","0.25"),m.setAttributeNS(null,"cx","5.5"),m.setAttributeNS(null,"cy","5.5"),m.setAttributeNS(null,"r","5.4999962");const f=D.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#FFFFFF"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962"),d.appendChild(m),d.appendChild(f),n.appendChild(a),n.appendChild(l),n.appendChild(h),n.appendChild(p),n.appendChild(d),e.appendChild(n),e.setAttributeNS(null,"height",i*this._scale+"px"),e.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(e),this._offset=k.convert(t&&t.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),lf(this._element,this._anchor,"marker"),this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",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("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),D.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Kc.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,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}_update(t){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=af(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let e="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?e=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(e=`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)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),D.setTransform(this._element,`${of[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${e}`),this._map.style&&this._map.style.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout((()=>{const t=this._map.unproject(this._pos),e=40075016.686*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=t.distanceTo(this._lngLat)>20*e?"0.2":"1.0",this._opacityTimeout=null}),100))}getOffset(){return this._offset}setOffset(t){return this._offset=k.convert(t),this._update(),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 ut("dragstart"))),this.fire(new ut("drag")))}_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 ut("dragend")),this._state="inactive"}_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))}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}}const hf={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let uf,pf=0,df=!1;const mf={maxWidth:100,unit:"metric"};function ff(t,e,i){const r=i&&i.maxWidth||100,s=t._container.clientHeight/2,n=t.unproject([0,s]),a=t.unproject([r,s]),o=n.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*o;i>5280?_f(e,r,i/5280,t._getUIString("ScaleControl.Miles")):_f(e,r,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?_f(e,r,o/1852,t._getUIString("ScaleControl.NauticalMiles")):o>=1e3?_f(e,r,o/1e3,t._getUIString("ScaleControl.Kilometers")):_f(e,r,o,t._getUIString("ScaleControl.Meters"))}function _f(t,e,i,r){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s} ${r}`}const gf={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},yf=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function xf(t){if(t){if("number"==typeof t){const e=Math.round(Math.sqrt(.5*Math.pow(t,2)));return{center:new k(0,0),top:new k(0,t),"top-left":new k(e,e),"top-right":new k(-e,e),bottom:new k(0,-t),"bottom-left":new k(e,-e),"bottom-right":new k(-e,-e),left:new k(t,0),right:new k(-t,0)}}if(t instanceof k||Array.isArray(t)){const e=k.convert(t);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:k.convert(t.center||[0,0]),top:k.convert(t.top||[0,0]),"top-left":k.convert(t["top-left"]||[0,0]),"top-right":k.convert(t["top-right"]||[0,0]),bottom:k.convert(t.bottom||[0,0]),"bottom-left":k.convert(t["bottom-left"]||[0,0]),"bottom-right":k.convert(t["bottom-right"]||[0,0]),left:k.convert(t.left||[0,0]),right:k.convert(t.right||[0,0])}}return xf(new k(0,0))}const vf={supported:t,setRTLTextPlugin:function(t,e,i=!1){if(es===Yr||es===Jr||es===Qr)throw new Error("setRTLTextPlugin cannot be called multiple times.");is=P.resolveURL(t),es=Yr,ts=e,ss(),i||os()},getRTLTextPluginStatus:as,Map:class extends Gm{constructor(t){var e;if(tf.mark(Km.create),null!=(t=u({},rf,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Kd(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._interactive=t.interactive,this._cooperativeGestures=t.cooperativeGestures,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new Hm,this._controls=[],this._mapId=m(),this._locale=u({},ef,t.locale),this._clickTolerance=t.clickTolerance,this._pixelRatio=null!==(e=t.pixelRatio)&&void 0!==e?e:devicePixelRatio,this._requestManager=new ot(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),f(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),"undefined"!=typeof window&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new jm(this,t),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=t.hash&&new Yd("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,u({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Xm({customAttribution:t.customAttribution})),t.maplibreLogo&&this.addControl(new Wm,t.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 ut(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new ut(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new ut("sourcedataabort",t))}))}_getMapId(){return this._mapId}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new pt(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new pt(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}resize(t){const e=this._containerDimensions(),i=e[0],r=e[1];this._resizeCanvas(i,r,this.getPixelRatio()),this.transform.resize(i,r),this.painter.resize(i,r,this.getPixelRatio());const s=!this._moving;return s&&(this.stop(),this.fire(new ut("movestart",t)).fire(new ut("move",t))),this.fire(new ut("resize",t)),s&&this.fire(new ut("moveend",t)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(t){const[e,i]=this._containerDimensions();this._pixelRatio=t,this._resizeCanvas(e,i,t),this.painter.resize(e,i,t)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(Yc.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=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?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>85)throw new Error("maxPitch must be less than or equal to 85");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(Kc.convert(t),this.style&&this.style.terrain)}unproject(t){return this.transform.pointLocation(k.convert(t),this.style&&this.style.terrain)}isMoving(){return this._moving||this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers.isRotating()}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const s=s=>{const n=this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[];n.length?r||(r=!0,i.call(this,new am(t,this,s.originalEvent,{features:n}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const s=s=>{(this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new am(t,this,s.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new am(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:n}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const s=this._delegatedListeners[t];for(let t=0;t<s.length;t++){const r=s[t];if(r.layer===e&&r.listener===i){for(const t in r.delegates)this.off(t,r.delegates[t]);return s.splice(t,1),this}}})(),this)}queryRenderedFeatures(t,e){if(!this.style)return[];let i;if(void 0!==e||void 0===t||t instanceof k||Array.isArray(t)||(e=t,t=void 0),e=e||{},(t=t||[[0,0],[this.transform.width,this.transform.height]])instanceof k||"number"==typeof t[0])i=[k.convert(t)];else{const e=k.convert(t[0]),r=k.convert(t[1]);i=[e,new k(r.x,e.y),r,new k(e.x,r.y),e]}return this.style.queryRenderedFeatures(i,e,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,e){return!1!==(e=u({},{localIdeographFontFamily:this._localIdeographFontFamily},e)).diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(t,e))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove()),t?(this.style=new Hu(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Hu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,e){if("string"==typeof t){const i=this._requestManager.transformRequest(t,H.Style);tt(i,((t,i)=>{t?this.fire(new pt(t)):i&&this._updateDiff(i,e)}))}else"object"==typeof t&&this._updateDiff(t,e)}_updateDiff(t,e){try{this.style.setState(t)&&this._update(!0)}catch(i){v(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():v("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 e=this.style&&this.style.sourceCaches[t];if(void 0!==e)return e.loaded();this.fire(new pt(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){return this.style.setTerrain(t),this}getTerrain(){return this.style.terrain&&this.style.terrain.options}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,e,{pixelRatio:i=1,sdf:r=!1,stretchX:s,stretchY:n,content:a}={}){if(this._lazyInitEmptyStyle(),e instanceof HTMLImageElement||C(e)){const{width:o,height:l,data:c}=P.getImageData(e);this.style.addImage(t,{data:new ro({width:o,height:l},c),pixelRatio:i,stretchX:s,stretchY:n,content:a,sdf:r,version:0})}else{if(void 0===e.width||void 0===e.height)return this.fire(new pt(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:o,height:l,data:c}=e,h=e;this.style.addImage(t,{data:new ro({width:o,height:l},new Uint8Array(c)),pixelRatio:i,stretchX:s,stretchY:n,content:a,sdf:r,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}}updateImage(t,e){const i=this.style.getImage(t);if(!i)return this.fire(new pt(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=e instanceof HTMLImageElement||C(e)?P.getImageData(e):e,{width:s,height:n,data:a}=r;if(void 0===s||void 0===n)return this.fire(new pt(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(s!==i.data.width||n!==i.data.height)return this.fire(new pt(new Error("The width and height of the updated image must be that same as the previous version of the image")));const o=!(e instanceof HTMLImageElement||C(e));i.data.replace(a,o),this.style.updateImage(t,i)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new pt(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t,e){at(this._requestManager.transformRequest(t,H.Image),e)}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)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}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","mapboxgl-map");const e=this._canvasContainer=D.create("div","maplibregl-canvas-container mapboxgl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=D.create("canvas","maplibregl-canvas mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const i=this._containerDimensions();this._resizeCanvas(i[0],i[1],this.getPixelRatio());const r=this._controlContainer=D.create("div","maplibregl-control-container mapboxgl-control-container",t),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{s[t]=D.create("div",`maplibregl-ctrl-${t} mapboxgl-ctrl-${t}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const t=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=D.create("div","maplibregl-cooperative-gesture-screen",t);let e="Control",i="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";0===navigator.platform.indexOf("Mac")&&(i="boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map",e="Meta"),this._cooperativeGesturesScreen.innerHTML=`\n <div class="maplibregl-desktop-message">${i}</div>\n <div class="maplibregl-mobile-message">${"boolean"!=typeof this._cooperativeGestures&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}</div>\n `,document.addEventListener("keydown",(t=>{t.key===e&&(this._metaPress=!0)})),document.addEventListener("keyup",(t=>{t.key===e&&(this._metaPress=!1)})),this._canvasContainer.addEventListener("wheel",(t=>{this._onCooperativeGesture(t,this._metaPress,1)}),!1),this._canvasContainer.classList.remove("mapboxgl-touch-drag-pan","maplibregl-touch-drag-pan")}_resizeCanvas(t,e,i){this._canvas.width=i*t,this._canvas.height=i*e,this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const e=u({},t.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);i?(this.painter=new Gd(i,this.transform),q.testSupport(i)):this.fire(new pt(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new ut("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new ut("webglcontextrestored",{originalEvent:t}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(t,e,i){return!e&&i<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout((()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")}),100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(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){let e,i=0;const r=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(e=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,e),i=P.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let s=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,e=P.now();this.style.zoomHistory.update(t,e);const i=new cs(t,{now:e,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=i.crossFadingFactor();1===r&&r===this._crossFadingFactor||(s=!0,this._crossFadingFactor=r),this.style.update(i)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.style.terrain&&this.style.terrain.sourceCache.update(this.transform,this.style.terrain),this.transform.updateElevation(this.style.terrain),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new ut("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,tf.mark(Km.load),this.fire(new ut("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const t=P.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,e),setTimeout((()=>{const i=r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(e),this.fire(new ut("gpu-timing-frame",{cpuTime:t,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const e=this.painter.queryGpuTimers(t);this.fire(new ut("gpu-timing-layer",{layerTimes:e}))}),50)}const n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new ut("idle")),!this._loaded||this._fullyLoaded||n||(this._fullyLoaded=!0,tf.mark(Km.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),D.remove(this._canvasContainer),D.remove(this._controlContainer),this._cooperativeGestures&&D.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map","mapboxgl-map"),tf.clearMetrics(),this._removed=!0,this.fire(new ut("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=P.frame((t=>{tf.frame(t),this._frame=null,this._render(t)})))}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}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()}_setCacheLimits(t,e){!function(t,e){O=t,V=e}(t,e)}},NavigationControl:class{constructor(t){this.options=u({},sf,t),this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(f(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(f(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_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}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 nf(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){D.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 i=D.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}},GeolocateControl:class extends dt{constructor(t){super(),this.options=u({},hf,t),f(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(t){var e;return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),e=this._setupUI,void 0!==uf?e(uf):void 0!==window.navigator.permissions?window.navigator.permissions.query({name:"geolocation"}).then((t=>{uf="denied"!==t.state,e(uf)})):(uf=!!window.navigator.geolocation,e(uf)),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(),D.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,pf=0,df=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new ut("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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background")}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","mapboxgl-user-location-dot-stale"),this.fire(new ut("geolocate",t)),this._finish()}}_updateCamera(t){const e=new Kc(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=u({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(e.toBounds(i),r,{geolocateSource:!0})}_updateMarker(t){if(t){const e=new Kc(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([1,t]),r=e.distanceTo(i),s=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-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&&df)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new ut("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=D.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){v("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.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=D.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new cf(this._dotElement),this._circleElement=D.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new cf({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this.fire(new ut("trackuserlocationend")))}))}trigger(){if(!this._setup)return v("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 ut("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":pf--,df=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new ut("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new ut("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active")}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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),pf++,pf>1?(t={maximumAge:6e5,timeout:0},df=!0):(t=this.options.positionOptions,df=!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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Xm,LogoControl:Wm,ScaleControl:class{constructor(t){this.options=u({},mf,t),f(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){ff(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){D.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,ff(this._map,this._container,this.options)}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:v("Full screen control 'container' must be a DOM element.")),f(["_onClickFullscreen","_changeIcon"],this),"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=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",v("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){D.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=D.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);D.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_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}_changeIcon(){(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?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._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},TerrainControl:class{constructor(t){this.options=t,f(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._terrainButton=D.create("button","maplibregl-ctrl-terrain mapboxgl-ctrl-terrain",this._container),D.create("span","maplibregl-ctrl-icon mapboxgl-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(){D.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._map.style.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends dt{constructor(t){super(),this.options=u(Object.create(gf),t),f(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new ut("open")),this}isOpen(){return!!this._map}remove(){return this._content&&D.remove(this._content),this._container&&(D.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),delete this._map),this.fire(new ut("close")),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Kc.convert(t),this._pos=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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){return this._container&&this._container.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=D.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}_createCloseButton(){this.options.closeButton&&(this._closeButton=D.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(t){this._update(t.point)}_onMouseMove(t){this._update(t.point)}_onDrag(t){this._update(t.point)}_update(t){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(this._container||(this._container=D.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=D.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((t=>this._container.classList.add(t))),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),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=af(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const e=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let i=this.options.anchor;const r=xf(this.options.offset);if(!i){const t=this._container.offsetWidth,s=this._container.offsetHeight;let n;n=e.y+r.bottom.y<s?["top"]:e.y>this._map.transform.height-s?["bottom"]:[],e.x<t/2?n.push("left"):e.x>this._map.transform.width-t/2&&n.push("right"),i=0===n.length?"bottom":n.join("-")}const s=e.add(r[i]).round();D.setTransform(this._container,`${of[i]} translate(${s.x}px,${s.y}px)`),lf(this._container,i,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(yf);t&&t.focus()}_onClose(){this.remove()}},Marker:cf,Style:Hu,LngLat:Kc,LngLatBounds:Yc,Point:k,MercatorCoordinate:sh,Evented:dt,AJAXError:K,config:L,CanvasSource:xh,GeoJSONSource:fh,ImageSource:gh,RasterDEMTileSource:mh,RasterTileSource:oh,VectorTileSource:ah,VideoSource:yh,prewarm:function(){Vh().acquire(Bh)},clearPrewarmedResources:function(){const t=Oh;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Bh),Oh=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()"))},get workerCount(){return Rh.workerCount},set workerCount(t){Rh.workerCount=t},get maxParallelImageRequests(){return L.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){L.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){!function(t){const e=caches.delete(B);t&&e.catch(t).then((()=>t()))}(t)},workerUrl:"",addProtocol(t,e){L.REGISTERED_PROTOCOLS[t]=e},removeProtocol(t){delete L.REGISTERED_PROTOCOLS[t]}};return Zm.extend(vf,{isSafari:E,getPerformanceMetrics:tf.getPerformanceMetrics}),vf}));
|
|
2
2
|
//# sourceMappingURL=maplibre-gl-csp.js.map
|