From ac0905de039d331533a94507ebaea471809e65b4 Mon Sep 17 00:00:00 2001 From: Cristine Guadelupe Date: Tue, 11 Jun 2024 22:36:34 +0700 Subject: [PATCH] Updates text-protocol --- assets/maplibre/package-lock.json | 8 +-- assets/maplibre/package.json | 2 +- lib/assets/maplibre/build/main.js | 86 +++++++++++++++---------------- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/assets/maplibre/package-lock.json b/assets/maplibre/package-lock.json index 944ade5..65d833b 100644 --- a/assets/maplibre/package-lock.json +++ b/assets/maplibre/package-lock.json @@ -8,7 +8,7 @@ "@maplibre/maplibre-gl-geocoder": "^1.5.0", "@watergis/maplibre-gl-export": "^3.2.2", "maplibre-gl": "^4.1.2", - "maplibre-gl-vector-text-protocol": "github:jimmyrocks/maplibre-gl-vector-text-protocol" + "maplibre-gl-vector-text-protocol": "^0.0.5" }, "devDependencies": { "@types/events": "^3.0.3", @@ -1319,9 +1319,9 @@ } }, "node_modules/maplibre-gl-vector-text-protocol": { - "version": "0.0.3", - "resolved": "git+ssh://git@github.com/jimmyrocks/maplibre-gl-vector-text-protocol.git#9877992676b683431feff403954f6b771de4f9fe", - "license": "MIT", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/maplibre-gl-vector-text-protocol/-/maplibre-gl-vector-text-protocol-0.0.5.tgz", + "integrity": "sha512-6sIJ2Ihz7KVg8oU3bQjeWJ80TcNKokrqCef2atHDIzXZhK8PSHUkpspreNjbFSfSMRUcKhL4BlMf4qwJxHtGUg==", "dependencies": { "@mapbox/polyline": "^1.2.1", "@tmcw/togeojson": "5.8.1", diff --git a/assets/maplibre/package.json b/assets/maplibre/package.json index 7c2aeed..c4b3310 100644 --- a/assets/maplibre/package.json +++ b/assets/maplibre/package.json @@ -8,7 +8,7 @@ "@maplibre/maplibre-gl-geocoder": "^1.5.0", "@watergis/maplibre-gl-export": "^3.2.2", "maplibre-gl": "^4.1.2", - "maplibre-gl-vector-text-protocol": "github:jimmyrocks/maplibre-gl-vector-text-protocol" + "maplibre-gl-vector-text-protocol": "^0.0.5" }, "devDependencies": { "@types/events": "^3.0.3", diff --git a/lib/assets/maplibre/build/main.js b/lib/assets/maplibre/build/main.js index aa4b5ca..3bfd308 100644 --- a/lib/assets/maplibre/build/main.js +++ b/lib/assets/maplibre/build/main.js @@ -1,5 +1,5 @@ -var f3=Object.create;var Wm=Object.defineProperty;var m3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var I3=Object.getPrototypeOf,y3=Object.prototype.hasOwnProperty;var gd=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var dd=(r,t)=>()=>(r&&(t=r(r=0)),t);var la=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Om=(r,t)=>{for(var i in t)Wm(r,i,{get:t[i],enumerable:!0})},b3=(r,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of C3(t))!y3.call(r,A)&&A!==i&&Wm(r,A,{get:()=>t[A],enumerable:!(s=m3(t,A))||s.enumerable});return r};var pd=(r,t,i)=>(i=r!=null?f3(I3(r)):{},b3(t||!r||!r.__esModule?Wm(i,"default",{value:r,enumerable:!0}):i,r));var Xm=la((zm,Jm)=>{(function(r,t){typeof zm=="object"&&typeof Jm<"u"?Jm.exports=t():typeof define=="function"&&define.amd?define(t):(r=typeof globalThis<"u"?globalThis:r||self,r.maplibregl=t())})(zm,function(){"use strict";var r={},t={};function i(A,o,g){if(t[A]=g,A==="index"){var d="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",C={};return t.shared(C),t.index(r,C),typeof window<"u"&&r.setWorkerUrl(window.URL.createObjectURL(new Blob([d],{type:"text/javascript"}))),r}}i("shared",["exports"],function(A){"use strict";function o(a,e,l,u){return new(l||(l=Promise))(function(m,w){function B(M){try{Q(u.next(M))}catch(D){w(D)}}function S(M){try{Q(u.throw(M))}catch(D){w(D)}}function Q(M){var D;M.done?m(M.value):(D=M.value,D instanceof l?D:new l(function(z){z(D)})).then(B,S)}Q((u=u.apply(a,e||[])).next())})}function g(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}typeof SuppressedError=="function"&&SuppressedError;var d=C;function C(a,e){this.x=a,this.y=e}C.prototype={clone:function(){return new C(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,e){return this.clone()._rotateAround(a,e)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var e=a.x-this.x,l=a.y-this.y;return e*e+l*l},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,e){return Math.atan2(this.x*e-this.y*a,this.x*a+this.y*e)},_matMult:function(a){var e=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=e,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var e=Math.cos(a),l=Math.sin(a),u=l*this.x+e*this.y;return this.x=e*this.x-l*this.y,this.y=u,this},_rotateAround:function(a,e){var l=Math.cos(a),u=Math.sin(a),m=e.y+u*(this.x-e.x)+l*(this.y-e.y);return this.x=e.x+l*(this.x-e.x)-u*(this.y-e.y),this.y=m,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},C.convert=function(a){return a instanceof C?a:Array.isArray(a)?new C(a[0],a[1]):a};var v=g(d),x=T;function T(a,e,l,u){this.cx=3*a,this.bx=3*(l-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=e,this.p2x=l,this.p2y=u}T.prototype={sampleCurveX:function(a){return((this.ax*a+this.bx)*a+this.cx)*a},sampleCurveY:function(a){return((this.ay*a+this.by)*a+this.cy)*a},sampleCurveDerivativeX:function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},solveCurveX:function(a,e){if(e===void 0&&(e=1e-6),a<0)return 0;if(a>1)return 1;for(var l=a,u=0;u<8;u++){var m=this.sampleCurveX(l)-a;if(Math.abs(m)m?B=l:S=l,l=.5*(S-B)+B;return l},solve:function(a,e){return this.sampleCurveY(this.solveCurveX(a,e))}};var G=g(x);let k,W;function K(){return k==null&&(k=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),k}function $(){if(W==null&&(W=!1,K())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let u=0;u<5*5;u++){let m=4*u;e.fillStyle=`rgb(${m},${m+1},${m+2})`,e.fillRect(u%5,Math.floor(u/5),1,1)}let l=e.getImageData(0,0,5,5).data;for(let u=0;u<5*5*4;u++)if(u%4!=3&&l[u]!==u){W=!0;break}}}return W||!1}function O(a,e,l,u){let m=new G(a,e,l,u);return function(w){return m.solve(w)}}let tt=O(.25,.1,.25,1);function at(a,e,l){return Math.min(l,Math.max(e,a))}function Lt(a,e,l){let u=l-e,m=((a-e)%u+u)%u+e;return m===e?l:m}function Tt(a,...e){for(let l of e)for(let u in l)a[u]=l[u];return a}let Qt=1;function Ft(a,e,l){let u={};for(let m in a)u[m]=e.call(l||this,a[m],m,a);return u}function vt(a,e,l){let u={};for(let m in a)e.call(l||this,a[m],m,a)&&(u[m]=a[m]);return u}function Jt(a){return Array.isArray(a)?a.map(Jt):typeof a=="object"&&a?Ft(a,Jt):a}let qt={};function At(a){qt[a]||(typeof console<"u"&&console.warn(a),qt[a]=!0)}function lt(a,e,l){return(l.y-a.y)*(e.x-a.x)>(e.y-a.y)*(l.x-a.x)}function kt(a){let e=0;for(let l,u,m=0,w=a.length,B=w-1;m"u")throw new Error("VideoFrame not supported");let w=new VideoFrame(a,{timestamp:0});try{let B=w?.format;if(!B||!B.startsWith("BGR")&&!B.startsWith("RGB"))throw new Error(`Unrecognized format ${B}`);let S=B.startsWith("BGR"),Q=new Uint8ClampedArray(u*m*4);if(yield w.copyTo(Q,function(M,D,z,et,nt){let st=4*Math.max(-D,0),mt=(Math.max(0,z)-z)*et*4+st,St=4*et,Vt=Math.max(0,D),oe=Math.max(0,z);return{rect:{x:Vt,y:oe,width:Math.min(M.width,D+et)-Vt,height:Math.min(M.height,z+nt)-oe},layout:[{offset:mt,stride:St}]}}(a,e,l,u,m)),S)for(let M=0;M_t(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,he=function(a,e){if(/:\/\//.test(a.url)&&!/^https?:|^file:/.test(a.url)){let u=It(a.url);if(u)return u(a,e);if(_t(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"getResource",data:a,targetMapId:Ht},e)}if(!(/^file:/.test(l=a.url)||/^file:/.test(Ae())&&!/^\w+:/.test(l))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(u,m){return o(this,void 0,void 0,function*(){let w=new Request(u.url,{method:u.method||"GET",body:u.body,credentials:u.credentials,headers:u.headers,cache:u.cache,referrer:Ae(),signal:m.signal});u.type==="json"&&w.headers.set("Accept","application/json");let B=yield fetch(w);if(!B.ok){let M=yield B.blob();throw new Ot(B.status,B.statusText,u.url,M)}let S;S=u.type==="arrayBuffer"||u.type==="image"?B.arrayBuffer():u.type==="json"?B.json():B.text();let Q=yield S;if(m.signal.aborted)throw j();return{data:Q,cacheControl:B.headers.get("Cache-Control"),expires:B.headers.get("Expires")}})}(a,e);if(_t(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"getResource",data:a,mustQueue:!0,targetMapId:Ht},e)}var l;return function(u,m){return new Promise((w,B)=>{let S=new XMLHttpRequest;S.open(u.method||"GET",u.url,!0),u.type!=="arrayBuffer"&&u.type!=="image"||(S.responseType="arraybuffer");for(let Q in u.headers)S.setRequestHeader(Q,u.headers[Q]);u.type==="json"&&(S.responseType="text",S.setRequestHeader("Accept","application/json")),S.withCredentials=u.credentials==="include",S.onerror=()=>{B(new Error(S.statusText))},S.onload=()=>{if(!m.signal.aborted)if((S.status>=200&&S.status<300||S.status===0)&&S.response!==null){let Q=S.response;if(u.type==="json")try{Q=JSON.parse(S.response)}catch(M){return void B(M)}w({data:Q,cacheControl:S.getResponseHeader("Cache-Control"),expires:S.getResponseHeader("Expires")})}else{let Q=new Blob([S.response],{type:S.getResponseHeader("Content-Type")});B(new Ot(S.status,S.statusText,u.url,Q))}},m.signal.addEventListener("abort",()=>{S.abort(),B(j())}),S.send(u.body)})}(a,e)};function de(a){if(!a||a.indexOf("://")<=0||a.indexOf("data:image/")===0||a.indexOf("blob:")===0)return!0;let e=new URL(a),l=window.location;return e.protocol===l.protocol&&e.host===l.host}function He(a,e,l){l[a]&&l[a].indexOf(e)!==-1||(l[a]=l[a]||[],l[a].push(e))}function Re(a,e,l){if(l&&l[a]){let u=l[a].indexOf(e);u!==-1&&l[a].splice(u,1)}}class je{constructor(e,l={}){Tt(this,l),this.type=e}}class Me extends je{constructor(e,l={}){super("error",Tt({error:e},l))}}class gi{on(e,l){return this._listeners=this._listeners||{},He(e,l,this._listeners),this}off(e,l){return Re(e,l,this._listeners),Re(e,l,this._oneTimeListeners),this}once(e,l){return l?(this._oneTimeListeners=this._oneTimeListeners||{},He(e,l,this._oneTimeListeners),this):new Promise(u=>this.once(e,u))}fire(e,l){typeof e=="string"&&(e=new je(e,l||{}));let u=e.type;if(this.listens(u)){e.target=this;let m=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(let S of m)S.call(this,e);let w=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(let S of w)Re(u,S,this._oneTimeListeners),S.call(this,e);let B=this._eventedParent;B&&(Tt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),B.fire(e))}else e instanceof Me&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,l){return this._eventedParent=e,this._eventedParentData=l,this}}var xt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},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}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},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"}}};let Rt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Li(a,e){let l={};for(let u in a)u!=="ref"&&(l[u]=a[u]);return Rt.forEach(u=>{u in e&&(l[u]=e[u])}),l}function Ue(a,e){if(Array.isArray(a)){if(!Array.isArray(e)||a.length!==e.length)return!1;for(let l=0;l`:a.itemType.kind==="value"?"array":`array<${e}>`}return a.kind}let Zt=[We,Se,$e,di,Zi,Lr,qi,rt(vi),ft,Y,q];function zt(a,e){if(e.kind==="error")return null;if(a.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!zt(a.itemType,e.itemType))&&(typeof a.N!="number"||a.N===e.N))return null}else{if(a.kind===e.kind)return null;if(a.kind==="value"){for(let l of Zt)if(!zt(l,e))return null}}return`Expected ${ht(a)} but found ${ht(e)} instead.`}function Xt(a,e){return e.some(l=>l.kind===a.kind)}function Mt(a,e){return e.some(l=>l==="null"?a===null:l==="array"?Array.isArray(a):l==="object"?a&&!Array.isArray(a)&&typeof a=="object":l===typeof a)}function re(a,e){return a.kind==="array"&&e.kind==="array"?a.itemType.kind===e.itemType.kind&&typeof a.N=="number":a.kind===e.kind}let ce=.96422,pe=.82521,me=4/29,Xe=6/29,oi=3*Xe*Xe,ii=Xe*Xe*Xe,Ni=Math.PI/180,Qi=180/Math.PI;function rr(a){return(a%=360)<0&&(a+=360),a}function zi([a,e,l,u]){let m,w,B=ki((.2225045*(a=Cr(a))+.7168786*(e=Cr(e))+.0606169*(l=Cr(l)))/1);a===e&&e===l?m=w=B:(m=ki((.4360747*a+.3850649*e+.1430804*l)/ce),w=ki((.0139322*a+.0971045*e+.7141733*l)/pe));let S=116*B-16;return[S<0?0:S,500*(m-B),200*(B-w),u]}function Cr(a){return a<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function ki(a){return a>ii?Math.pow(a,1/3):a/oi+me}function fr([a,e,l,u]){let m=(a+16)/116,w=isNaN(e)?m:m+e/500,B=isNaN(l)?m:m-l/200;return m=1*Tr(m),w=ce*Tr(w),B=pe*Tr(B),[br(3.1338561*w-1.6168667*m-.4906146*B),br(-.9787684*w+1.9161415*m+.033454*B),br(.0719453*w-.2289914*m+1.4052427*B),u]}function br(a){return(a=a<=.00304?12.92*a:1.055*Math.pow(a,1/2.4)-.055)<0?0:a>1?1:a}function Tr(a){return a>Xe?a*a*a:oi*(a-me)}function Dt(a){return parseInt(a.padEnd(2,a),16)/255}function Ke(a,e){return Te(e?a/100:a,0,1)}function Te(a,e,l){return Math.min(Math.max(e,a),l)}function or(a){return!a.some(Number.isNaN)}let Er={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Ji{constructor(e,l,u,m=1,w=!0){this.r=e,this.g=l,this.b=u,this.a=m,w||(this.r*=m,this.g*=m,this.b*=m,m||this.overwriteGetter("rgb",[e,l,u,m]))}static parse(e){if(e instanceof Ji)return e;if(typeof e!="string")return;let l=function(u){if((u=u.toLowerCase().trim())==="transparent")return[0,0,0,0];let m=Er[u];if(m){let[B,S,Q]=m;return[B/255,S/255,Q/255,1]}if(u.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(u)){let B=u.length<6?1:2,S=1;return[Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+B)||"ff")]}if(u.startsWith("rgb")){let B=u.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(B){let[S,Q,M,D,z,et,nt,st,mt,St,Vt,oe]=B,Wt=[D||" ",nt||" ",St].join("");if(Wt===" "||Wt===" /"||Wt===",,"||Wt===",,,"){let $t=[M,et,mt].join(""),ve=$t==="%%%"?100:$t===""?255:0;if(ve){let Le=[Te(+Q/ve,0,1),Te(+z/ve,0,1),Te(+st/ve,0,1),Vt?Ke(+Vt,oe):1];if(or(Le))return Le}}return}}let w=u.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(w){let[B,S,Q,M,D,z,et,nt,st]=w,mt=[Q||" ",D||" ",et].join("");if(mt===" "||mt===" /"||mt===",,"||mt===",,,"){let St=[+S,Te(+M,0,100),Te(+z,0,100),nt?Ke(+nt,st):1];if(or(St))return function([Vt,oe,Wt,$t]){function ve(Le){let ni=(Le+Vt/30)%12,bi=oe*Math.min(Wt,1-Wt);return Wt-bi*Math.max(-1,Math.min(ni-3,9-ni,1))}return Vt=rr(Vt),oe/=100,Wt/=100,[ve(0),ve(8),ve(4),$t]}(St)}}}(e);return l?new Ji(...l,!1):void 0}get rgb(){let{r:e,g:l,b:u,a:m}=this,w=m||1/0;return this.overwriteGetter("rgb",[e/w,l/w,u/w,m])}get hcl(){return this.overwriteGetter("hcl",function(e){let[l,u,m,w]=zi(e),B=Math.sqrt(u*u+m*m);return[Math.round(1e4*B)?rr(Math.atan2(m,u)*Qi):NaN,B,l,w]}(this.rgb))}get lab(){return this.overwriteGetter("lab",zi(this.rgb))}overwriteGetter(e,l){return Object.defineProperty(this,e,{value:l}),l}toString(){let[e,l,u,m]=this.rgb;return`rgba(${[e,l,u].map(w=>Math.round(255*w)).join(",")},${m})`}}Ji.black=new Ji(0,0,0,1),Ji.white=new Ji(1,1,1,1),Ji.transparent=new Ji(0,0,0,0),Ji.red=new Ji(1,0,0,1);class Mr{constructor(e,l,u){this.sensitivity=e?l?"variant":"case":l?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,l){return this.collator.compare(e,l)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class vs{constructor(e,l,u,m,w){this.text=e,this.image=l,this.scale=u,this.fontStack=m,this.textColor=w}}class Sr{constructor(e){this.sections=e}static fromString(e){return new Sr([new vs(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Sr?e:Sr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class xr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof xr)return e;if(typeof e=="number")return new xr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let l of e)if(typeof l!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new xr(e)}}toString(){return JSON.stringify(this.values)}}let Wo=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class an{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof an)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let l=0;l=0&&a<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof l=="number"&&l>=0&&l<=255?u===void 0||typeof u=="number"&&u>=0&&u<=1?null:`Invalid rgba value [${[a,e,l,u].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof u=="number"?[a,e,l,u]:[a,e,l]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function As(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Ji||a instanceof Mr||a instanceof Sr||a instanceof xr||a instanceof an||a instanceof Dn)return!0;if(Array.isArray(a)){for(let e of a)if(!As(e))return!1;return!0}if(typeof a=="object"){for(let e in a)if(!As(a[e]))return!1;return!0}return!1}function Qr(a){if(a===null)return We;if(typeof a=="string")return $e;if(typeof a=="boolean")return di;if(typeof a=="number")return Se;if(a instanceof Ji)return Zi;if(a instanceof Mr)return tr;if(a instanceof Sr)return Lr;if(a instanceof xr)return ft;if(a instanceof an)return q;if(a instanceof Dn)return Y;if(Array.isArray(a)){let e=a.length,l;for(let u of a){let m=Qr(u);if(l){if(l===m)continue;l=vi;break}l=m}return rt(l||vi,e)}return qi}function zo(a){let e=typeof a;return a===null?"":e==="string"||e==="number"||e==="boolean"?String(a):a instanceof Ji||a instanceof Sr||a instanceof xr||a instanceof an||a instanceof Dn?a.toString():JSON.stringify(a)}class Fr{constructor(e,l){this.type=e,this.value=l}static parse(e,l){if(e.length!==2)return l.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!As(e[1]))return l.error("invalid value");let u=e[1],m=Qr(u),w=l.expectedType;return m.kind!=="array"||m.N!==0||!w||w.kind!=="array"||typeof w.N=="number"&&w.N!==0||(m=w),new Fr(m,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Nr{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let Gs={string:$e,number:Se,boolean:di,object:qi};class Kn{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u,m=1,w=e[0];if(w==="array"){let S,Q;if(e.length>2){let M=e[1];if(typeof M!="string"||!(M in Gs)||M==="object")return l.error('The item type argument of "array" must be one of string, number, boolean',1);S=Gs[M],m++}else S=vi;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return l.error('The length argument to "array" must be a positive integer literal',2);Q=e[2],m++}u=rt(S,Q)}else{if(!Gs[w])throw new Error(`Types doesn't contain name = ${w}`);u=Gs[w]}let B=[];for(;me.outputDefined())}}let to={"to-boolean":di,"to-color":Zi,"to-number":Se,"to-string":$e};class pt{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u=e[0];if(!to[u])throw new Error(`Can't parse ${u} as it is not part of the known types`);if((u==="to-boolean"||u==="to-string")&&e.length!==2)return l.error("Expected one argument.");let m=to[u],w=[];for(let B=1;B4?`Invalid rbga value ${JSON.stringify(l)}: expected an array containing either three or four numeric values.`:Oo(l[0],l[1],l[2],l[3]),!u))return new Ji(l[0]/255,l[1]/255,l[2]/255,l[3])}throw new Nr(u||`Could not parse color from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"padding":{let l;for(let u of this.args){l=u.evaluate(e);let m=xr.parse(l);if(m)return m}throw new Nr(`Could not parse padding from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"variableAnchorOffsetCollection":{let l;for(let u of this.args){l=u.evaluate(e);let m=an.parse(l);if(m)return m}throw new Nr(`Could not parse variableAnchorOffsetCollection from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"number":{let l=null;for(let u of this.args){if(l=u.evaluate(e),l===null)return 0;let m=Number(l);if(!isNaN(m))return m}throw new Nr(`Could not convert ${JSON.stringify(l)} to number.`)}case"formatted":return Sr.fromString(zo(this.args[0].evaluate(e)));case"resolvedImage":return Dn.fromString(zo(this.args[0].evaluate(e)));default:return zo(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}let yt=["Unknown","Point","LineString","Polygon"];class ct{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?typeof this.feature.type=="number"?yt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let l=this._parseColorCache[e];return l||(l=this._parseColorCache[e]=Ji.parse(e)),l}}class Bt{constructor(e,l,u=[],m,w=new Vi,B=[]){this.registry=e,this.path=u,this.key=u.map(S=>`[${S}]`).join(""),this.scope=w,this.errors=B,this.expectedType=m,this._isConstant=l}parse(e,l,u,m,w={}){return l?this.concat(l,u,m)._parse(e,w):this._parse(e,w)}_parse(e,l){function u(m,w,B){return B==="assert"?new Kn(w,[m]):B==="coerce"?new pt(w,[m]):m}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let m=e[0];if(typeof m!="string")return this.error(`Expression name must be a string, but found ${typeof m} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let w=this.registry[m];if(w){let B=w.parse(e,this);if(!B)return null;if(this.expectedType){let S=this.expectedType,Q=B.type;if(S.kind!=="string"&&S.kind!=="number"&&S.kind!=="boolean"&&S.kind!=="object"&&S.kind!=="array"||Q.kind!=="value")if(S.kind!=="color"&&S.kind!=="formatted"&&S.kind!=="resolvedImage"||Q.kind!=="value"&&Q.kind!=="string")if(S.kind!=="padding"||Q.kind!=="value"&&Q.kind!=="number"&&Q.kind!=="array")if(S.kind!=="variableAnchorOffsetCollection"||Q.kind!=="value"&&Q.kind!=="array"){if(this.checkSubtype(S,Q))return null}else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"assert")}if(!(B instanceof Fr)&&B.type.kind!=="resolvedImage"&&this._isConstant(B)){let S=new ct;try{B=new Fr(B.type,B.evaluate(S))}catch(Q){return this.error(Q.message),null}}return B}return this.error(`Unknown expression "${m}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,l,u){let m=typeof e=="number"?this.path.concat(e):this.path,w=u?this.scope.concat(u):this.scope;return new Bt(this.registry,this._isConstant,m,l||null,w,this.errors)}error(e,...l){let u=`${this.key}${l.map(m=>`[${m}]`).join("")}`;this.errors.push(new mi(u,e))}checkSubtype(e,l){let u=zt(e,l);return u&&this.error(u),u}}class Kt{constructor(e,l,u){this.type=tr,this.locale=u,this.caseSensitive=e,this.diacriticSensitive=l}static parse(e,l){if(e.length!==2)return l.error("Expected one argument.");let u=e[1];if(typeof u!="object"||Array.isArray(u))return l.error("Collator options argument must be an object.");let m=l.parse(u["case-sensitive"]!==void 0&&u["case-sensitive"],1,di);if(!m)return null;let w=l.parse(u["diacritic-sensitive"]!==void 0&&u["diacritic-sensitive"],1,di);if(!w)return null;let B=null;return u.locale&&(B=l.parse(u.locale,1,$e),!B)?null:new Kt(m,w,B)}evaluate(e){return new Mr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}let Yt=8192;function ae(a,e){a[0]=Math.min(a[0],e[0]),a[1]=Math.min(a[1],e[1]),a[2]=Math.max(a[2],e[0]),a[3]=Math.max(a[3],e[1])}function Be(a,e){return!(a[0]<=e[0]||a[2]>=e[2]||a[1]<=e[1]||a[3]>=e[3])}function _e(a,e){let l=(180+a[0])/360,u=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,m=Math.pow(2,e.z);return[Math.round(l*m*Yt),Math.round(u*m*Yt)]}function Ce(a,e,l){let u=a[0]-e[0],m=a[1]-e[1],w=a[0]-l[0],B=a[1]-l[1];return u*B-w*m==0&&u*w<=0&&m*B<=0}function se(a,e){let l=!1;for(let B=0,S=e.length;B(u=a)[1]!=(w=Q[M+1])[1]>u[1]&&u[0]<(w[0]-m[0])*(u[1]-m[1])/(w[1]-m[1])+m[0]&&(l=!l)}}var u,m,w;return l}function ye(a,e){for(let l=0;l0&&S<0||B<0&&S>0}function Ge(a,e,l){for(let M of l)for(let D=0;Dl[2]){let m=.5*u,w=a[0]-l[0]>m?-u:l[0]-a[0]>m?u:0;w===0&&(w=a[0]-l[2]>m?-u:l[2]-a[0]>m?u:0),a[0]+=w}ae(e,a)}function Fi(a,e,l,u){let m=Math.pow(2,u.z)*Yt,w=[u.x*Yt,u.y*Yt],B=[];for(let S of a)for(let Q of S){let M=[Q.x+w[0],Q.y+w[1]];Ai(M,e,l,m),B.push(M)}return B}function Wi(a,e,l,u){let m=Math.pow(2,u.z)*Yt,w=[u.x*Yt,u.y*Yt],B=[];for(let Q of a){let M=[];for(let D of Q){let z=[D.x+w[0],D.y+w[1]];ae(e,z),M.push(z)}B.push(M)}if(e[2]-e[0]<=m/2){(S=e)[0]=S[1]=1/0,S[2]=S[3]=-1/0;for(let Q of B)for(let M of Q)Ai(M,e,l,m)}var S;return B}class nr{constructor(e,l){this.type=di,this.geojson=e,this.geometries=l}static parse(e,l){if(e.length!==2)return l.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(As(e[1])){let u=e[1];if(u.type==="FeatureCollection"){let m=[];for(let w of u.features){let{type:B,coordinates:S}=w.geometry;B==="Polygon"&&m.push(S),B==="MultiPolygon"&&m.push(...S)}if(m.length)return new nr(u,{type:"MultiPolygon",coordinates:m})}else if(u.type==="Feature"){let m=u.geometry.type;if(m==="Polygon"||m==="MultiPolygon")return new nr(u,u.geometry)}else if(u.type==="Polygon"||u.type==="MultiPolygon")return new nr(u,u)}return l.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(l,u){let m=[1/0,1/0,-1/0,-1/0],w=[1/0,1/0,-1/0,-1/0],B=l.canonicalID();if(u.type==="Polygon"){let S=Pe(u.coordinates,w,B),Q=Fi(l.geometry(),m,w,B);if(!Be(m,w))return!1;for(let M of Q)if(!se(M,S))return!1}if(u.type==="MultiPolygon"){let S=Qe(u.coordinates,w,B),Q=Fi(l.geometry(),m,w,B);if(!Be(m,w))return!1;for(let M of Q)if(!ye(M,S))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(l,u){let m=[1/0,1/0,-1/0,-1/0],w=[1/0,1/0,-1/0,-1/0],B=l.canonicalID();if(u.type==="Polygon"){let S=Pe(u.coordinates,w,B),Q=Wi(l.geometry(),m,w,B);if(!Be(m,w))return!1;for(let M of Q)if(!Ui(M,S))return!1}if(u.type==="MultiPolygon"){let S=Qe(u.coordinates,w,B),Q=Wi(l.geometry(),m,w,B);if(!Be(m,w))return!1;for(let M of Q)if(!Ri(M,S))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class ai{constructor(e,l){this.type=l.type,this.name=e,this.boundExpression=l}static parse(e,l){if(e.length!==2||typeof e[1]!="string")return l.error("'var' expression requires exactly one string literal argument.");let u=e[1];return l.scope.has(u)?new ai(u,l.scope.get(u)):l.error(`Unknown variable "${u}". Make sure "${u}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class dr{constructor(e,l,u,m){this.name=e,this.type=l,this._evaluate=u,this.args=m}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,l){let u=e[0],m=dr.definitions[u];if(!m)return l.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);let w=Array.isArray(m)?m[0]:m.type,B=Array.isArray(m)?[[m[1],m[2]]]:m.overloads,S=B.filter(([M])=>!Array.isArray(M)||M.length===e.length-1),Q=null;for(let[M,D]of S){Q=new Bt(l.registry,Or,l.path,null,l.scope);let z=[],et=!1;for(let nt=1;nt{return et=z,Array.isArray(et)?`(${et.map(ht).join(", ")})`:`(${ht(et.type)}...)`;var et}).join(" | "),D=[];for(let z=1;z{l=e?l&&Or(u):l&&u instanceof Fr}),!!l&&Ur(a)&&vn(a,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ur(a){if(a instanceof dr&&(a.name==="get"&&a.args.length===1||a.name==="feature-state"||a.name==="has"&&a.args.length===1||a.name==="properties"||a.name==="geometry-type"||a.name==="id"||/^filter-/.test(a.name))||a instanceof nr)return!1;let e=!0;return a.eachChild(l=>{e&&!Ur(l)&&(e=!1)}),e}function _n(a){if(a instanceof dr&&a.name==="feature-state")return!1;let e=!0;return a.eachChild(l=>{e&&!_n(l)&&(e=!1)}),e}function vn(a,e){if(a instanceof dr&&e.indexOf(a.name)>=0)return!1;let l=!0;return a.eachChild(u=>{l&&!vn(u,e)&&(l=!1)}),l}function ws(a,e){let l=a.length-1,u,m,w=0,B=l,S=0;for(;w<=B;)if(S=Math.floor((w+B)/2),u=a[S],m=a[S+1],u<=e){if(S===l||ee))throw new Nr("Input is not a number.");B=S-1}return 0}class _o{constructor(e,l,u){this.type=e,this.input=l,this.labels=[],this.outputs=[];for(let[m,w]of u)this.labels.push(m),this.outputs.push(w)}static parse(e,l){if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");let u=l.parse(e[1],1,Se);if(!u)return null;let m=[],w=null;l.expectedType&&l.expectedType.kind!=="value"&&(w=l.expectedType);for(let B=1;B=S)return l.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',M);let z=l.parse(Q,D,w);if(!z)return null;w=w||z.type,m.push([S,z])}return new _o(w,u,m)}evaluate(e){let l=this.labels,u=this.outputs;if(l.length===1)return u[0].evaluate(e);let m=this.input.evaluate(e);if(m<=l[0])return u[0].evaluate(e);let w=l.length;return m>=l[w-1]?u[w-1].evaluate(e):u[ws(l,m)].evaluate(e)}eachChild(e){e(this.input);for(let l of this.outputs)e(l)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Ic(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var yc=El;function El(a,e,l,u){this.cx=3*a,this.bx=3*(l-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=e,this.p2x=l,this.p2y=u}El.prototype={sampleCurveX:function(a){return((this.ax*a+this.bx)*a+this.cx)*a},sampleCurveY:function(a){return((this.ay*a+this.by)*a+this.cy)*a},sampleCurveDerivativeX:function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},solveCurveX:function(a,e){if(e===void 0&&(e=1e-6),a<0)return 0;if(a>1)return 1;for(var l=a,u=0;u<8;u++){var m=this.sampleCurveX(l)-a;if(Math.abs(m)m?B=l:S=l,l=.5*(S-B)+B;return l},solve:function(a,e){return this.sampleCurveY(this.solveCurveX(a,e))}};var el=Ic(yc);function Bs(a,e,l){return a+l*(e-a)}function eo(a,e,l){return a.map((u,m)=>Bs(u,e[m],l))}let qn={number:Bs,color:function(a,e,l,u="rgb"){switch(u){case"rgb":{let[m,w,B,S]=eo(a.rgb,e.rgb,l);return new Ji(m,w,B,S,!1)}case"hcl":{let[m,w,B,S]=a.hcl,[Q,M,D,z]=e.hcl,et,nt;if(isNaN(m)||isNaN(Q))isNaN(m)?isNaN(Q)?et=NaN:(et=Q,B!==1&&B!==0||(nt=M)):(et=m,D!==1&&D!==0||(nt=w));else{let oe=Q-m;Q>m&&oe>180?oe-=360:Q180&&(oe+=360),et=m+l*oe}let[st,mt,St,Vt]=function([oe,Wt,$t,ve]){return oe=isNaN(oe)?0:oe*Ni,fr([$t,Math.cos(oe)*Wt,Math.sin(oe)*Wt,ve])}([et,nt??Bs(w,M,l),Bs(B,D,l),Bs(S,z,l)]);return new Ji(st,mt,St,Vt,!1)}case"lab":{let[m,w,B,S]=fr(eo(a.lab,e.lab,l));return new Ji(m,w,B,S,!1)}}},array:eo,padding:function(a,e,l){return new xr(eo(a.values,e.values,l))},variableAnchorOffsetCollection:function(a,e,l){let u=a.values,m=e.values;if(u.length!==m.length)throw new Nr(`Cannot interpolate values of different length. from: ${a.toString()}, to: ${e.toString()}`);let w=[];for(let B=0;Btypeof D!="number"||D<0||D>1))return l.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);m={name:"cubic-bezier",controlPoints:M}}}if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");if(w=l.parse(w,2,Se),!w)return null;let S=[],Q=null;u==="interpolate-hcl"||u==="interpolate-lab"?Q=Zi:l.expectedType&&l.expectedType.kind!=="value"&&(Q=l.expectedType);for(let M=0;M=D)return l.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',et);let st=l.parse(z,nt,Q);if(!st)return null;Q=Q||st.type,S.push([D,st])}return re(Q,Se)||re(Q,Zi)||re(Q,ft)||re(Q,q)||re(Q,rt(Se))?new cn(Q,u,m,w,S):l.error(`Type ${ht(Q)} is not interpolatable.`)}evaluate(e){let l=this.labels,u=this.outputs;if(l.length===1)return u[0].evaluate(e);let m=this.input.evaluate(e);if(m<=l[0])return u[0].evaluate(e);let w=l.length;if(m>=l[w-1])return u[w-1].evaluate(e);let B=ws(l,m),S=cn.interpolationFactor(this.interpolation,m,l[B],l[B+1]),Q=u[B].evaluate(e),M=u[B+1].evaluate(e);switch(this.operator){case"interpolate":return qn[this.type.kind](Q,M,S);case"interpolate-hcl":return qn.color(Q,M,S,"hcl");case"interpolate-lab":return qn.color(Q,M,S,"lab")}}eachChild(e){e(this.input);for(let l of this.outputs)e(l)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function xo(a,e,l,u){let m=u-l,w=a-l;return m===0?0:e===1?w/m:(Math.pow(e,w)-1)/(Math.pow(e,m)-1)}class lr{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expectected at least one argument.");let u=null,m=l.expectedType;m&&m.kind!=="value"&&(u=m);let w=[];for(let S of e.slice(1)){let Q=l.parse(S,1+w.length,u,void 0,{typeAnnotation:"omit"});if(!Q)return null;u=u||Q.type,w.push(Q)}if(!u)throw new Error("No output type");let B=m&&w.some(S=>zt(m,S.type));return new lr(B?vi:u,w)}evaluate(e){let l,u=null,m=0;for(let w of this.args)if(m++,u=w.evaluate(e),u&&u instanceof Dn&&!u.available&&(l||(l=u.name),u=null,m===this.args.length&&(u=l)),u!==null)break;return u}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class Sa{constructor(e,l){this.type=l.type,this.bindings=[].concat(e),this.result=l}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let l of this.bindings)e(l[1]);e(this.result)}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let u=[];for(let w=1;w=u.length)throw new Nr(`Array index out of bounds: ${l} > ${u.length-1}.`);if(l!==Math.floor(l))throw new Nr(`Array index must be an integer, but found ${l} instead.`);return u[l]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class fA{constructor(e,l){this.type=di,this.needle=e,this.haystack=l}static parse(e,l){if(e.length!==3)return l.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,vi);return u&&m?Xt(u.type,[di,$e,Se,We,vi])?new fA(u,m):l.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(u.type)} instead`):null}evaluate(e){let l=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!u)return!1;if(!Mt(l,["boolean","string","number","null"]))throw new Nr(`Expected first argument to be of type boolean, string, number or null, but found ${ht(Qr(l))} instead.`);if(!Mt(u,["string","array"]))throw new Nr(`Expected second argument to be of type array or string, but found ${ht(Qr(u))} instead.`);return u.indexOf(l)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Fa{constructor(e,l,u){this.type=Se,this.needle=e,this.haystack=l,this.fromIndex=u}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,vi);if(!u||!m)return null;if(!Xt(u.type,[di,$e,Se,We,vi]))return l.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(u.type)} instead`);if(e.length===4){let w=l.parse(e[3],3,Se);return w?new Fa(u,m,w):null}return new Fa(u,m)}evaluate(e){let l=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!Mt(l,["boolean","string","number","null"]))throw new Nr(`Expected first argument to be of type boolean, string, number or null, but found ${ht(Qr(l))} instead.`);if(!Mt(u,["string","array"]))throw new Nr(`Expected second argument to be of type array or string, but found ${ht(Qr(u))} instead.`);if(this.fromIndex){let m=this.fromIndex.evaluate(e);return u.indexOf(l,m)}return u.indexOf(l)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class io{constructor(e,l,u,m,w,B){this.inputType=e,this.type=l,this.input=u,this.cases=m,this.outputs=w,this.otherwise=B}static parse(e,l){if(e.length<5)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return l.error("Expected an even number of arguments.");let u,m;l.expectedType&&l.expectedType.kind!=="value"&&(m=l.expectedType);let w={},B=[];for(let M=2;MNumber.MAX_SAFE_INTEGER)return et.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof st=="number"&&Math.floor(st)!==st)return et.error("Numeric branch labels must be integer values.");if(u){if(et.checkSubtype(u,Qr(st)))return null}else u=Qr(st);if(w[String(st)]!==void 0)return et.error("Branch labels must be unique.");w[String(st)]=B.length}let nt=l.parse(z,M,m);if(!nt)return null;m=m||nt.type,B.push(nt)}let S=l.parse(e[1],1,vi);if(!S)return null;let Q=l.parse(e[e.length-1],e.length-1,m);return Q?S.type.kind!=="value"&&l.concat(1).checkSubtype(u,S.type)?null:new io(u,m,S,w,B,Q):null}evaluate(e){let l=this.input.evaluate(e);return(Qr(l)===this.inputType&&this.outputs[this.cases[l]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class So{constructor(e,l,u){this.type=e,this.branches=l,this.otherwise=u}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return l.error("Expected an odd number of arguments.");let u;l.expectedType&&l.expectedType.kind!=="value"&&(u=l.expectedType);let m=[];for(let B=1;Bl.outputDefined())&&this.otherwise.outputDefined()}}class mA{constructor(e,l,u,m){this.type=e,this.input=l,this.beginIndex=u,this.endIndex=m}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,Se);if(!u||!m)return null;if(!Xt(u.type,[rt(vi),$e,vi]))return l.error(`Expected first argument to be of type array or string, but found ${ht(u.type)} instead`);if(e.length===4){let w=l.parse(e[3],3,Se);return w?new mA(u.type,u,m,w):null}return new mA(u.type,u,m)}evaluate(e){let l=this.input.evaluate(e),u=this.beginIndex.evaluate(e);if(!Mt(l,["string","array"]))throw new Nr(`Expected first argument to be of type array or string, but found ${ht(Qr(l))} instead.`);if(this.endIndex){let m=this.endIndex.evaluate(e);return l.slice(u,m)}return l.slice(u)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Jo(a,e){return a==="=="||a==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Rs(a,e,l,u){return u.compare(e,l)===0}function Fo(a,e,l){let u=a!=="=="&&a!=="!=";return class Ab{constructor(w,B,S){this.type=di,this.lhs=w,this.rhs=B,this.collator=S,this.hasUntypedArgument=w.type.kind==="value"||B.type.kind==="value"}static parse(w,B){if(w.length!==3&&w.length!==4)return B.error("Expected two or three arguments.");let S=w[0],Q=B.parse(w[1],1,vi);if(!Q)return null;if(!Jo(S,Q.type))return B.concat(1).error(`"${S}" comparisons are not supported for type '${ht(Q.type)}'.`);let M=B.parse(w[2],2,vi);if(!M)return null;if(!Jo(S,M.type))return B.concat(2).error(`"${S}" comparisons are not supported for type '${ht(M.type)}'.`);if(Q.type.kind!==M.type.kind&&Q.type.kind!=="value"&&M.type.kind!=="value")return B.error(`Cannot compare types '${ht(Q.type)}' and '${ht(M.type)}'.`);u&&(Q.type.kind==="value"&&M.type.kind!=="value"?Q=new Kn(M.type,[Q]):Q.type.kind!=="value"&&M.type.kind==="value"&&(M=new Kn(Q.type,[M])));let D=null;if(w.length===4){if(Q.type.kind!=="string"&&M.type.kind!=="string"&&Q.type.kind!=="value"&&M.type.kind!=="value")return B.error("Cannot use collator to compare non-string types.");if(D=B.parse(w[3],3,tr),!D)return null}return new Ab(Q,M,D)}evaluate(w){let B=this.lhs.evaluate(w),S=this.rhs.evaluate(w);if(u&&this.hasUntypedArgument){let Q=Qr(B),M=Qr(S);if(Q.kind!==M.kind||Q.kind!=="string"&&Q.kind!=="number")throw new Nr(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${Q.kind}, ${M.kind}) instead.`)}if(this.collator&&!u&&this.hasUntypedArgument){let Q=Qr(B),M=Qr(S);if(Q.kind!=="string"||M.kind!=="string")return e(w,B,S)}return this.collator?l(w,B,S,this.collator.evaluate(w)):e(w,B,S)}eachChild(w){w(this.lhs),w(this.rhs),this.collator&&w(this.collator)}outputDefined(){return!0}}}let ka=Fo("==",function(a,e,l){return e===l},Rs),bc=Fo("!=",function(a,e,l){return e!==l},function(a,e,l,u){return!Rs(0,e,l,u)}),CA=Fo("<",function(a,e,l){return e",function(a,e,l){return e>l},function(a,e,l,u){return u.compare(e,l)>0}),il=Fo("<=",function(a,e,l){return e<=l},function(a,e,l,u){return u.compare(e,l)<=0}),rl=Fo(">=",function(a,e,l){return e>=l},function(a,e,l,u){return u.compare(e,l)>=0});class IA{constructor(e,l,u,m,w){this.type=$e,this.number=e,this.locale=l,this.currency=u,this.minFractionDigits=m,this.maxFractionDigits=w}static parse(e,l){if(e.length!==3)return l.error("Expected two arguments.");let u=l.parse(e[1],1,Se);if(!u)return null;let m=e[2];if(typeof m!="object"||Array.isArray(m))return l.error("NumberFormat options argument must be an object.");let w=null;if(m.locale&&(w=l.parse(m.locale,1,$e),!w))return null;let B=null;if(m.currency&&(B=l.parse(m.currency,1,$e),!B))return null;let S=null;if(m["min-fraction-digits"]&&(S=l.parse(m["min-fraction-digits"],1,Se),!S))return null;let Q=null;return m["max-fraction-digits"]&&(Q=l.parse(m["max-fraction-digits"],1,Se),!Q)?null:new IA(u,w,B,S,Q)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Xo{constructor(e){this.type=Lr,this.sections=e}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u=e[1];if(!Array.isArray(u)&&typeof u=="object")return l.error("First argument must be an image or text section.");let m=[],w=!1;for(let B=1;B<=e.length-1;++B){let S=e[B];if(w&&typeof S=="object"&&!Array.isArray(S)){w=!1;let Q=null;if(S["font-scale"]&&(Q=l.parse(S["font-scale"],1,Se),!Q))return null;let M=null;if(S["text-font"]&&(M=l.parse(S["text-font"],1,rt($e)),!M))return null;let D=null;if(S["text-color"]&&(D=l.parse(S["text-color"],1,Zi),!D))return null;let z=m[m.length-1];z.scale=Q,z.font=M,z.textColor=D}else{let Q=l.parse(e[B],1,vi);if(!Q)return null;let M=Q.type.kind;if(M!=="string"&&M!=="value"&&M!=="null"&&M!=="resolvedImage")return l.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");w=!0,m.push({content:Q,scale:null,font:null,textColor:null})}}return new Xo(m)}evaluate(e){return new Sr(this.sections.map(l=>{let u=l.content.evaluate(e);return Qr(u)===Y?new vs("",u,null,null,null):new vs(zo(u),null,l.scale?l.scale.evaluate(e):null,l.font?l.font.evaluate(e).join(","):null,l.textColor?l.textColor.evaluate(e):null)}))}eachChild(e){for(let l of this.sections)e(l.content),l.scale&&e(l.scale),l.font&&e(l.font),l.textColor&&e(l.textColor)}outputDefined(){return!1}}class La{constructor(e){this.type=Y,this.input=e}static parse(e,l){if(e.length!==2)return l.error("Expected two arguments.");let u=l.parse(e[1],1,$e);return u?new La(u):l.error("No image name provided.")}evaluate(e){let l=this.input.evaluate(e),u=Dn.fromString(l);return u&&e.availableImages&&(u.available=e.availableImages.indexOf(l)>-1),u}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ea{constructor(e){this.type=Se,this.input=e}static parse(e,l){if(e.length!==2)return l.error(`Expected 1 argument, but found ${e.length-1} instead.`);let u=l.parse(e[1],1);return u?u.type.kind!=="array"&&u.type.kind!=="string"&&u.type.kind!=="value"?l.error(`Expected argument of type string or array, but found ${ht(u.type)} instead.`):new Ea(u):null}evaluate(e){let l=this.input.evaluate(e);if(typeof l=="string"||Array.isArray(l))return l.length;throw new Nr(`Expected value to be of type string or array, but found ${ht(Qr(l))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Yo={"==":ka,"!=":bc,">":vc,"<":CA,">=":rl,"<=":il,array:Kn,at:pA,boolean:Kn,case:So,coalesce:lr,collator:Kt,format:Xo,image:La,in:fA,"index-of":Fa,interpolate:cn,"interpolate-hcl":cn,"interpolate-lab":cn,length:Ea,let:Sa,literal:Fr,match:io,number:Kn,"number-format":IA,object:Kn,slice:mA,step:_o,string:Kn,"to-boolean":pt,"to-color":pt,"to-number":pt,"to-string":pt,var:ai,within:nr};function Tl(a,[e,l,u,m]){e=e.evaluate(a),l=l.evaluate(a),u=u.evaluate(a);let w=m?m.evaluate(a):1,B=Oo(e,l,u,w);if(B)throw new Nr(B);return new Ji(e/255,l/255,u/255,w,!1)}function Ta(a,e){return a in e}function jo(a,e){let l=e[a];return l===void 0?null:l}function ro(a){return{type:a}}function qo(a){return{result:"success",value:a}}function ko(a){return{result:"error",value:a}}function U(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function it(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Et(a){return!!a.expression&&a.expression.interpolated}function Nt(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":a===null?"null":typeof a}function ue(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function we(a){return a}function Ve(a,e){let l=e.type==="color",u=a.stops&&typeof a.stops[0][0]=="object",m=u||!(u||a.property!==void 0),w=a.type||(Et(e)?"exponential":"interval");if(l||e.type==="padding"){let D=l?Ji.parse:xr.parse;(a=Oi({},a)).stops&&(a.stops=a.stops.map(z=>[z[0],D(z[1])])),a.default=D(a.default?a.default:e.default)}if(a.colorSpace&&(B=a.colorSpace)!=="rgb"&&B!=="hcl"&&B!=="lab")throw new Error(`Unknown color space: "${a.colorSpace}"`);var B;let S,Q,M;if(w==="exponential")S=ar;else if(w==="interval")S=xi;else if(w==="categorical"){S=Di,Q=Object.create(null);for(let D of a.stops)Q[D[0]]=D[1];M=typeof a.stops[0][0]}else{if(w!=="identity")throw new Error(`Unknown function type "${w}"`);S=Ci}if(u){let D={},z=[];for(let st=0;stst[0]),evaluate:({zoom:st},mt)=>ar({stops:et,base:a.base},e,st).evaluate(st,mt)}}if(m){let D=w==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:D,interpolationFactor:cn.interpolationFactor.bind(void 0,D),zoomStops:a.stops.map(z=>z[0]),evaluate:({zoom:z})=>S(a,e,z,Q,M)}}return{kind:"source",evaluate(D,z){let et=z&&z.properties?z.properties[a.property]:void 0;return et===void 0?li(a.default,e.default):S(a,e,et,Q,M)}}}function li(a,e,l){return a!==void 0?a:e!==void 0?e:l!==void 0?l:void 0}function Di(a,e,l,u,m){return li(typeof l===m?u[l]:void 0,a.default,e.default)}function xi(a,e,l){if(Nt(l)!=="number")return li(a.default,e.default);let u=a.stops.length;if(u===1||l<=a.stops[0][0])return a.stops[0][1];if(l>=a.stops[u-1][0])return a.stops[u-1][1];let m=ws(a.stops.map(w=>w[0]),l);return a.stops[m][1]}function ar(a,e,l){let u=a.base!==void 0?a.base:1;if(Nt(l)!=="number")return li(a.default,e.default);let m=a.stops.length;if(m===1||l<=a.stops[0][0])return a.stops[0][1];if(l>=a.stops[m-1][0])return a.stops[m-1][1];let w=ws(a.stops.map(D=>D[0]),l),B=function(D,z,et,nt){let st=nt-et,mt=D-et;return st===0?0:z===1?mt/st:(Math.pow(z,mt)-1)/(Math.pow(z,st)-1)}(l,u,a.stops[w][0],a.stops[w+1][0]),S=a.stops[w][1],Q=a.stops[w+1][1],M=qn[e.type]||we;return typeof S.evaluate=="function"?{evaluate(...D){let z=S.evaluate.apply(void 0,D),et=Q.evaluate.apply(void 0,D);if(z!==void 0&&et!==void 0)return M(z,et,B,a.colorSpace)}}:M(S,Q,B,a.colorSpace)}function Ci(a,e,l){switch(e.type){case"color":l=Ji.parse(l);break;case"formatted":l=Sr.fromString(l.toString());break;case"resolvedImage":l=Dn.fromString(l.toString());break;case"padding":l=xr.parse(l);break;default:Nt(l)===e.type||e.type==="enum"&&e.values[l]||(l=void 0)}return li(l,a.default,e.default)}dr.register(Yo,{error:[{kind:"error"},[$e],(a,[e])=>{throw new Nr(e.evaluate(a))}],typeof:[$e,[vi],(a,[e])=>ht(Qr(e.evaluate(a)))],"to-rgba":[rt(Se,4),[Zi],(a,[e])=>{let[l,u,m,w]=e.evaluate(a).rgb;return[255*l,255*u,255*m,w]}],rgb:[Zi,[Se,Se,Se],Tl],rgba:[Zi,[Se,Se,Se,Se],Tl],has:{type:di,overloads:[[[$e],(a,[e])=>Ta(e.evaluate(a),a.properties())],[[$e,qi],(a,[e,l])=>Ta(e.evaluate(a),l.evaluate(a))]]},get:{type:vi,overloads:[[[$e],(a,[e])=>jo(e.evaluate(a),a.properties())],[[$e,qi],(a,[e,l])=>jo(e.evaluate(a),l.evaluate(a))]]},"feature-state":[vi,[$e],(a,[e])=>jo(e.evaluate(a),a.featureState||{})],properties:[qi,[],a=>a.properties()],"geometry-type":[$e,[],a=>a.geometryType()],id:[vi,[],a=>a.id()],zoom:[Se,[],a=>a.globals.zoom],"heatmap-density":[Se,[],a=>a.globals.heatmapDensity||0],"line-progress":[Se,[],a=>a.globals.lineProgress||0],accumulated:[vi,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[Se,ro(Se),(a,e)=>{let l=0;for(let u of e)l+=u.evaluate(a);return l}],"*":[Se,ro(Se),(a,e)=>{let l=1;for(let u of e)l*=u.evaluate(a);return l}],"-":{type:Se,overloads:[[[Se,Se],(a,[e,l])=>e.evaluate(a)-l.evaluate(a)],[[Se],(a,[e])=>-e.evaluate(a)]]},"/":[Se,[Se,Se],(a,[e,l])=>e.evaluate(a)/l.evaluate(a)],"%":[Se,[Se,Se],(a,[e,l])=>e.evaluate(a)%l.evaluate(a)],ln2:[Se,[],()=>Math.LN2],pi:[Se,[],()=>Math.PI],e:[Se,[],()=>Math.E],"^":[Se,[Se,Se],(a,[e,l])=>Math.pow(e.evaluate(a),l.evaluate(a))],sqrt:[Se,[Se],(a,[e])=>Math.sqrt(e.evaluate(a))],log10:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))/Math.LN10],ln:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))],log2:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))/Math.LN2],sin:[Se,[Se],(a,[e])=>Math.sin(e.evaluate(a))],cos:[Se,[Se],(a,[e])=>Math.cos(e.evaluate(a))],tan:[Se,[Se],(a,[e])=>Math.tan(e.evaluate(a))],asin:[Se,[Se],(a,[e])=>Math.asin(e.evaluate(a))],acos:[Se,[Se],(a,[e])=>Math.acos(e.evaluate(a))],atan:[Se,[Se],(a,[e])=>Math.atan(e.evaluate(a))],min:[Se,ro(Se),(a,e)=>Math.min(...e.map(l=>l.evaluate(a)))],max:[Se,ro(Se),(a,e)=>Math.max(...e.map(l=>l.evaluate(a)))],abs:[Se,[Se],(a,[e])=>Math.abs(e.evaluate(a))],round:[Se,[Se],(a,[e])=>{let l=e.evaluate(a);return l<0?-Math.round(-l):Math.round(l)}],floor:[Se,[Se],(a,[e])=>Math.floor(e.evaluate(a))],ceil:[Se,[Se],(a,[e])=>Math.ceil(e.evaluate(a))],"filter-==":[di,[$e,vi],(a,[e,l])=>a.properties()[e.value]===l.value],"filter-id-==":[di,[vi],(a,[e])=>a.id()===e.value],"filter-type-==":[di,[$e],(a,[e])=>a.geometryType()===e.value],"filter-<":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u{let l=a.id(),u=e.value;return typeof l==typeof u&&l":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u>m}],"filter-id->":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l>u}],"filter-<=":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u<=m}],"filter-id-<=":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l<=u}],"filter->=":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u>=m}],"filter-id->=":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l>=u}],"filter-has":[di,[vi],(a,[e])=>e.value in a.properties()],"filter-has-id":[di,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[di,[rt($e)],(a,[e])=>e.value.indexOf(a.geometryType())>=0],"filter-id-in":[di,[rt(vi)],(a,[e])=>e.value.indexOf(a.id())>=0],"filter-in-small":[di,[$e,rt(vi)],(a,[e,l])=>l.value.indexOf(a.properties()[e.value])>=0],"filter-in-large":[di,[$e,rt(vi)],(a,[e,l])=>function(u,m,w,B){for(;w<=B;){let S=w+B>>1;if(m[S]===u)return!0;m[S]>u?B=S-1:w=S+1}return!1}(a.properties()[e.value],l.value,0,l.value.length-1)],all:{type:di,overloads:[[[di,di],(a,[e,l])=>e.evaluate(a)&&l.evaluate(a)],[ro(di),(a,e)=>{for(let l of e)if(!l.evaluate(a))return!1;return!0}]]},any:{type:di,overloads:[[[di,di],(a,[e,l])=>e.evaluate(a)||l.evaluate(a)],[ro(di),(a,e)=>{for(let l of e)if(l.evaluate(a))return!0;return!1}]]},"!":[di,[di],(a,[e])=>!e.evaluate(a)],"is-supported-script":[di,[$e],(a,[e])=>{let l=a.globals&&a.globals.isSupportedScript;return!l||l(e.evaluate(a))}],upcase:[$e,[$e],(a,[e])=>e.evaluate(a).toUpperCase()],downcase:[$e,[$e],(a,[e])=>e.evaluate(a).toLowerCase()],concat:[$e,ro(vi),(a,e)=>e.map(l=>zo(l.evaluate(a))).join("")],"resolved-locale":[$e,[tr],(a,[e])=>e.evaluate(a).resolvedLocale()]});class Vr{constructor(e,l){var u;this.expression=e,this._warningHistory={},this._evaluator=new ct,this._defaultValue=l?(u=l).type==="color"&&ue(u.default)?new Ji(0,0,0,0):u.type==="color"?Ji.parse(u.default)||null:u.type==="padding"?xr.parse(u.default)||null:u.type==="variableAnchorOffsetCollection"?an.parse(u.default)||null:u.default===void 0?null:u.default:null,this._enumValues=l&&l.type==="enum"?l.values:null}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._evaluator.globals=e,this._evaluator.feature=l,this._evaluator.featureState=u,this._evaluator.canonical=m,this._evaluator.availableImages=w||null,this._evaluator.formattedSection=B,this.expression.evaluate(this._evaluator)}evaluate(e,l,u,m,w,B){this._evaluator.globals=e,this._evaluator.feature=l||null,this._evaluator.featureState=u||null,this._evaluator.canonical=m,this._evaluator.availableImages=w||null,this._evaluator.formattedSection=B||null;try{let S=this.expression.evaluate(this._evaluator);if(S==null||typeof S=="number"&&S!=S)return this._defaultValue;if(this._enumValues&&!(S in this._enumValues))throw new Nr(`Expected value to be one of ${Object.keys(this._enumValues).map(Q=>JSON.stringify(Q)).join(", ")}, but found ${JSON.stringify(S)} instead.`);return S}catch(S){return this._warningHistory[S.message]||(this._warningHistory[S.message]=!0,typeof console<"u"&&console.warn(S.message)),this._defaultValue}}}function Xi(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Yo}function Yi(a,e){let l=new Bt(Yo,Or,[],e?function(m){let w={color:Zi,string:$e,number:Se,enum:$e,boolean:di,formatted:Lr,padding:ft,resolvedImage:Y,variableAnchorOffsetCollection:q};return m.type==="array"?rt(w[m.value]||vi,m.length):w[m.type]}(e):void 0),u=l.parse(a,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?qo(new Vr(u,e)):ko(l.errors)}class un{constructor(e,l){this.kind=e,this._styleExpression=l,this.isStateDependent=e!=="constant"&&!_n(l.expression)}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._styleExpression.evaluateWithoutErrorHandling(e,l,u,m,w,B)}evaluate(e,l,u,m,w,B){return this._styleExpression.evaluate(e,l,u,m,w,B)}}class hn{constructor(e,l,u,m){this.kind=e,this.zoomStops=u,this._styleExpression=l,this.isStateDependent=e!=="camera"&&!_n(l.expression),this.interpolationType=m}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._styleExpression.evaluateWithoutErrorHandling(e,l,u,m,w,B)}evaluate(e,l,u,m,w,B){return this._styleExpression.evaluate(e,l,u,m,w,B)}interpolationFactor(e,l,u){return this.interpolationType?cn.interpolationFactor(this.interpolationType,e,l,u):0}}function Hs(a,e){let l=Yi(a,e);if(l.result==="error")return l;let u=l.value.expression,m=Ur(u);if(!m&&!U(e))return ko([new mi("","data expressions not supported")]);let w=vn(u,["zoom"]);if(!w&&!it(e))return ko([new mi("","zoom expressions not supported")]);let B=Zs(u);return B||w?B instanceof mi?ko([B]):B instanceof cn&&!Et(e)?ko([new mi("",'"interpolate" expressions cannot be used with this property')]):qo(B?new hn(m?"camera":"composite",l.value,B.labels,B instanceof cn?B.interpolation:void 0):new un(m?"constant":"source",l.value)):ko([new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class $n{constructor(e,l){this._parameters=e,this._specification=l,Oi(this,Ve(this._parameters,this._specification))}static deserialize(e){return new $n(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Zs(a){let e=null;if(a instanceof Sa)e=Zs(a.result);else if(a instanceof lr){for(let l of a.args)if(e=Zs(l),e)break}else(a instanceof _o||a instanceof cn)&&a.input instanceof dr&&a.input.name==="zoom"&&(e=a);return e instanceof mi||a.eachChild(l=>{let u=Zs(l);u instanceof mi?e=u:!e&&u?e=new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&u&&e!==u&&(e=new mi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function yA(a){if(a===!0||a===!1)return!0;if(!Array.isArray(a)||a.length===0)return!1;switch(a[0]){case"has":return a.length>=2&&a[1]!=="$id"&&a[1]!=="$type";case"in":return a.length>=3&&(typeof a[1]!="string"||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return a.length!==3||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(let e of a.slice(1))if(!yA(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}let bA={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ga(a){if(a==null)return{filter:()=>!0,needGeometry:!1};yA(a)||(a=Lo(a));let e=Yi(a,bA);if(e.result==="error")throw new Error(e.value.map(l=>`${l.key}: ${l.message}`).join(", "));return{filter:(l,u,m)=>e.value.evaluate(l,u,{},m),needGeometry:Ua(a)}}function Qa(a,e){return ae?1:0}function Ua(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?da(a[1],a[2],e):e==="any"?(l=a.slice(1),["any"].concat(l.map(Lo))):e==="all"?["all"].concat(a.slice(1).map(Lo)):e==="none"?["all"].concat(a.slice(1).map(Lo).map($o)):e==="in"?ts(a[1],a.slice(2)):e==="!in"?$o(ts(a[1],a.slice(2))):e==="has"?Ga(a[1]):e==="!has"?$o(Ga(a[1])):e!=="within"||a;var l}function da(a,e,l){switch(a){case"$type":return[`filter-type-${l}`,e];case"$id":return[`filter-id-${l}`,e];default:return[`filter-${l}`,a,e]}}function ts(a,e){if(e.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(l=>typeof l!=typeof e[0])?["filter-in-large",a,["literal",e.sort(Qa)]]:["filter-in-small",a,["literal",e]]}}function Ga(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function $o(a){return["!",a]}function pa(a){let e=typeof a;if(e==="number"||e==="boolean"||e==="string"||a==null)return JSON.stringify(a);if(Array.isArray(a)){let m="[";for(let w of a)m+=`${pa(w)},`;return`${m}]`}let l=Object.keys(a).sort(),u="{";for(let m=0;mu.maximum?[new Ie(e,l,`${l} is greater than the maximum value ${u.maximum}`)]:[]}function sl(a){let e=a.valueSpec,l=zr(a.value.type),u,m,w,B={},S=l!=="categorical"&&a.value.property===void 0,Q=!S,M=Nt(a.value.stops)==="array"&&Nt(a.value.stops[0])==="array"&&Nt(a.value.stops[0][0])==="object",D=Wn({key:a.key,value:a.value,valueSpec:a.styleSpec.function,validateSpec:a.validateSpec,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(nt){if(l==="identity")return[new Ie(nt.key,nt.value,'identity function may not have a "stops" property')];let st=[],mt=nt.value;return st=st.concat(On({key:nt.key,value:mt,valueSpec:nt.valueSpec,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec,arrayElementValidator:z})),Nt(mt)==="array"&&mt.length===0&&st.push(new Ie(nt.key,mt,"array must have at least one stop")),st},default:function(nt){return nt.validateSpec({key:nt.key,value:nt.value,valueSpec:e,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec})}}});return l==="identity"&&S&&D.push(new Ie(a.key,a.value,'missing required property "property"')),l==="identity"||a.value.stops||D.push(new Ie(a.key,a.value,'missing required property "stops"')),l==="exponential"&&a.valueSpec.expression&&!Et(a.valueSpec)&&D.push(new Ie(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(Q&&!U(a.valueSpec)?D.push(new Ie(a.key,a.value,"property functions not supported")):S&&!it(a.valueSpec)&&D.push(new Ie(a.key,a.value,"zoom functions not supported"))),l!=="categorical"&&!M||a.value.property!==void 0||D.push(new Ie(a.key,a.value,'"property" property is required')),D;function z(nt){let st=[],mt=nt.value,St=nt.key;if(Nt(mt)!=="array")return[new Ie(St,mt,`array expected, ${Nt(mt)} found`)];if(mt.length!==2)return[new Ie(St,mt,`array length 2 expected, length ${mt.length} found`)];if(M){if(Nt(mt[0])!=="object")return[new Ie(St,mt,`object expected, ${Nt(mt[0])} found`)];if(mt[0].zoom===void 0)return[new Ie(St,mt,"object stop key must have zoom")];if(mt[0].value===void 0)return[new Ie(St,mt,"object stop key must have value")];if(w&&w>zr(mt[0].zoom))return[new Ie(St,mt[0].zoom,"stop zoom values must appear in ascending order")];zr(mt[0].zoom)!==w&&(w=zr(mt[0].zoom),m=void 0,B={}),st=st.concat(Wn({key:`${St}[0]`,value:mt[0],valueSpec:{zoom:{}},validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec,objectElementValidators:{zoom:Ra,value:et}}))}else st=st.concat(et({key:`${St}[0]`,value:mt[0],valueSpec:{},validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec},mt));return Xi(Ps(mt[1]))?st.concat([new Ie(`${St}[1]`,mt[1],"expressions are not allowed in function stops.")]):st.concat(nt.validateSpec({key:`${St}[1]`,value:mt[1],valueSpec:e,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec}))}function et(nt,st){let mt=Nt(nt.value),St=zr(nt.value),Vt=nt.value!==null?nt.value:st;if(u){if(mt!==u)return[new Ie(nt.key,Vt,`${mt} stop domain type must match previous stop domain type ${u}`)]}else u=mt;if(mt!=="number"&&mt!=="string"&&mt!=="boolean")return[new Ie(nt.key,Vt,"stop domain value must be a number, string, or boolean")];if(mt!=="number"&&l!=="categorical"){let oe=`number expected, ${mt} found`;return U(e)&&l===void 0&&(oe+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ie(nt.key,Vt,oe)]}return l!=="categorical"||mt!=="number"||isFinite(St)&&Math.floor(St)===St?l!=="categorical"&&mt==="number"&&m!==void 0&&Stnew Ie(`${a.key}${u.key}`,a.value,u.message));let l=e.value.expression||e.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!l.outputDefined())return[new Ie(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!_n(l))return[new Ie(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter"&&!_n(l))return[new Ie(a.key,a.value,'"feature-state" data expressions are not supported with filters.')];if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!vn(l,["zoom","feature-state"]))return[new Ie(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!Ur(l))return[new Ie(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ls(a){let e=a.key,l=a.value,u=a.valueSpec,m=[];return Array.isArray(u.values)?u.values.indexOf(zr(l))===-1&&m.push(new Ie(e,l,`expected one of [${u.values.join(", ")}], ${JSON.stringify(l)} found`)):Object.keys(u.values).indexOf(zr(l))===-1&&m.push(new Ie(e,l,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(l)} found`)),m}function xn(a){return yA(Ps(a.value))?fa(Oi({},a,{expressionContext:"filter",valueSpec:{value:"boolean"}})):is(a)}function is(a){let e=a.value,l=a.key;if(Nt(e)!=="array")return[new Ie(l,e,`array expected, ${Nt(e)} found`)];let u=a.styleSpec,m,w=[];if(e.length<1)return[new Ie(l,e,"filter array must have at least 1 element")];switch(w=w.concat(ls({key:`${l}[0]`,value:e[0],valueSpec:u.filter_operator,style:a.style,styleSpec:a.styleSpec})),zr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&zr(e[1])==="$type"&&w.push(new Ie(l,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&w.push(new Ie(l,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(m=Nt(e[1]),m!=="string"&&w.push(new Ie(`${l}[1]`,e[1],`string expected, ${m} found`)));for(let B=2;B{M in l&&e.push(new Ie(u,l[M],`"${M}" is prohibited for ref layers`))}),m.layers.forEach(M=>{zr(M.id)===S&&(Q=M)}),Q?Q.ref?e.push(new Ie(u,l.ref,"ref cannot reference another ref layer")):B=zr(Q.type):e.push(new Ie(u,l.ref,`ref layer "${S}" not found`))}else if(B!=="background")if(l.source){let Q=m.sources&&m.sources[l.source],M=Q&&zr(Q.type);Q?M==="vector"&&B==="raster"?e.push(new Ie(u,l.source,`layer "${l.id}" requires a raster source`)):M!=="raster-dem"&&B==="hillshade"?e.push(new Ie(u,l.source,`layer "${l.id}" requires a raster-dem source`)):M==="raster"&&B!=="raster"?e.push(new Ie(u,l.source,`layer "${l.id}" requires a vector source`)):M!=="vector"||l["source-layer"]?M==="raster-dem"&&B!=="hillshade"?e.push(new Ie(u,l.source,"raster-dem source can only be used with layer type 'hillshade'.")):B!=="line"||!l.paint||!l.paint["line-gradient"]||M==="geojson"&&Q.lineMetrics||e.push(new Ie(u,l,`layer "${l.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ie(u,l,`layer "${l.id}" must specify a "source-layer"`)):e.push(new Ie(u,l.source,`source "${l.source}" not found`))}else e.push(new Ie(u,l,'missing required property "source"'));return e=e.concat(Wn({key:u,value:l,valueSpec:w.layer,style:a.style,styleSpec:a.styleSpec,validateSpec:a.validateSpec,objectElementValidators:{"*":()=>[],type:()=>a.validateSpec({key:`${u}.type`,value:l.type,valueSpec:w.layer.type,style:a.style,styleSpec:a.styleSpec,validateSpec:a.validateSpec,object:l,objectKey:"type"}),filter:xn,layout:Q=>Wn({layer:l,key:Q.key,value:Q.value,style:Q.style,styleSpec:Q.styleSpec,validateSpec:Q.validateSpec,objectElementValidators:{"*":M=>no(Oi({layerType:B},M))}}),paint:Q=>Wn({layer:l,key:Q.key,value:Q.value,style:Q.style,styleSpec:Q.styleSpec,validateSpec:Q.validateSpec,objectElementValidators:{"*":M=>_s(Oi({layerType:B},M))}})}})),e}function fn(a){let e=a.value,l=a.key,u=Nt(e);return u!=="string"?[new Ie(l,e,`string expected, ${u} found`)]:[]}let Ha={promoteId:function({key:a,value:e}){if(Nt(e)==="string")return fn({key:a,value:e});{let l=[];for(let u in e)l.push(...fn({key:`${a}.${u}`,value:e[u]}));return l}}};function vA(a){let e=a.value,l=a.key,u=a.styleSpec,m=a.style,w=a.validateSpec;if(!e.type)return[new Ie(l,e,'"type" is required')];let B=zr(e.type),S;switch(B){case"vector":case"raster":return S=Wn({key:l,value:e,valueSpec:u[`source_${B.replace("-","_")}`],style:a.style,styleSpec:u,objectElementValidators:Ha,validateSpec:w}),S;case"raster-dem":return S=function(Q){var M;let D=(M=Q.sourceName)!==null&&M!==void 0?M:"",z=Q.value,et=Q.styleSpec,nt=et.source_raster_dem,st=Q.style,mt=[],St=Nt(z);if(z===void 0)return mt;if(St!=="object")return mt.push(new Ie("source_raster_dem",z,`object expected, ${St} found`)),mt;let Vt=zr(z.encoding)==="custom",oe=["redFactor","greenFactor","blueFactor","baseShift"],Wt=Q.value.encoding?`"${Q.value.encoding}"`:"Default";for(let $t in z)!Vt&&oe.includes($t)?mt.push(new Ie($t,z[$t],`In "${D}": "${$t}" is only valid when "encoding" is set to "custom". ${Wt} encoding found`)):nt[$t]?mt=mt.concat(Q.validateSpec({key:$t,value:z[$t],valueSpec:nt[$t],validateSpec:Q.validateSpec,style:st,styleSpec:et})):mt.push(new Ie($t,z[$t],`unknown property "${$t}"`));return mt}({sourceName:l,value:e,style:a.style,styleSpec:u,validateSpec:w}),S;case"geojson":if(S=Wn({key:l,value:e,valueSpec:u.source_geojson,style:m,styleSpec:u,validateSpec:w,objectElementValidators:Ha}),e.cluster)for(let Q in e.clusterProperties){let[M,D]=e.clusterProperties[Q],z=typeof M=="string"?[M,["accumulated"],["get",Q]]:M;S.push(...fa({key:`${l}.${Q}.map`,value:D,validateSpec:w,expressionContext:"cluster-map"})),S.push(...fa({key:`${l}.${Q}.reduce`,value:z,validateSpec:w,expressionContext:"cluster-reduce"}))}return S;case"video":return Wn({key:l,value:e,valueSpec:u.source_video,style:m,validateSpec:w,styleSpec:u});case"image":return Wn({key:l,value:e,valueSpec:u.source_image,style:m,validateSpec:w,styleSpec:u});case"canvas":return[new Ie(l,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ls({key:`${l}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:m,validateSpec:w,styleSpec:u})}}function ta(a){let e=a.value,l=a.styleSpec,u=l.light,m=a.style,w=[],B=Nt(e);if(e===void 0)return w;if(B!=="object")return w=w.concat([new Ie("light",e,`object expected, ${B} found`)]),w;for(let S in e){let Q=S.match(/^(.*)-transition$/);w=w.concat(Q&&u[Q[1]]&&u[Q[1]].transition?a.validateSpec({key:S,value:e[S],valueSpec:l.transition,validateSpec:a.validateSpec,style:m,styleSpec:l}):u[S]?a.validateSpec({key:S,value:e[S],valueSpec:u[S],validateSpec:a.validateSpec,style:m,styleSpec:l}):[new Ie(S,e[S],`unknown property "${S}"`)])}return w}function Ms(a){let e=a.value,l=a.styleSpec,u=l.sky,m=a.style,w=Nt(e);if(e===void 0)return[];if(w!=="object")return[new Ie("sky",e,`object expected, ${w} found`)];let B=[];for(let S in e)B=B.concat(u[S]?Jr({key:S,value:e[S],valueSpec:u[S],style:m,styleSpec:l}):[new Ie(S,e[S],`unknown property "${S}"`)]);return B}function To(a){let e=a.value,l=a.styleSpec,u=l.terrain,m=a.style,w=[],B=Nt(e);if(e===void 0)return w;if(B!=="object")return w=w.concat([new Ie("terrain",e,`object expected, ${B} found`)]),w;for(let S in e)w=w.concat(u[S]?a.validateSpec({key:S,value:e[S],valueSpec:u[S],validateSpec:a.validateSpec,style:m,styleSpec:l}):[new Ie(S,e[S],`unknown property "${S}"`)]);return w}function so(a){let e=[],l=a.value,u=a.key;if(Array.isArray(l)){let m=[],w=[];for(let B in l)l[B].id&&m.includes(l[B].id)&&e.push(new Ie(u,l,`all the sprites' ids must be unique, but ${l[B].id} is duplicated`)),m.push(l[B].id),l[B].url&&w.includes(l[B].url)&&e.push(new Ie(u,l,`all the sprites' URLs must be unique, but ${l[B].url} is duplicated`)),w.push(l[B].url),e=e.concat(Wn({key:`${u}[${B}]`,value:l[B],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:a.validateSpec}));return e}return fn({key:u,value:l})}let Qo={"*":()=>[],array:On,boolean:function(a){let e=a.value,l=a.key,u=Nt(e);return u!=="boolean"?[new Ie(l,e,`boolean expected, ${u} found`)]:[]},number:Ra,color:function(a){let e=a.key,l=a.value,u=Nt(l);return u!=="string"?[new Ie(e,l,`color expected, ${u} found`)]:Ji.parse(String(l))?[]:[new Ie(e,l,`color expected, "${l}" found`)]},constants:es,enum:ls,filter:xn,function:sl,layer:ma,object:Wn,source:vA,light:ta,sky:Ms,terrain:To,string:fn,formatted:function(a){return fn(a).length===0?[]:fa(a)},resolvedImage:function(a){return fn(a).length===0?[]:fa(a)},padding:function(a){let e=a.key,l=a.value;if(Nt(l)==="array"){if(l.length<1||l.length>4)return[new Ie(e,l,`padding requires 1 to 4 values; ${l.length} values found`)];let u={type:"number"},m=[];for(let w=0;w[]}})),a.constants&&(l=l.concat(es({key:"constants",value:a.constants,style:a,styleSpec:e,validateSpec:Jr}))),Uo(l)}function gn(a){return function(e){return a({...e,validateSpec:Jr})}}function Uo(a){return[].concat(a).sort((e,l)=>e.line-l.line)}function pr(a){return function(...e){return Uo(a.apply(this,e))}}zn.source=pr(gn(vA)),zn.sprite=pr(gn(so)),zn.glyphs=pr(gn(xs)),zn.light=pr(gn(ta)),zn.sky=pr(gn(Ms)),zn.terrain=pr(gn(To)),zn.layer=pr(gn(ma)),zn.filter=pr(gn(xn)),zn.paintProperty=pr(gn(_s)),zn.layoutProperty=pr(gn(no));let kr=zn,en=kr.light,yn=kr.paintProperty,oo=kr.layoutProperty;function ea(a,e){let l=!1;if(e&&e.length)for(let u of e)a.fire(new Me(new Error(u.message))),l=!0;return l}class cs{constructor(e,l,u){let m=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let B=new Int32Array(this.arrayBuffer);e=B[0],this.d=(l=B[1])+2*(u=B[2]);for(let Q=0;Q=z[st+0]&&m>=z[st+1])?(S[nt]=!0,B.push(D[nt])):S[nt]=!1}}}}_forEachCell(e,l,u,m,w,B,S,Q){let M=this._convertToCellCoord(e),D=this._convertToCellCoord(l),z=this._convertToCellCoord(u),et=this._convertToCellCoord(m);for(let nt=M;nt<=z;nt++)for(let st=D;st<=et;st++){let mt=this.d*st+nt;if((!Q||Q(this._convertFromCellCoord(nt),this._convertFromCellCoord(st),this._convertFromCellCoord(nt+1),this._convertFromCellCoord(st+1)))&&w.call(this,e,l,u,m,mt,B,S,Q))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,l=3+this.cells.length+1+1,u=0;for(let B=0;B=0)continue;let B=a[w];m[w]=ao[u].shallow.indexOf(w)>=0?B:Ca(B,e)}a instanceof Error&&(m.message=a.message)}if(m.$name)throw new Error("$name property is reserved for worker serialization logic.");return u!=="Object"&&(m.$name=u),m}throw new Error("can't serialize object of type "+typeof a)}function Za(a){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||a instanceof Blob||a instanceof Error||Ql(a)||ie(a)||ArrayBuffer.isView(a)||a instanceof ImageData)return a;if(Array.isArray(a))return a.map(Za);if(typeof a=="object"){let e=a.$name||"Object";if(!ao[e])throw new Error(`can't deserialize unregistered class ${e}`);let{klass:l}=ao[e];if(!l)throw new Error(`can't deserialize unregistered class ${e}`);if(l.deserialize)return l.deserialize(a);let u=Object.create(l.prototype);for(let m of Object.keys(a)){if(m==="$name")continue;let w=a[m];u[m]=ao[e].shallow.indexOf(m)>=0?w:Za(w)}return u}throw new Error("can't deserialize object of type "+typeof a)}class Ul{constructor(){this.first=!0}update(e,l){let u=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=l):this.lastFloorZooma>=128&&a<=255,Arabic:a=>a>=1536&&a<=1791,"Arabic Supplement":a=>a>=1872&&a<=1919,"Arabic Extended-A":a=>a>=2208&&a<=2303,"Hangul Jamo":a=>a>=4352&&a<=4607,"Unified Canadian Aboriginal Syllabics":a=>a>=5120&&a<=5759,Khmer:a=>a>=6016&&a<=6143,"Unified Canadian Aboriginal Syllabics Extended":a=>a>=6320&&a<=6399,"General Punctuation":a=>a>=8192&&a<=8303,"Letterlike Symbols":a=>a>=8448&&a<=8527,"Number Forms":a=>a>=8528&&a<=8591,"Miscellaneous Technical":a=>a>=8960&&a<=9215,"Control Pictures":a=>a>=9216&&a<=9279,"Optical Character Recognition":a=>a>=9280&&a<=9311,"Enclosed Alphanumerics":a=>a>=9312&&a<=9471,"Geometric Shapes":a=>a>=9632&&a<=9727,"Miscellaneous Symbols":a=>a>=9728&&a<=9983,"Miscellaneous Symbols and Arrows":a=>a>=11008&&a<=11263,"CJK Radicals Supplement":a=>a>=11904&&a<=12031,"Kangxi Radicals":a=>a>=12032&&a<=12255,"Ideographic Description Characters":a=>a>=12272&&a<=12287,"CJK Symbols and Punctuation":a=>a>=12288&&a<=12351,Hiragana:a=>a>=12352&&a<=12447,Katakana:a=>a>=12448&&a<=12543,Bopomofo:a=>a>=12544&&a<=12591,"Hangul Compatibility Jamo":a=>a>=12592&&a<=12687,Kanbun:a=>a>=12688&&a<=12703,"Bopomofo Extended":a=>a>=12704&&a<=12735,"CJK Strokes":a=>a>=12736&&a<=12783,"Katakana Phonetic Extensions":a=>a>=12784&&a<=12799,"Enclosed CJK Letters and Months":a=>a>=12800&&a<=13055,"CJK Compatibility":a=>a>=13056&&a<=13311,"CJK Unified Ideographs Extension A":a=>a>=13312&&a<=19903,"Yijing Hexagram Symbols":a=>a>=19904&&a<=19967,"CJK Unified Ideographs":a=>a>=19968&&a<=40959,"Yi Syllables":a=>a>=40960&&a<=42127,"Yi Radicals":a=>a>=42128&&a<=42191,"Hangul Jamo Extended-A":a=>a>=43360&&a<=43391,"Hangul Syllables":a=>a>=44032&&a<=55215,"Hangul Jamo Extended-B":a=>a>=55216&&a<=55295,"Private Use Area":a=>a>=57344&&a<=63743,"CJK Compatibility Ideographs":a=>a>=63744&&a<=64255,"Arabic Presentation Forms-A":a=>a>=64336&&a<=65023,"Vertical Forms":a=>a>=65040&&a<=65055,"CJK Compatibility Forms":a=>a>=65072&&a<=65103,"Small Form Variants":a=>a>=65104&&a<=65135,"Arabic Presentation Forms-B":a=>a>=65136&&a<=65279,"Halfwidth and Fullwidth Forms":a=>a>=65280&&a<=65519};function Pa(a){for(let e of a)if(rs(e.charCodeAt(0)))return!0;return!1}function Ma(a){for(let e of a)if(!us(e.charCodeAt(0)))return!1;return!0}function us(a){return!(ei.Arabic(a)||ei["Arabic Supplement"](a)||ei["Arabic Extended-A"](a)||ei["Arabic Presentation Forms-A"](a)||ei["Arabic Presentation Forms-B"](a))}function rs(a){return!(a!==746&&a!==747&&(a<4352||!(ei["Bopomofo Extended"](a)||ei.Bopomofo(a)||ei["CJK Compatibility Forms"](a)&&!(a>=65097&&a<=65103)||ei["CJK Compatibility Ideographs"](a)||ei["CJK Compatibility"](a)||ei["CJK Radicals Supplement"](a)||ei["CJK Strokes"](a)||!(!ei["CJK Symbols and Punctuation"](a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||ei["CJK Unified Ideographs Extension A"](a)||ei["CJK Unified Ideographs"](a)||ei["Enclosed CJK Letters and Months"](a)||ei["Hangul Compatibility Jamo"](a)||ei["Hangul Jamo Extended-A"](a)||ei["Hangul Jamo Extended-B"](a)||ei["Hangul Jamo"](a)||ei["Hangul Syllables"](a)||ei.Hiragana(a)||ei["Ideographic Description Characters"](a)||ei.Kanbun(a)||ei["Kangxi Radicals"](a)||ei["Katakana Phonetic Extensions"](a)||ei.Katakana(a)&&a!==12540||!(!ei["Halfwidth and Fullwidth Forms"](a)||a===65288||a===65289||a===65293||a>=65306&&a<=65310||a===65339||a===65341||a===65343||a>=65371&&a<=65503||a===65507||a>=65512&&a<=65519)||!(!ei["Small Form Variants"](a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||ei["Unified Canadian Aboriginal Syllabics"](a)||ei["Unified Canadian Aboriginal Syllabics Extended"](a)||ei["Vertical Forms"](a)||ei["Yijing Hexagram Symbols"](a)||ei["Yi Syllables"](a)||ei["Yi Radicals"](a))))}function wA(a){return!(rs(a)||function(e){return!!(ei["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||ei["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||ei["Letterlike Symbols"](e)||ei["Number Forms"](e)||ei["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||ei["Control Pictures"](e)&&e!==9251||ei["Optical Character Recognition"](e)||ei["Enclosed Alphanumerics"](e)||ei["Geometric Shapes"](e)||ei["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||ei["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||ei["CJK Symbols and Punctuation"](e)||ei.Katakana(e)||ei["Private Use Area"](e)||ei["CJK Compatibility Forms"](e)||ei["Small Form Variants"](e)||ei["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(a))}function BA(a){return a>=1424&&a<=2303||ei["Arabic Presentation Forms-A"](a)||ei["Arabic Presentation Forms-B"](a)}function Gl(a,e){return!(!e&&BA(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||ei.Khmer(a))}function ol(a){for(let e of a)if(BA(e.charCodeAt(0)))return!0;return!1}let Go=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(a){this.pluginStatus=a.pluginStatus,this.pluginURL=a.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(a){this.applyArabicShaping=a.applyArabicShaping,this.processBidirectionalText=a.processBidirectionalText,this.processStyledBidirectionalText=a.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class Hr{constructor(e,l){this.zoom=e,l?(this.now=l.now,this.fadeDuration=l.fadeDuration,this.zoomHistory=l.zoomHistory,this.transition=l.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ul,this.transition={})}isSupportedScript(e){return function(l,u){for(let m of l)if(!Gl(m.charCodeAt(0),u))return!1;return!0}(e,Go.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,l=e-Math.floor(e),u=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:l+(1-l)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*l}}}class al{constructor(e,l){this.property=e,this.value=l,this.expression=function(u,m){if(ue(u))return new $n(u,m);if(Xi(u)){let w=Hs(u,m);if(w.result==="error")throw new Error(w.value.map(B=>`${B.key}: ${B.message}`).join(", "));return w.value}{let w=u;return m.type==="color"&&typeof u=="string"?w=Ji.parse(u):m.type!=="padding"||typeof u!="number"&&!Array.isArray(u)?m.type==="variableAnchorOffsetCollection"&&Array.isArray(u)&&(w=an.parse(u)):w=xr.parse(u),{kind:"constant",evaluate:()=>w}}}(l===void 0?e.specification.default:l,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,l,u){return this.property.possiblyEvaluate(this,e,l,u)}}class _A{constructor(e){this.property=e,this.value=new al(e,void 0)}transitioned(e,l){return new xA(this.property,this.value,l,Tt({},e.transition,this.transition),e.now)}untransitioned(){return new xA(this.property,this.value,null,{},0)}}class Al{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Jt(this._values[e].value.value)}setValue(e,l){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new _A(this._values[e].property)),this._values[e].value=new al(this._values[e].property,l===null?void 0:Jt(l))}getTransition(e){return Jt(this._values[e].transition)}setTransition(e,l){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new _A(this._values[e].property)),this._values[e].transition=Jt(l)||void 0}serialize(){let e={};for(let l of Object.keys(this._values)){let u=this.getValue(l);u!==void 0&&(e[l]=u);let m=this.getTransition(l);m!==void 0&&(e[`${l}-transition`]=m)}return e}transitioned(e,l){let u=new Rl(this._properties);for(let m of Object.keys(this._values))u._values[m]=this._values[m].transitioned(e,l._values[m]);return u}untransitioned(){let e=new Rl(this._properties);for(let l of Object.keys(this._values))e._values[l]=this._values[l].untransitioned();return e}}class xA{constructor(e,l,u,m,w){this.property=e,this.value=l,this.begin=w+m.delay||0,this.end=this.begin+m.duration||0,e.specification.transition&&(m.delay||m.duration)&&(this.prior=u)}possiblyEvaluate(e,l,u){let m=e.now||0,w=this.value.possiblyEvaluate(e,l,u),B=this.prior;if(B){if(m>this.end)return this.prior=null,w;if(this.value.isDataDriven())return this.prior=null,w;if(m=1)return 1;let M=Q*Q,D=M*Q;return 4*(Q<.5?D:3*(Q-M)+D-.75)}(S))}}return w}}class Rl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,l,u){let m=new SA(this._properties);for(let w of Object.keys(this._values))m._values[w]=this._values[w].possiblyEvaluate(e,l,u);return m}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class dh{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Jt(this._values[e].value)}setValue(e,l){this._values[e]=new al(this._values[e].property,l===null?void 0:Jt(l))}serialize(){let e={};for(let l of Object.keys(this._values)){let u=this.getValue(l);u!==void 0&&(e[l]=u)}return e}possiblyEvaluate(e,l,u){let m=new SA(this._properties);for(let w of Object.keys(this._values))m._values[w]=this._values[w].possiblyEvaluate(e,l,u);return m}}class Ao{constructor(e,l,u){this.property=e,this.value=l,this.parameters=u}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,l,u,m){return this.property.evaluate(this.value,this.parameters,e,l,u,m)}}class SA{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class wi{constructor(e){this.specification=e}possiblyEvaluate(e,l){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(l)}interpolate(e,l,u){let m=qn[this.specification.type];return m?m(e,l,u):e}}class Hi{constructor(e,l){this.specification=e,this.overrides=l}possiblyEvaluate(e,l,u,m){return new Ao(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(l,null,{},u,m)}:e.expression,l)}interpolate(e,l,u){if(e.value.kind!=="constant"||l.value.kind!=="constant")return e;if(e.value.value===void 0||l.value.value===void 0)return new Ao(this,{kind:"constant",value:void 0},e.parameters);let m=qn[this.specification.type];if(m){let w=m(e.value.value,l.value.value,u);return new Ao(this,{kind:"constant",value:w},e.parameters)}return e}evaluate(e,l,u,m,w,B){return e.kind==="constant"?e.value:e.evaluate(l,u,m,w,B)}}class Na extends Hi{possiblyEvaluate(e,l,u,m){if(e.value===void 0)return new Ao(this,{kind:"constant",value:void 0},l);if(e.expression.kind==="constant"){let w=e.expression.evaluate(l,null,{},u,m),B=e.property.specification.type==="resolvedImage"&&typeof w!="string"?w.name:w,S=this._calculate(B,B,B,l);return new Ao(this,{kind:"constant",value:S},l)}if(e.expression.kind==="camera"){let w=this._calculate(e.expression.evaluate({zoom:l.zoom-1}),e.expression.evaluate({zoom:l.zoom}),e.expression.evaluate({zoom:l.zoom+1}),l);return new Ao(this,{kind:"constant",value:w},l)}return new Ao(this,e.expression,l)}evaluate(e,l,u,m,w,B){if(e.kind==="source"){let S=e.evaluate(l,u,m,w,B);return this._calculate(S,S,S,l)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(l.zoom)-1},u,m),e.evaluate({zoom:Math.floor(l.zoom)},u,m),e.evaluate({zoom:Math.floor(l.zoom)+1},u,m),l):e.value}_calculate(e,l,u,m){return m.zoom>m.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:u,to:l}}interpolate(e){return e}}class wc{constructor(e){this.specification=e}possiblyEvaluate(e,l,u,m){if(e.value!==void 0){if(e.expression.kind==="constant"){let w=e.expression.evaluate(l,null,{},u,m);return this._calculate(w,w,w,l)}return this._calculate(e.expression.evaluate(new Hr(Math.floor(l.zoom-1),l)),e.expression.evaluate(new Hr(Math.floor(l.zoom),l)),e.expression.evaluate(new Hr(Math.floor(l.zoom+1),l)),l)}}_calculate(e,l,u,m){return m.zoom>m.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:u,to:l}}interpolate(e){return e}}class ll{constructor(e){this.specification=e}possiblyEvaluate(e,l,u,m){return!!e.expression.evaluate(l,null,{},u,m)}interpolate(){return!1}}class Jn{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let l in e){let u=e[l];u.specification.overridable&&this.overridableProperties.push(l);let m=this.defaultPropertyValues[l]=new al(u,void 0),w=this.defaultTransitionablePropertyValues[l]=new _A(u);this.defaultTransitioningPropertyValues[l]=w.untransitioned(),this.defaultPossiblyEvaluatedValues[l]=m.possiblyEvaluate({})}}}si("DataDrivenProperty",Hi),si("DataConstantProperty",wi),si("CrossFadedDataDrivenProperty",Na),si("CrossFadedProperty",wc),si("ColorRampProperty",ll);let Hl="-transition";class ns extends gi{constructor(e,l){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),l.layout&&(this._unevaluatedLayout=new dh(l.layout)),l.paint)){this._transitionablePaint=new Al(l.paint);for(let u in e.paint)this.setPaintProperty(u,e.paint[u],{validate:!1});for(let u in e.layout)this.setLayoutProperty(u,e.layout[u],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new SA(l.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,l,u={}){l!=null&&this._validate(oo,`layers.${this.id}.layout.${e}`,e,l,u)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,l):this.visibility=l)}getPaintProperty(e){return e.endsWith(Hl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,l,u={}){if(l!=null&&this._validate(yn,`layers.${this.id}.paint.${e}`,e,l,u))return!1;if(e.endsWith(Hl))return this._transitionablePaint.setTransition(e.slice(0,-11),l||void 0),!1;{let m=this._transitionablePaint._values[e],w=m.property.specification["property-type"]==="cross-faded-data-driven",B=m.value.isDataDriven(),S=m.value;this._transitionablePaint.setValue(e,l),this._handleSpecialPaintPropertyUpdate(e);let Q=this._transitionablePaint._values[e].value;return Q.isDataDriven()||B||w||this._handleOverridablePaintPropertyUpdate(e,S,Q)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,l,u){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,l){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,l)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,l)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),vt(e,(l,u)=>!(l===void 0||u==="layout"&&!Object.keys(l).length||u==="paint"&&!Object.keys(l).length))}_validate(e,l,u,m,w={}){return(!w||w.validate!==!1)&&ea(this,e.call(kr,{key:l,layerType:this.type,objectKey:u,value:m,styleSpec:xt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let l=this.paint.get(e);if(l instanceof Ao&&U(l.property.specification)&&(l.value.kind==="source"||l.value.kind==="composite")&&l.value.isStateDependent)return!0}return!1}}let ou={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class FA{constructor(e,l){this._structArray=e,this._pos1=l*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,l){return e._trim(),l&&(e.isTransferred=!0,l.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let l=Object.create(this.prototype);return l.arrayBuffer=e.arrayBuffer,l.length=e.length,l.capacity=e.arrayBuffer.byteLength/l.bytesPerElement,l._refreshViews(),l}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let l=this.uint8;this._refreshViews(),l&&this.uint8.set(l)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function dn(a,e=1){let l=0,u=0;return{members:a.map(m=>{let w=ou[m.type].BYTES_PER_ELEMENT,B=l=au(l,Math.max(e,w)),S=m.components||1;return u=Math.max(u,w),l+=w*S,{name:m.name,type:m.type,components:S,offset:B}}),size:au(l,Math.max(u,e)),alignment:e}}function au(a,e){return Math.ceil(a/e)*e}class cl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.int16[m+0]=l,this.int16[m+1]=u,e}}cl.prototype.bytesPerElement=4,si("StructArrayLayout2i4",cl);class Zl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.int16[w+0]=l,this.int16[w+1]=u,this.int16[w+2]=m,e}}Zl.prototype.bytesPerElement=6,si("StructArrayLayout3i6",Zl);class ss extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=4*e;return this.int16[B+0]=l,this.int16[B+1]=u,this.int16[B+2]=m,this.int16[B+3]=w,e}}ss.prototype.bytesPerElement=8,si("StructArrayLayout4i8",ss);class Ss extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let Q=6*e;return this.int16[Q+0]=l,this.int16[Q+1]=u,this.int16[Q+2]=m,this.int16[Q+3]=w,this.int16[Q+4]=B,this.int16[Q+5]=S,e}}Ss.prototype.bytesPerElement=12,si("StructArrayLayout2i4i12",Ss);class lo extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let Q=4*e,M=8*e;return this.int16[Q+0]=l,this.int16[Q+1]=u,this.uint8[M+4]=m,this.uint8[M+5]=w,this.uint8[M+6]=B,this.uint8[M+7]=S,e}}lo.prototype.bytesPerElement=8,si("StructArrayLayout2i4ub8",lo);class ul extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.float32[m+0]=l,this.float32[m+1]=u,e}}ul.prototype.bytesPerElement=8,si("StructArrayLayout2f8",ul);class Pl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,Q,M,D){let z=this.length;return this.resize(z+1),this.emplace(z,e,l,u,m,w,B,S,Q,M,D)}emplace(e,l,u,m,w,B,S,Q,M,D,z){let et=10*e;return this.uint16[et+0]=l,this.uint16[et+1]=u,this.uint16[et+2]=m,this.uint16[et+3]=w,this.uint16[et+4]=B,this.uint16[et+5]=S,this.uint16[et+6]=Q,this.uint16[et+7]=M,this.uint16[et+8]=D,this.uint16[et+9]=z,e}}Pl.prototype.bytesPerElement=20,si("StructArrayLayout10ui20",Pl);class co extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,Q,M,D,z,et){let nt=this.length;return this.resize(nt+1),this.emplace(nt,e,l,u,m,w,B,S,Q,M,D,z,et)}emplace(e,l,u,m,w,B,S,Q,M,D,z,et,nt){let st=12*e;return this.int16[st+0]=l,this.int16[st+1]=u,this.int16[st+2]=m,this.int16[st+3]=w,this.uint16[st+4]=B,this.uint16[st+5]=S,this.uint16[st+6]=Q,this.uint16[st+7]=M,this.int16[st+8]=D,this.int16[st+9]=z,this.int16[st+10]=et,this.int16[st+11]=nt,e}}co.prototype.bytesPerElement=24,si("StructArrayLayout4i4ui4i24",co);class hs extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.float32[w+0]=l,this.float32[w+1]=u,this.float32[w+2]=m,e}}hs.prototype.bytesPerElement=12,si("StructArrayLayout3f12",hs);class Bc extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint32[1*e+0]=l,e}}Bc.prototype.bytesPerElement=4,si("StructArrayLayout1ul4",Bc);class ia extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,Q,M){let D=this.length;return this.resize(D+1),this.emplace(D,e,l,u,m,w,B,S,Q,M)}emplace(e,l,u,m,w,B,S,Q,M,D){let z=10*e,et=5*e;return this.int16[z+0]=l,this.int16[z+1]=u,this.int16[z+2]=m,this.int16[z+3]=w,this.int16[z+4]=B,this.int16[z+5]=S,this.uint32[et+3]=Q,this.uint16[z+8]=M,this.uint16[z+9]=D,e}}ia.prototype.bytesPerElement=20,si("StructArrayLayout6i1ul2ui20",ia);class hl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let Q=6*e;return this.int16[Q+0]=l,this.int16[Q+1]=u,this.int16[Q+2]=m,this.int16[Q+3]=w,this.int16[Q+4]=B,this.int16[Q+5]=S,e}}hl.prototype.bytesPerElement=12,si("StructArrayLayout2i2i2i12",hl);class kA extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w){let B=this.length;return this.resize(B+1),this.emplace(B,e,l,u,m,w)}emplace(e,l,u,m,w,B){let S=4*e,Q=8*e;return this.float32[S+0]=l,this.float32[S+1]=u,this.float32[S+2]=m,this.int16[Q+6]=w,this.int16[Q+7]=B,e}}kA.prototype.bytesPerElement=16,si("StructArrayLayout2f1f2i16",kA);class gl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=12*e,S=3*e;return this.uint8[B+0]=l,this.uint8[B+1]=u,this.float32[S+1]=m,this.float32[S+2]=w,e}}gl.prototype.bytesPerElement=12,si("StructArrayLayout2ub2f12",gl);class Va extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.uint16[w+0]=l,this.uint16[w+1]=u,this.uint16[w+2]=m,e}}Va.prototype.bytesPerElement=6,si("StructArrayLayout3ui6",Va);class _c extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt){let oe=this.length;return this.resize(oe+1),this.emplace(oe,e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt)}emplace(e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt,oe){let Wt=24*e,$t=12*e,ve=48*e;return this.int16[Wt+0]=l,this.int16[Wt+1]=u,this.uint16[Wt+2]=m,this.uint16[Wt+3]=w,this.uint32[$t+2]=B,this.uint32[$t+3]=S,this.uint32[$t+4]=Q,this.uint16[Wt+10]=M,this.uint16[Wt+11]=D,this.uint16[Wt+12]=z,this.float32[$t+7]=et,this.float32[$t+8]=nt,this.uint8[ve+36]=st,this.uint8[ve+37]=mt,this.uint8[ve+38]=St,this.uint32[$t+10]=Vt,this.int16[Wt+22]=oe,e}}_c.prototype.bytesPerElement=48,si("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",_c);class ra extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt,oe,Wt,$t,ve,Le,ni,bi,ri,ti,Oe,fi){let qe=this.length;return this.resize(qe+1),this.emplace(qe,e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt,oe,Wt,$t,ve,Le,ni,bi,ri,ti,Oe,fi)}emplace(e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt,St,Vt,oe,Wt,$t,ve,Le,ni,bi,ri,ti,Oe,fi,qe){let Ze=32*e,Gi=16*e;return this.int16[Ze+0]=l,this.int16[Ze+1]=u,this.int16[Ze+2]=m,this.int16[Ze+3]=w,this.int16[Ze+4]=B,this.int16[Ze+5]=S,this.int16[Ze+6]=Q,this.int16[Ze+7]=M,this.uint16[Ze+8]=D,this.uint16[Ze+9]=z,this.uint16[Ze+10]=et,this.uint16[Ze+11]=nt,this.uint16[Ze+12]=st,this.uint16[Ze+13]=mt,this.uint16[Ze+14]=St,this.uint16[Ze+15]=Vt,this.uint16[Ze+16]=oe,this.uint16[Ze+17]=Wt,this.uint16[Ze+18]=$t,this.uint16[Ze+19]=ve,this.uint16[Ze+20]=Le,this.uint16[Ze+21]=ni,this.uint16[Ze+22]=bi,this.uint32[Gi+12]=ri,this.float32[Gi+13]=ti,this.float32[Gi+14]=Oe,this.uint16[Ze+30]=fi,this.uint16[Ze+31]=qe,e}}ra.prototype.bytesPerElement=64,si("StructArrayLayout8i15ui1ul2f2ui64",ra);class uo extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.float32[1*e+0]=l,e}}uo.prototype.bytesPerElement=4,si("StructArrayLayout1f4",uo);class Da extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.uint16[6*e+0]=l,this.float32[w+1]=u,this.float32[w+2]=m,e}}Da.prototype.bytesPerElement=12,si("StructArrayLayout1ui2f12",Da);class LA extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=4*e;return this.uint32[2*e+0]=l,this.uint16[w+2]=u,this.uint16[w+3]=m,e}}LA.prototype.bytesPerElement=8,si("StructArrayLayout1ul2ui8",LA);class Ia extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.uint16[m+0]=l,this.uint16[m+1]=u,e}}Ia.prototype.bytesPerElement=4,si("StructArrayLayout2ui4",Ia);class xc extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint16[1*e+0]=l,e}}xc.prototype.bytesPerElement=2,si("StructArrayLayout1ui2",xc);class Ml extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=4*e;return this.float32[B+0]=l,this.float32[B+1]=u,this.float32[B+2]=m,this.float32[B+3]=w,e}}Ml.prototype.bytesPerElement=16,si("StructArrayLayout4f16",Ml);class Sc extends FA{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 v(this.anchorPointX,this.anchorPointY)}}Sc.prototype.size=20;class Au extends ia{get(e){return new Sc(this,e)}}si("CollisionBoxArray",Au);class y extends FA{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}y.prototype.size=48;class n extends _c{get(e){return new y(this,e)}}si("PlacedSymbolArray",n);class c extends FA{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}c.prototype.size=64;class p extends ra{get(e){return new c(this,e)}}si("SymbolInstanceArray",p);class f extends uo{getoffsetX(e){return this.float32[1*e+0]}}si("GlyphOffsetArray",f);class b extends Zl{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}si("SymbolLineVertexArray",b);class L extends FA{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}L.prototype.size=12;class E extends Da{get(e){return new L(this,e)}}si("TextAnchorOffsetArray",E);class H extends FA{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]}}H.prototype.size=8;class h extends LA{get(e){return new H(this,e)}}si("FeatureIndexArray",h);class I extends cl{}class _ extends cl{}class F extends cl{}class R extends Ss{}class Z extends lo{}class N extends ul{}class P extends Pl{}class V extends co{}class X extends hs{}class J extends Bc{}class ot extends hl{}class dt extends gl{}class ut extends Va{}class Gt extends Ia{}let Pt=dn([{name:"a_pos",components:2,type:"Int16"}],4),{members:gt}=Pt;class Ct{constructor(e=[]){this.segments=e}prepareSegment(e,l,u,m){let w=this.segments[this.segments.length-1];return e>Ct.MAX_VERTEX_ARRAY_LENGTH&&At(`Max vertices per segment is ${Ct.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!w||w.vertexLength+e>Ct.MAX_VERTEX_ARRAY_LENGTH||w.sortKey!==m)&&(w={vertexOffset:l.length,primitiveOffset:u.length,vertexLength:0,primitiveLength:0},m!==void 0&&(w.sortKey=m),this.segments.push(w)),w}get(){return this.segments}destroy(){for(let e of this.segments)for(let l in e.vaos)e.vaos[l].destroy()}static simpleSegment(e,l,u,m){return new Ct([{vertexOffset:e,primitiveOffset:l,vertexLength:u,primitiveLength:m,vaos:{},sortKey:0}])}}function ee(a,e){return 256*(a=at(Math.floor(a),0,255))+at(Math.floor(e),0,255)}Ct.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,si("SegmentVector",Ct);let ge=dn([{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 jt={exports:{}},Fe={exports:{}};Fe.exports=function(a,e){var l,u,m,w,B,S,Q,M;for(u=a.length-(l=3&a.length),m=e,B=3432918353,S=461845907,M=0;M>>16)*B&65535)<<16)&4294967295)<<15|Q>>>17))*S+(((Q>>>16)*S&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(w>>>16)&65535)<<16);switch(Q=0,l){case 3:Q^=(255&a.charCodeAt(M+2))<<16;case 2:Q^=(255&a.charCodeAt(M+1))<<8;case 1:m^=Q=(65535&(Q=(Q=(65535&(Q^=255&a.charCodeAt(M)))*B+(((Q>>>16)*B&65535)<<16)&4294967295)<<15|Q>>>17))*S+(((Q>>>16)*S&65535)<<16)&4294967295}return m^=a.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0};var ke=Fe.exports,Ye={exports:{}};Ye.exports=function(a,e){for(var l,u=a.length,m=e^u,w=0;u>=4;)l=1540483477*(65535&(l=255&a.charCodeAt(w)|(255&a.charCodeAt(++w))<<8|(255&a.charCodeAt(++w))<<16|(255&a.charCodeAt(++w))<<24))+((1540483477*(l>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),u-=4,++w;switch(u){case 3:m^=(255&a.charCodeAt(w+2))<<16;case 2:m^=(255&a.charCodeAt(w+1))<<8;case 1:m=1540483477*(65535&(m^=255&a.charCodeAt(w)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0};var xe=ke,ci=Ye.exports;jt.exports=xe,jt.exports.murmur3=xe,jt.exports.murmur2=ci;var pi=g(jt.exports);class Mi{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,l,u,m){this.ids.push(Si(e)),this.positions.push(l,u,m)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");let l=Si(e),u=0,m=this.ids.length-1;for(;u>1;this.ids[B]>=l?m=B:u=B+1}let w=[];for(;this.ids[u]===l;)w.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return w}static serialize(e,l){let u=new Float64Array(e.ids),m=new Uint32Array(e.positions);return cr(u,m,0,u.length-1),l&&l.push(u.buffer,m.buffer),{ids:u,positions:m}}static deserialize(e){let l=new Mi;return l.ids=e.ids,l.positions=e.positions,l.indexed=!0,l}}function Si(a){let e=+a;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:pi(String(a))}function cr(a,e,l,u){for(;l>1],w=l-1,B=u+1;for(;;){do w++;while(a[w]m);if(w>=B)break;ji(a,w,B),ji(e,3*w,3*B),ji(e,3*w+1,3*B+1),ji(e,3*w+2,3*B+2)}B-l`u_${m}`),this.type=u}setUniform(e,l,u){e.set(u.constantOr(this.value))}getBinding(e,l,u){return this.type==="color"?new Gr(e,l):new vr(e,l)}}class rn{constructor(e,l){this.uniformNames=l.map(u=>`u_${u}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,l){this.pixelRatioFrom=l.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=l.tlbr,this.patternTo=e.tlbr}setUniform(e,l,u,m){let w=m==="u_pattern_to"?this.patternTo:m==="u_pattern_from"?this.patternFrom:m==="u_pixel_ratio_to"?this.pixelRatioTo:m==="u_pixel_ratio_from"?this.pixelRatioFrom:null;w&&e.set(w)}getBinding(e,l,u){return u.substr(0,9)==="u_pattern"?new Yr(e,l):new vr(e,l)}}class ur{constructor(e,l,u,m){this.expression=e,this.type=u,this.maxValue=0,this.paintVertexAttributes=l.map(w=>({name:`a_${w}`,type:"Float32",components:u==="color"?2:1,offset:0})),this.paintVertexArray=new m}populatePaintArray(e,l,u,m,w){let B=this.paintVertexArray.length,S=this.expression.evaluate(new Hr(0),l,{},m,[],w);this.paintVertexArray.resize(e),this._setPaintValue(B,e,S)}updatePaintArray(e,l,u,m){let w=this.expression.evaluate({zoom:0},u,m);this._setPaintValue(e,l,w)}_setPaintValue(e,l,u){if(this.type==="color"){let m=wr(u);for(let w=e;w`u_${S}_t`),this.type=u,this.useIntegerZoom=m,this.zoom=w,this.maxValue=0,this.paintVertexAttributes=l.map(S=>({name:`a_${S}`,type:"Float32",components:u==="color"?4:2,offset:0})),this.paintVertexArray=new B}populatePaintArray(e,l,u,m,w){let B=this.expression.evaluate(new Hr(this.zoom),l,{},m,[],w),S=this.expression.evaluate(new Hr(this.zoom+1),l,{},m,[],w),Q=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(Q,e,B,S)}updatePaintArray(e,l,u,m){let w=this.expression.evaluate({zoom:this.zoom},u,m),B=this.expression.evaluate({zoom:this.zoom+1},u,m);this._setPaintValue(e,l,w,B)}_setPaintValue(e,l,u,m){if(this.type==="color"){let w=wr(u),B=wr(m);for(let S=e;S`#define HAS_UNIFORM_${m}`))}return e}getBinderAttributes(){let e=[];for(let l in this.binders){let u=this.binders[l];if(u instanceof ur||u instanceof sr)for(let m=0;m!0){this.programConfigurations={};for(let m of e)this.programConfigurations[m.id]=new Sn(m,l,u);this.needsUpload=!1,this._featureMap=new Mi,this._bufferOffset=0}populatePaintArrays(e,l,u,m,w,B){for(let S in this.programConfigurations)this.programConfigurations[S].populatePaintArrays(e,l,m,w,B);l.id!==void 0&&this._featureMap.add(l.id,u,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,l,u,m){for(let w of u)this.needsUpload=this.programConfigurations[w.id].updatePaintArrays(e,this._featureMap,l,w,m)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let l in this.programConfigurations)this.programConfigurations[l].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Br(a,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"]}[a]||[a.replace(`${e}-`,"").replace(/-/g,"_")]}function pn(a,e,l){let u={color:{source:ul,composite:Ml},number:{source:uo,composite:ul}},m=function(w){return{"line-pattern":{source:P,composite:P},"fill-pattern":{source:P,composite:P},"fill-extrusion-pattern":{source:P,composite:P}}[w]}(a);return m&&m[l]||u[e][l]}si("ConstantBinder",An),si("CrossFadedConstantBinder",rn),si("SourceExpressionBinder",ur),si("CrossFadedCompositeBinder",Ir),si("CompositeExpressionBinder",sr),si("ProgramConfiguration",Sn,{omit:["_buffers"]}),si("ProgramConfigurationSet",_r);let $i=8192,ya=Math.pow(2,14)-1,na=-ya-1;function Zr(a){let e=$i/a.extent,l=a.loadGeometry();for(let u=0;uB.x+1||QB.y+1)&&At("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return l}function sa(a,e){return{type:a.type,id:a.id,properties:a.properties,geometry:e?Zr(a):[]}}function dl(a,e,l,u,m){a.emplaceBack(2*e+(u+1)/2,2*l+(m+1)/2)}class Nl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(l=>l.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new _,this.indexArray=new ut,this.segments=new Ct,this.programConfigurations=new _r(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){let m=this.layers[0],w=[],B=null,S=!1;m.type==="circle"&&(B=m.layout.get("circle-sort-key"),S=!B.isConstant());for(let{feature:Q,id:M,index:D,sourceLayerIndex:z}of e){let et=this.layers[0]._featureFilter.needGeometry,nt=sa(Q,et);if(!this.layers[0]._featureFilter.filter(new Hr(this.zoom),nt,u))continue;let st=S?B.evaluate(nt,{},u):void 0,mt={id:M,properties:Q.properties,type:Q.type,sourceLayerIndex:z,index:D,geometry:et?nt.geometry:Zr(Q),patterns:{},sortKey:st};w.push(mt)}S&&w.sort((Q,M)=>Q.sortKey-M.sortKey);for(let Q of w){let{geometry:M,index:D,sourceLayerIndex:z}=Q,et=e[D].feature;this.addFeature(Q,M,D,u),l.featureIndex.insert(et,M,D,z,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gt),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,l,u,m){for(let w of l)for(let B of w){let S=B.x,Q=B.y;if(S<0||S>=$i||Q<0||Q>=$i)continue;let M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),D=M.vertexLength;dl(this.layoutVertexArray,S,Q,-1,-1),dl(this.layoutVertexArray,S,Q,1,-1),dl(this.layoutVertexArray,S,Q,1,1),dl(this.layoutVertexArray,S,Q,-1,1),this.indexArray.emplaceBack(D,D+1,D+2),this.indexArray.emplaceBack(D,D+3,D+2),M.vertexLength+=4,M.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{},m)}}function Ro(a,e){for(let l=0;l1){if(Ho(a,e))return!0;for(let u=0;u1?l:l.sub(e)._mult(m)._add(e))}function ph(a,e){let l,u,m,w=!1;for(let B=0;Be.y!=m.y>e.y&&e.x<(m.x-u.x)*(e.y-u.y)/(m.y-u.y)+u.x&&(w=!w)}return w}function Wa(a,e){let l=!1;for(let u=0,m=a.length-1;ue.y!=B.y>e.y&&e.x<(B.x-w.x)*(e.y-w.y)/(B.y-w.y)+w.x&&(l=!l)}return l}function fh(a,e,l){let u=l[0],m=l[2];if(a.xm.x&&e.x>m.x||a.ym.y&&e.y>m.y)return!1;let w=lt(a,e,l[0]);return w!==lt(a,e,l[1])||w!==lt(a,e,l[2])||w!==lt(a,e,l[3])}function UA(a,e,l){let u=e.paint.get(a).value;return u.kind==="constant"?u.value:l.programConfigurations.get(e.id).getMaxValue(a)}function GA(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function lu(a,e,l,u,m){if(!e[0]&&!e[1])return a;let w=v.convert(e)._mult(m);l==="viewport"&&w._rotate(-u);let B=[];for(let S=0;Shu(St,mt))}(M,Q),nt=z?D*S:D;for(let st of m)for(let mt of st){let St=z?mt:hu(mt,Q),Vt=nt,oe=kc([],[mt.x,mt.y,0,1],Q);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?Vt*=oe[3]/B.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(Vt*=B.cameraToCenterDistance/oe[3]),EA(et,St,Vt))return!0}return!1}}function hu(a,e){let l=kc([],[a.x,a.y,0,1],e);return new v(l[0]/l[3],l[1]/l[3])}class Dl extends Nl{}let Ih;si("HeatmapBucket",Dl,{omit:["layers"]});var om={get paint(){return Ih=Ih||new Jn({"heatmap-radius":new Hi(xt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Hi(xt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new wi(xt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ll(xt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new wi(xt.paint_heatmap["heatmap-opacity"])})}};function Kl(a,{width:e,height:l},u,m){if(m){if(m instanceof Uint8ClampedArray)m=new Uint8Array(m.buffer);else if(m.length!==e*l*u)throw new RangeError(`mismatched image size. expected: ${m.length} but got: ${e*l*u}`)}else m=new Uint8Array(e*l*u);return a.width=e,a.height=l,a.data=m,a}function yh(a,{width:e,height:l},u){if(e===a.width&&l===a.height)return;let m=Kl({},{width:e,height:l},u);Lc(a,m,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,e),height:Math.min(a.height,l)},u),a.width=e,a.height=l,a.data=m.data}function Lc(a,e,l,u,m,w){if(m.width===0||m.height===0)return e;if(m.width>a.width||m.height>a.height||l.x>a.width-m.width||l.y>a.height-m.height)throw new RangeError("out of range source coordinates for image copy");if(m.width>e.width||m.height>e.height||u.x>e.width-m.width||u.y>e.height-m.height)throw new RangeError("out of range destination coordinates for image copy");let B=a.data,S=e.data;if(B===S)throw new Error("srcData equals dstData, so image is already copied");for(let Q=0;Q{e[a.evaluationKey]=Q;let M=a.expression.evaluate(e);m.data[B+S+0]=Math.floor(255*M.r/M.a),m.data[B+S+1]=Math.floor(255*M.g/M.a),m.data[B+S+2]=Math.floor(255*M.b/M.a),m.data[B+S+3]=Math.floor(255*M.a)};if(a.clips)for(let B=0,S=0;B80*l){u=w=a[0],m=B=a[1];for(var st=l;stw&&(w=S),Q>B&&(B=Q);M=(M=Math.max(w-u,B-m))!==0?32767/M:0}return ZA(et,nt,l,u,m,M,0),nt}function Ol(a,e,l,u,m){var w,B;if(m===hm(a,e,l,u)>0)for(w=e;w=e;w-=u)B=zy(w,a[w],a[w+1],B);return B&&jg(B,B.next)&&(xh(B),B=B.next),B}function Oa(a,e){if(!a)return a;e||(e=a);var l,u=a;do if(l=!1,u.steiner||!jg(u,u.next)&&bn(u.prev,u,u.next)!==0)u=u.next;else{if(xh(u),(u=e=u.prev)===u.next)break;l=!0}while(l||u!==e);return e}function ZA(a,e,l,u,m,w,B){if(a){!B&&w&&function(D,z,et,nt){var st=D;do st.z===0&&(st.z=Ec(st.x,st.y,z,et,nt)),st.prevZ=st.prev,st.nextZ=st.next,st=st.next;while(st!==D);st.prevZ.nextZ=null,st.prevZ=null,function(mt){var St,Vt,oe,Wt,$t,ve,Le,ni,bi=1;do{for(Vt=mt,mt=null,$t=null,ve=0;Vt;){for(ve++,oe=Vt,Le=0,St=0;St0||ni>0&&oe;)Le!==0&&(ni===0||!oe||Vt.z<=oe.z)?(Wt=Vt,Vt=Vt.nextZ,Le--):(Wt=oe,oe=oe.nextZ,ni--),$t?$t.nextZ=Wt:mt=Wt,Wt.prevZ=$t,$t=Wt;Vt=oe}$t.nextZ=null,bi*=2}while(ve>1)}(st)}(a,u,m,w);for(var S,Q,M=a;a.prev!==a.next;)if(S=a.prev,Q=a.next,w?PA(a,u,m,w):za(a))e.push(S.i/l|0),e.push(a.i/l|0),e.push(Q.i/l|0),xh(a),a=Q.next,M=Q.next;else if((a=Q)===M){B?B===1?ZA(a=MA(Oa(a),e,l),e,l,u,m,w,2):B===2&&pu(a,e,l,u,m,w):ZA(Oa(a),e,l,u,m,w,1);break}}}function za(a){var e=a.prev,l=a,u=a.next;if(bn(e,l,u)>=0)return!1;for(var m=e.x,w=l.x,B=u.x,S=e.y,Q=l.y,M=u.y,D=mw?m>B?m:B:w>B?w:B,nt=S>Q?S>M?S:M:Q>M?Q:M,st=u.next;st!==e;){if(st.x>=D&&st.x<=et&&st.y>=z&&st.y<=nt&&fu(m,S,w,Q,B,M,st.x,st.y)&&bn(st.prev,st,st.next)>=0)return!1;st=st.next}return!0}function PA(a,e,l,u){var m=a.prev,w=a,B=a.next;if(bn(m,w,B)>=0)return!1;for(var S=m.x,Q=w.x,M=B.x,D=m.y,z=w.y,et=B.y,nt=SQ?S>M?S:M:Q>M?Q:M,St=D>z?D>et?D:et:z>et?z:et,Vt=Ec(nt,st,e,l,u),oe=Ec(mt,St,e,l,u),Wt=a.prevZ,$t=a.nextZ;Wt&&Wt.z>=Vt&&$t&&$t.z<=oe;){if(Wt.x>=nt&&Wt.x<=mt&&Wt.y>=st&&Wt.y<=St&&Wt!==m&&Wt!==B&&fu(S,D,Q,z,M,et,Wt.x,Wt.y)&&bn(Wt.prev,Wt,Wt.next)>=0||(Wt=Wt.prevZ,$t.x>=nt&&$t.x<=mt&&$t.y>=st&&$t.y<=St&&$t!==m&&$t!==B&&fu(S,D,Q,z,M,et,$t.x,$t.y)&&bn($t.prev,$t,$t.next)>=0))return!1;$t=$t.nextZ}for(;Wt&&Wt.z>=Vt;){if(Wt.x>=nt&&Wt.x<=mt&&Wt.y>=st&&Wt.y<=St&&Wt!==m&&Wt!==B&&fu(S,D,Q,z,M,et,Wt.x,Wt.y)&&bn(Wt.prev,Wt,Wt.next)>=0)return!1;Wt=Wt.prevZ}for(;$t&&$t.z<=oe;){if($t.x>=nt&&$t.x<=mt&&$t.y>=st&&$t.y<=St&&$t!==m&&$t!==B&&fu(S,D,Q,z,M,et,$t.x,$t.y)&&bn($t.prev,$t,$t.next)>=0)return!1;$t=$t.nextZ}return!0}function MA(a,e,l){var u=a;do{var m=u.prev,w=u.next.next;!jg(m,w)&&Wy(m,u,u.next,w)&&_h(m,w)&&_h(w,m)&&(e.push(m.i/l|0),e.push(u.i/l|0),e.push(w.i/l|0),xh(u),xh(u.next),u=a=w),u=u.next}while(u!==a);return Oa(u)}function pu(a,e,l,u,m,w){var B=a;do{for(var S=B.next.next;S!==B.prev;){if(B.i!==S.i&&K5(B,S)){var Q=Oy(B,S);return B=Oa(B,B.next),Q=Oa(Q,Q.next),ZA(B,e,l,u,m,w,0),void ZA(Q,e,l,u,m,w,0)}S=S.next}B=B.next}while(B!==a)}function wh(a,e){return a.x-e.x}function Yg(a,e){var l=function(m,w){var B,S=w,Q=m.x,M=m.y,D=-1/0;do{if(M<=S.y&&M>=S.next.y&&S.next.y!==S.y){var z=S.x+(M-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(z<=Q&&z>D&&(D=z,B=S.x=S.x&&S.x>=st&&Q!==S.x&&fu(MB.x||S.x===B.x&&cm(B,S)))&&(B=S,St=et)),S=S.next;while(S!==nt);return B}(a,e);if(!l)return e;var u=Oy(l,a);return Oa(u,u.next),Oa(l,l.next)}function cm(a,e){return bn(a.prev,a,e.prev)<0&&bn(e.next,a,a.next)<0}function Ec(a,e,l,u,m){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=(a-l)*m|0)|a<<8))|a<<4))|a<<2))|a<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-u)*m|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Bh(a){var e=a,l=a;do(e.x=(a-B)*(w-S)&&(a-B)*(u-S)>=(l-B)*(e-S)&&(l-B)*(w-S)>=(m-B)*(u-S)}function K5(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!function(l,u){var m=l;do{if(m.i!==l.i&&m.next.i!==l.i&&m.i!==u.i&&m.next.i!==u.i&&Wy(m,m.next,l,u))return!0;m=m.next}while(m!==l);return!1}(a,e)&&(_h(a,e)&&_h(e,a)&&function(l,u){var m=l,w=!1,B=(l.x+u.x)/2,S=(l.y+u.y)/2;do m.y>S!=m.next.y>S&&m.next.y!==m.y&&B<(m.next.x-m.x)*(S-m.y)/(m.next.y-m.y)+m.x&&(w=!w),m=m.next;while(m!==l);return w}(a,e)&&(bn(a.prev,a,e.prev)||bn(a,e.prev,e))||jg(a,e)&&bn(a.prev,a,a.next)>0&&bn(e.prev,e,e.next)>0)}function bn(a,e,l){return(e.y-a.y)*(l.x-e.x)-(e.x-a.x)*(l.y-e.y)}function jg(a,e){return a.x===e.x&&a.y===e.y}function Wy(a,e,l,u){var m=$g(bn(a,e,l)),w=$g(bn(a,e,u)),B=$g(bn(l,u,a)),S=$g(bn(l,u,e));return m!==w&&B!==S||!(m!==0||!qg(a,l,e))||!(w!==0||!qg(a,u,e))||!(B!==0||!qg(l,a,u))||!(S!==0||!qg(l,e,u))}function qg(a,e,l){return e.x<=Math.max(a.x,l.x)&&e.x>=Math.min(a.x,l.x)&&e.y<=Math.max(a.y,l.y)&&e.y>=Math.min(a.y,l.y)}function $g(a){return a>0?1:a<0?-1:0}function _h(a,e){return bn(a.prev,a,a.next)<0?bn(a,e,a.next)>=0&&bn(a,a.prev,e)>=0:bn(a,e,a.prev)<0||bn(a,a.next,e)<0}function Oy(a,e){var l=new um(a.i,a.x,a.y),u=new um(e.i,e.x,e.y),m=a.next,w=e.prev;return a.next=e,e.prev=a,l.next=m,m.prev=l,u.next=l,l.prev=u,w.next=u,u.prev=w,u}function zy(a,e,l,u){var m=new um(a,e,l);return u?(m.next=u.next,m.prev=u,u.next.prev=m,u.next=m):(m.prev=m,m.next=m),m}function xh(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function um(a,e,l){this.i=a,this.x=e,this.y=l,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hm(a,e,l,u){for(var m=0,w=e,B=l-u;w0&&l.holes.push(u+=a[m-1].length)}return l};var Jy=g(gu.exports);function W5(a,e,l,u,m){Xy(a,e,l||0,u||a.length-1,m||O5)}function Xy(a,e,l,u,m){for(;u>l;){if(u-l>600){var w=u-l+1,B=e-l+1,S=Math.log(w),Q=.5*Math.exp(2*S/3),M=.5*Math.sqrt(S*Q*(w-Q)/w)*(B-w/2<0?-1:1);Xy(a,e,Math.max(l,Math.floor(e-B*Q/w+M)),Math.min(u,Math.floor(e+(w-B)*Q/w+M)),m)}var D=a[e],z=l,et=u;for(Sh(a,l,e),m(a[u],D)>0&&Sh(a,l,u);z0;)et--}m(a[l],D)===0?Sh(a,l,et):Sh(a,++et,u),et<=e&&(l=et+1),e<=et&&(u=et-1)}}function Sh(a,e,l){var u=a[e];a[e]=a[l],a[l]=u}function O5(a,e){return ae?1:0}function gm(a,e){let l=a.length;if(l<=1)return[a];let u=[],m,w;for(let B=0;B1)for(let B=0;Bl.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new F,this.indexArray=new ut,this.indexArray2=new Gt,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.segments2=new Ct,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.hasPattern=dm("fill",this.layers,l);let m=this.layers[0].layout.get("fill-sort-key"),w=!m.isConstant(),B=[];for(let{feature:S,id:Q,index:M,sourceLayerIndex:D}of e){let z=this.layers[0]._featureFilter.needGeometry,et=sa(S,z);if(!this.layers[0]._featureFilter.filter(new Hr(this.zoom),et,u))continue;let nt=w?m.evaluate(et,{},u,l.availableImages):void 0,st={id:Q,properties:S.properties,type:S.type,sourceLayerIndex:D,index:M,geometry:z?et.geometry:Zr(S),patterns:{},sortKey:nt};B.push(st)}w&&B.sort((S,Q)=>S.sortKey-Q.sortKey);for(let S of B){let{geometry:Q,index:M,sourceLayerIndex:D}=S;if(this.hasPattern){let z=pm("fill",this.layers,S,this.zoom,l);this.patternFeatures.push(z)}else this.addFeature(S,Q,M,u,{});l.featureIndex.insert(e[M].feature,Q,M,D,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}addFeatures(e,l,u){for(let m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,l,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lm),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,l,u,m,w){for(let B of gm(l,500)){let S=0;for(let nt of B)S+=nt.length;let Q=this.segments.prepareSegment(S,this.layoutVertexArray,this.indexArray),M=Q.vertexLength,D=[],z=[];for(let nt of B){if(nt.length===0)continue;nt!==B[0]&&z.push(D.length/2);let st=this.segments2.prepareSegment(nt.length,this.layoutVertexArray,this.indexArray2),mt=st.vertexLength;this.layoutVertexArray.emplaceBack(nt[0].x,nt[0].y),this.indexArray2.emplaceBack(mt+nt.length-1,mt),D.push(nt[0].x),D.push(nt[0].y);for(let St=1;St>3}if(m--,u===1||u===2)w+=a.readSVarint(),B+=a.readSVarint(),u===1&&(e&&S.push(e),e=[]),e.push(new $5(w,B));else{if(u!==7)throw new Error("unknown command "+u);e&&e.push(e[0].clone())}}return e&&S.push(e),S},mu.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var e=a.readVarint()+a.pos,l=1,u=0,m=0,w=0,B=1/0,S=-1/0,Q=1/0,M=-1/0;a.pos>3}if(u--,l===1||l===2)(m+=a.readSVarint())S&&(S=m),(w+=a.readSVarint())M&&(M=w);else if(l!==7)throw new Error("unknown command "+l)}return[B,Q,S,M]},mu.prototype.toGeoJSON=function(a,e,l){var u,m,w=this.extent*Math.pow(2,l),B=this.extent*a,S=this.extent*e,Q=this.loadGeometry(),M=mu.types[this.type];function D(nt){for(var st=0;st>3;m=B===1?u.readString():B===2?u.readFloat():B===3?u.readDouble():B===4?u.readVarint64():B===5?u.readVarint():B===6?u.readSVarint():B===7?u.readBoolean():null}return m}(l))}t1.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var e=this._pbf.readVarint()+this._pbf.pos;return new iS(this._pbf,e,this.extent,this._keys,this._values)};var nS=$y;function sS(a,e,l){if(a===3){var u=new nS(l,l.readVarint()+l.pos);u.length&&(e[u.name]=u)}}zl.VectorTile=function(a,e){this.layers=a.readFields(sS,{},e)},zl.VectorTileFeature=qy,zl.VectorTileLayer=$y;let oS=zl.VectorTileFeature.types,mm=Math.pow(2,13);function Fh(a,e,l,u,m,w,B,S){a.emplaceBack(e,l,2*Math.floor(u*mm)+B,m*mm*2,w*mm*2,Math.round(S))}class Cm{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(l=>l.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new R,this.centroidVertexArray=new I,this.indexArray=new ut,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.features=[],this.hasPattern=dm("fill-extrusion",this.layers,l);for(let{feature:m,id:w,index:B,sourceLayerIndex:S}of e){let Q=this.layers[0]._featureFilter.needGeometry,M=sa(m,Q);if(!this.layers[0]._featureFilter.filter(new Hr(this.zoom),M,u))continue;let D={id:w,sourceLayerIndex:S,index:B,geometry:Q?M.geometry:Zr(m),properties:m.properties,type:m.type,patterns:{}};this.hasPattern?this.features.push(pm("fill-extrusion",this.layers,D,this.zoom,l)):this.addFeature(D,D.geometry,B,u,{}),l.featureIndex.insert(m,D.geometry,B,S,this.index,!0)}}addFeatures(e,l,u){for(let m of this.features){let{geometry:w}=m;this.addFeature(m,w,m.index,l,u)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,q5),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,j5.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,l,u,m,w){let B={x:0,y:0,vertexCount:0};for(let S of gm(l,500)){let Q=0;for(let st of S)Q+=st.length;let M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let st of S){if(st.length===0||AS(st))continue;let mt=0;for(let St=0;St=1){let oe=st[St-1];if(!aS(Vt,oe)){M.vertexLength+4>Ct.MAX_VERTEX_ARRAY_LENGTH&&(M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let Wt=Vt.sub(oe)._perp()._unit(),$t=oe.dist(Vt);mt+$t>32768&&(mt=0),Fh(this.layoutVertexArray,Vt.x,Vt.y,Wt.x,Wt.y,0,0,mt),Fh(this.layoutVertexArray,Vt.x,Vt.y,Wt.x,Wt.y,0,1,mt),B.x+=2*Vt.x,B.y+=2*Vt.y,B.vertexCount+=2,mt+=$t,Fh(this.layoutVertexArray,oe.x,oe.y,Wt.x,Wt.y,0,0,mt),Fh(this.layoutVertexArray,oe.x,oe.y,Wt.x,Wt.y,0,1,mt),B.x+=2*oe.x,B.y+=2*oe.y,B.vertexCount+=2;let ve=M.vertexLength;this.indexArray.emplaceBack(ve,ve+2,ve+1),this.indexArray.emplaceBack(ve+1,ve+2,ve+3),M.vertexLength+=4,M.primitiveLength+=2}}}}if(M.vertexLength+Q>Ct.MAX_VERTEX_ARRAY_LENGTH&&(M=this.segments.prepareSegment(Q,this.layoutVertexArray,this.indexArray)),oS[e.type]!=="Polygon")continue;let D=[],z=[],et=M.vertexLength;for(let st of S)if(st.length!==0){st!==S[0]&&z.push(D.length/2);for(let mt=0;mt$i)||a.y===e.y&&(a.y<0||a.y>$i)}function AS(a){return a.every(e=>e.x<0)||a.every(e=>e.x>$i)||a.every(e=>e.y<0)||a.every(e=>e.y>$i)}let e1;si("FillExtrusionBucket",Cm,{omit:["layers","features"]});var lS={get paint(){return e1=e1||new Jn({"fill-extrusion-opacity":new wi(xt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new wi(xt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new wi(xt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Na(xt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new wi(xt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class cS extends ns{constructor(e){super(e,lS)}createBucket(e){return new Cm(e)}queryRadius(){return GA(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,l,u,m,w,B,S,Q){let M=lu(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),B.angle,S),D=this.paint.get("fill-extrusion-height").evaluate(l,u),z=this.paint.get("fill-extrusion-base").evaluate(l,u),et=function(st,mt,St,Vt){let oe=[];for(let Wt of st){let $t=[Wt.x,Wt.y,0,1];kc($t,$t,mt),oe.push(new v($t[0]/$t[3],$t[1]/$t[3]))}return oe}(M,Q),nt=function(st,mt,St,Vt){let oe=[],Wt=[],$t=Vt[8]*mt,ve=Vt[9]*mt,Le=Vt[10]*mt,ni=Vt[11]*mt,bi=Vt[8]*St,ri=Vt[9]*St,ti=Vt[10]*St,Oe=Vt[11]*St;for(let fi of st){let qe=[],Ze=[];for(let Gi of fi){let Bi=Gi.x,hr=Gi.y,jr=Vt[0]*Bi+Vt[4]*hr+Vt[12],nn=Vt[1]*Bi+Vt[5]*hr+Vt[13],kn=Vt[2]*Bi+Vt[6]*hr+Vt[14],Po=Vt[3]*Bi+Vt[7]*hr+Vt[15],Ds=kn+Le,wn=Po+ni,os=jr+bi,ps=nn+ri,Ks=kn+ti,Ws=Po+Oe,Ln=new v((jr+$t)/wn,(nn+ve)/wn);Ln.z=Ds/wn,qe.push(Ln);let En=new v(os/Ws,ps/Ws);En.z=Ks/Ws,Ze.push(En)}oe.push(qe),Wt.push(Ze)}return[oe,Wt]}(m,z,D,Q);return function(st,mt,St){let Vt=1/0;TA(St,mt)&&(Vt=i1(St,mt[0]));for(let oe=0;oel.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(l=>{this.gradients[l.id]={}}),this.layoutVertexArray=new Z,this.layoutVertexArray2=new N,this.indexArray=new ut,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.hasPattern=dm("line",this.layers,l);let m=this.layers[0].layout.get("line-sort-key"),w=!m.isConstant(),B=[];for(let{feature:S,id:Q,index:M,sourceLayerIndex:D}of e){let z=this.layers[0]._featureFilter.needGeometry,et=sa(S,z);if(!this.layers[0]._featureFilter.filter(new Hr(this.zoom),et,u))continue;let nt=w?m.evaluate(et,{},u):void 0,st={id:Q,properties:S.properties,type:S.type,sourceLayerIndex:D,index:M,geometry:z?et.geometry:Zr(S),patterns:{},sortKey:nt};B.push(st)}w&&B.sort((S,Q)=>S.sortKey-Q.sortKey);for(let S of B){let{geometry:Q,index:M,sourceLayerIndex:D}=S;if(this.hasPattern){let z=pm("line",this.layers,S,this.zoom,l);this.patternFeatures.push(z)}else this.addFeature(S,Q,M,u,{});l.featureIndex.insert(e[M].feature,Q,M,D,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}addFeatures(e,l,u){for(let m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,l,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,dS)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hS),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,l,u,m,w){let B=this.layers[0].layout,S=B.get("line-join").evaluate(e,{}),Q=B.get("line-cap"),M=B.get("line-miter-limit"),D=B.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(let z of l)this.addLine(z,e,S,Q,M,D);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,w,m)}addLine(e,l,u,m,w,B){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let Vt=0;Vt=2&&e[Q-1].equals(e[Q-2]);)Q--;let M=0;for(;M0;if(ni&&Vt>M){let Oe=et.dist(nt);if(Oe>2*D){let fi=et.sub(et.sub(nt)._mult(D/Oe)._round());this.updateDistance(nt,fi),this.addCurrentVertex(fi,mt,0,0,z),nt=fi}}let ri=nt&&st,ti=ri?u:S?"butt":m;if(ri&&ti==="round"&&(vew&&(ti="bevel"),ti==="bevel"&&(ve>2&&(ti="flipbevel"),ve100)oe=St.mult(-1);else{let Oe=ve*mt.add(St).mag()/mt.sub(St).mag();oe._perp()._mult(Oe*(bi?-1:1))}this.addCurrentVertex(et,oe,0,0,z),this.addCurrentVertex(et,oe.mult(-1),0,0,z)}else if(ti==="bevel"||ti==="fakeround"){let Oe=-Math.sqrt(ve*ve-1),fi=bi?Oe:0,qe=bi?0:Oe;if(nt&&this.addCurrentVertex(et,mt,fi,qe,z),ti==="fakeround"){let Ze=Math.round(180*Le/Math.PI/20);for(let Gi=1;Gi2*D){let fi=et.add(st.sub(et)._mult(D/Oe)._round());this.updateDistance(et,fi),this.addCurrentVertex(fi,St,0,0,z),et=fi}}}}addCurrentVertex(e,l,u,m,w,B=!1){let S=l.y*m-l.x,Q=-l.y-l.x*m;this.addHalfVertex(e,l.x+l.y*u,l.y-l.x*u,B,!1,u,w),this.addHalfVertex(e,S,Q,B,!0,-m,w),this.distance>r1/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,l,u,m,w,B))}addHalfVertex({x:e,y:l},u,m,w,B,S,Q){let M=.5*(this.lineClips?this.scaledDistance*(r1-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(w?1:0),(l<<1)+(B?1:0),Math.round(63*u)+128,Math.round(63*m)+128,1+(S===0?0:S<0?-1:1)|(63&M)<<2,M>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let D=Q.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,D),Q.primitiveLength++),B?this.e2=D:this.e1=D}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,l){this.distance+=e.dist(l),this.updateScaledDistance()}}let n1,s1;si("LineBucket",Im,{omit:["layers","patternFeatures"]});var o1={get paint(){return s1=s1||new Jn({"line-opacity":new Hi(xt.paint_line["line-opacity"]),"line-color":new Hi(xt.paint_line["line-color"]),"line-translate":new wi(xt.paint_line["line-translate"]),"line-translate-anchor":new wi(xt.paint_line["line-translate-anchor"]),"line-width":new Hi(xt.paint_line["line-width"]),"line-gap-width":new Hi(xt.paint_line["line-gap-width"]),"line-offset":new Hi(xt.paint_line["line-offset"]),"line-blur":new Hi(xt.paint_line["line-blur"]),"line-dasharray":new wc(xt.paint_line["line-dasharray"]),"line-pattern":new Na(xt.paint_line["line-pattern"]),"line-gradient":new ll(xt.paint_line["line-gradient"])})},get layout(){return n1=n1||new Jn({"line-cap":new wi(xt.layout_line["line-cap"]),"line-join":new Hi(xt.layout_line["line-join"]),"line-miter-limit":new wi(xt.layout_line["line-miter-limit"]),"line-round-limit":new wi(xt.layout_line["line-round-limit"]),"line-sort-key":new Hi(xt.layout_line["line-sort-key"])})}};class mS extends Hi{possiblyEvaluate(e,l){return l=new Hr(Math.floor(l.zoom),{now:l.now,fadeDuration:l.fadeDuration,zoomHistory:l.zoomHistory,transition:l.transition}),super.possiblyEvaluate(e,l)}evaluate(e,l,u,m){return l=Tt({},l,{zoom:Math.floor(l.zoom)}),super.evaluate(e,l,u,m)}}let td;class CS extends ns{constructor(e){super(e,o1),this.gradientVersion=0,td||(td=new mS(o1.paint.properties["line-width"].specification),td.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let l=this.gradientExpression();this.stepInterpolant=!!function(u){return u._styleExpression!==void 0}(l)&&l._styleExpression.expression instanceof _o,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,l){super.recalculate(e,l),this.paint._values["line-floorwidth"]=td.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Im(e)}queryRadius(e){let l=e,u=a1(UA("line-width",this,l),UA("line-gap-width",this,l)),m=UA("line-offset",this,l);return u/2+Math.abs(m)+GA(this.paint.get("line-translate"))}queryIntersectsFeature(e,l,u,m,w,B,S){let Q=lu(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),B.angle,S),M=S/2*a1(this.paint.get("line-width").evaluate(l,u),this.paint.get("line-gap-width").evaluate(l,u)),D=this.paint.get("line-offset").evaluate(l,u);return D&&(m=function(z,et){let nt=[];for(let st=0;st=3){for(let St=0;St0?e+2*a:a}let IS=dn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),yS=dn([{name:"a_projected_pos",components:3,type:"Float32"}],4);dn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let bS=dn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);dn([{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"}]);let A1=dn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),vS=dn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function wS(a,e,l){return a.sections.forEach(u=>{u.text=function(m,w,B){let S=w.layout.get("text-transform").evaluate(B,{});return S==="uppercase"?m=m.toLocaleUpperCase():S==="lowercase"&&(m=m.toLocaleLowerCase()),Go.applyArabicShaping&&(m=Go.applyArabicShaping(m)),m}(u.text,e,l)}),a}dn([{name:"triangle",components:3,type:"Uint16"}]),dn([{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"}]),dn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),dn([{type:"Float32",name:"offsetX"}]),dn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),dn([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);let Lh={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var Fn=24,l1=Dr,c1=function(a,e,l,u,m){var w,B,S=8*m-u-1,Q=(1<>1,D=-7,z=l?m-1:0,et=l?-1:1,nt=a[e+z];for(z+=et,w=nt&(1<<-D)-1,nt>>=-D,D+=S;D>0;w=256*w+a[e+z],z+=et,D-=8);for(B=w&(1<<-D)-1,w>>=-D,D+=u;D>0;B=256*B+a[e+z],z+=et,D-=8);if(w===0)w=1-M;else{if(w===Q)return B?NaN:1/0*(nt?-1:1);B+=Math.pow(2,u),w-=M}return(nt?-1:1)*B*Math.pow(2,w-u)},u1=function(a,e,l,u,m,w){var B,S,Q,M=8*w-m-1,D=(1<>1,et=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,nt=u?0:w-1,st=u?1:-1,mt=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(S=isNaN(e)?1:0,B=D):(B=Math.floor(Math.log(e)/Math.LN2),e*(Q=Math.pow(2,-B))<1&&(B--,Q*=2),(e+=B+z>=1?et/Q:et*Math.pow(2,1-z))*Q>=2&&(B++,Q/=2),B+z>=D?(S=0,B=D):B+z>=1?(S=(e*Q-1)*Math.pow(2,m),B+=z):(S=e*Math.pow(2,z-1)*Math.pow(2,m),B=0));m>=8;a[l+nt]=255&S,nt+=st,S/=256,m-=8);for(B=B<0;a[l+nt]=255&B,nt+=st,B/=256,M-=8);a[l+nt-st]|=128*mt};function Dr(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}Dr.Varint=0,Dr.Fixed64=1,Dr.Bytes=2,Dr.Fixed32=5;var ym=4294967296,h1=1/ym,g1=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function pl(a){return a.type===Dr.Bytes?a.readVarint()+a.pos:a.pos+1}function Cu(a,e,l){return l?4294967296*e+(a>>>0):4294967296*(e>>>0)+(a>>>0)}function d1(a,e,l){var u=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));l.realloc(u);for(var m=l.pos-1;m>=a;m--)l.buf[m+u]=l.buf[m]}function BS(a,e){for(var l=0;l>>8,a[l+2]=e>>>16,a[l+3]=e>>>24}function p1(a,e){return(a[e]|a[e+1]<<8|a[e+2]<<16)+(a[e+3]<<24)}Dr.prototype={destroy:function(){this.buf=null},readFields:function(a,e,l){for(l=l||this.length;this.pos>3,w=this.pos;this.type=7&u,a(m,e,this),this.pos===w&&this.skip(u)}return e},readMessage:function(a,e){return this.readFields(a,e,this.readVarint()+this.pos)},readFixed32:function(){var a=ed(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=p1(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=ed(this.buf,this.pos)+ed(this.buf,this.pos+4)*ym;return this.pos+=8,a},readSFixed64:function(){var a=ed(this.buf,this.pos)+p1(this.buf,this.pos+4)*ym;return this.pos+=8,a},readFloat:function(){var a=c1(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=c1(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var e,l,u=this.buf;return e=127&(l=u[this.pos++]),l<128?e:(e|=(127&(l=u[this.pos++]))<<7,l<128?e:(e|=(127&(l=u[this.pos++]))<<14,l<128?e:(e|=(127&(l=u[this.pos++]))<<21,l<128?e:function(m,w,B){var S,Q,M=B.buf;if(S=(112&(Q=M[B.pos++]))>>4,Q<128||(S|=(127&(Q=M[B.pos++]))<<3,Q<128)||(S|=(127&(Q=M[B.pos++]))<<10,Q<128)||(S|=(127&(Q=M[B.pos++]))<<17,Q<128)||(S|=(127&(Q=M[B.pos++]))<<24,Q<128)||(S|=(1&(Q=M[B.pos++]))<<31,Q<128))return Cu(m,S,w);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(l=u[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?(a+1)/-2:a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var a=this.readVarint()+this.pos,e=this.pos;return this.pos=a,a-e>=12&&g1?function(l,u,m){return g1.decode(l.subarray(u,m))}(this.buf,e,a):function(l,u,m){for(var w="",B=u;B239?4:D>223?3:D>191?2:1;if(B+et>m)break;et===1?D<128&&(z=D):et===2?(192&(S=l[B+1]))==128&&(z=(31&D)<<6|63&S)<=127&&(z=null):et===3?(Q=l[B+2],(192&(S=l[B+1]))==128&&(192&Q)==128&&((z=(15&D)<<12|(63&S)<<6|63&Q)<=2047||z>=55296&&z<=57343)&&(z=null)):et===4&&(Q=l[B+2],M=l[B+3],(192&(S=l[B+1]))==128&&(192&Q)==128&&(192&M)==128&&((z=(15&D)<<18|(63&S)<<12|(63&Q)<<6|63&M)<=65535||z>=1114112)&&(z=null)),z===null?(z=65533,et=1):z>65535&&(z-=65536,w+=String.fromCharCode(z>>>10&1023|55296),z=56320|1023&z),w+=String.fromCharCode(z),B+=et}return w}(this.buf,e,a)},readBytes:function(){var a=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,a);return this.pos=a,e},readPackedVarint:function(a,e){if(this.type!==Dr.Bytes)return a.push(this.readVarint(e));var l=pl(this);for(a=a||[];this.pos127;);else if(e===Dr.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Dr.Fixed32)this.pos+=4;else{if(e!==Dr.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(a,e){this.writeVarint(a<<3|e)},realloc:function(a){for(var e=this.length||16;e268435455||a<0?function(e,l){var u,m;if(e>=0?(u=e%4294967296|0,m=e/4294967296|0):(m=~(-e/4294967296),4294967295^(u=~(-e%4294967296))?u=u+1|0:(u=0,m=m+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");l.realloc(10),function(w,B,S){S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,S.buf[S.pos]=127&(w>>>=7)}(u,0,l),function(w,B){var S=(7&w)<<4;B.buf[B.pos++]|=S|((w>>>=3)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w)))))}(m,l)}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?2*-a-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var e=this.pos;this.pos=function(u,m,w){for(var B,S,Q=0;Q55295&&B<57344){if(!S){B>56319||Q+1===m.length?(u[w++]=239,u[w++]=191,u[w++]=189):S=B;continue}if(B<56320){u[w++]=239,u[w++]=191,u[w++]=189,S=B;continue}B=S-55296<<10|B-56320|65536,S=null}else S&&(u[w++]=239,u[w++]=191,u[w++]=189,S=null);B<128?u[w++]=B:(B<2048?u[w++]=B>>6|192:(B<65536?u[w++]=B>>12|224:(u[w++]=B>>18|240,u[w++]=B>>12&63|128),u[w++]=B>>6&63|128),u[w++]=63&B|128)}return w}(this.buf,a,this.pos);var l=this.pos-e;l>=128&&d1(e,l,this),this.pos=e-1,this.writeVarint(l),this.pos+=l},writeFloat:function(a){this.realloc(4),u1(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),u1(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var e=a.length;this.writeVarint(e),this.realloc(e);for(var l=0;l=128&&d1(l,u,this),this.pos=l-1,this.writeVarint(u),this.pos+=u},writeMessage:function(a,e,l){this.writeTag(a,Dr.Bytes),this.writeRawMessage(e,l)},writePackedVarint:function(a,e){e.length&&this.writeMessage(a,BS,e)},writePackedSVarint:function(a,e){e.length&&this.writeMessage(a,_S,e)},writePackedBoolean:function(a,e){e.length&&this.writeMessage(a,FS,e)},writePackedFloat:function(a,e){e.length&&this.writeMessage(a,xS,e)},writePackedDouble:function(a,e){e.length&&this.writeMessage(a,SS,e)},writePackedFixed32:function(a,e){e.length&&this.writeMessage(a,kS,e)},writePackedSFixed32:function(a,e){e.length&&this.writeMessage(a,LS,e)},writePackedFixed64:function(a,e){e.length&&this.writeMessage(a,ES,e)},writePackedSFixed64:function(a,e){e.length&&this.writeMessage(a,TS,e)},writeBytesField:function(a,e){this.writeTag(a,Dr.Bytes),this.writeBytes(e)},writeFixed32Field:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeSFixed64(e)},writeVarintField:function(a,e){this.writeTag(a,Dr.Varint),this.writeVarint(e)},writeSVarintField:function(a,e){this.writeTag(a,Dr.Varint),this.writeSVarint(e)},writeStringField:function(a,e){this.writeTag(a,Dr.Bytes),this.writeString(e)},writeFloatField:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeFloat(e)},writeDoubleField:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeDouble(e)},writeBooleanField:function(a,e){this.writeVarintField(a,Boolean(e))}};var bm=g(l1);let vm=3;function QS(a,e,l){a===1&&l.readMessage(US,e)}function US(a,e,l){if(a===3){let{id:u,bitmap:m,width:w,height:B,left:S,top:Q,advance:M}=l.readMessage(GS,{});e.push({id:u,bitmap:new Zo({width:w+2*vm,height:B+2*vm},m),metrics:{width:w,height:B,left:S,top:Q,advance:M}})}}function GS(a,e,l){a===1?e.id=l.readVarint():a===2?e.bitmap=l.readBytes():a===3?e.width=l.readVarint():a===4?e.height=l.readVarint():a===5?e.left=l.readSVarint():a===6?e.top=l.readSVarint():a===7&&(e.advance=l.readVarint())}let f1=vm;function m1(a){let e=0,l=0;for(let B of a)e+=B.w*B.h,l=Math.max(l,B.w);a.sort((B,S)=>S.h-B.h);let u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),l),h:1/0}],m=0,w=0;for(let B of a)for(let S=u.length-1;S>=0;S--){let Q=u[S];if(!(B.w>Q.w||B.h>Q.h)){if(B.x=Q.x,B.y=Q.y,w=Math.max(w,B.y+B.h),m=Math.max(m,B.x+B.w),B.w===Q.w&&B.h===Q.h){let M=u.pop();S=0&&u>=e&&rd[this.text.charCodeAt(u)];u--)l--;this.text=this.text.substring(e,l),this.sectionIndex=this.sectionIndex.slice(e,l)}substring(e,l){let u=new yu;return u.text=this.text.substring(e,l),u.sectionIndex=this.sectionIndex.slice(e,l),u.sections=this.sections,u}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,l)=>Math.max(e,this.sections[l].scale),0)}addTextSection(e,l){this.text+=e.text,this.sections.push(Th.forText(e.scale,e.fontStack||l));let u=this.sections.length-1;for(let m=0;m=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function id(a,e,l,u,m,w,B,S,Q,M,D,z,et,nt,st,mt){let St=yu.fromFeature(a,m),Vt;z===A.ah.vertical&&St.verticalizePunctuation();let{processBidirectionalText:oe,processStyledBidirectionalText:Wt}=Go;if(oe&&St.sections.length===1){Vt=[];let Le=oe(St.toString(),Bm(St,M,w,e,u,nt,st));for(let ni of Le){let bi=new yu;bi.text=ni,bi.sections=St.sections;for(let ri=0;ri0&&ml>go&&(go=ml)}else{let aa=bi[mr.fontStack],fo=aa&&aa[fs];if(fo&&fo.rect)Ja=fo.rect,ba=fo.metrics;else{let ml=ni[mr.fontStack],Hh=ml&&ml[fs];if(!Hh)continue;ba=Hh.metrics}Qn=(En-mr.scale)*Fn}va?(Le.verticalizable=!0,ks.push({glyph:fs,imageName:Xa,x:jr,y:nn+Qn,vertical:va,scale:mr.scale,fontStack:mr.fontStack,sectionIndex:Ls,metrics:ba,rect:Ja}),jr+=fl*mr.scale+Gi):(ks.push({glyph:fs,imageName:Xa,x:jr,y:nn+Qn,vertical:va,scale:mr.scale,fontStack:mr.fontStack,sectionIndex:Ls,metrics:ba,rect:Ja}),jr+=ba.advance*mr.scale+Gi)}ks.length!==0&&(kn=Math.max(jr-Gi,kn),ZS(ks,0,ks.length-1,Ds,go)),jr=0;let po=Oe*En+go;Os.lineOffset=Math.max(go,Fs),nn+=po,Po=Math.max(po,Po),++wn}var os;let ps=nn-Eh,{horizontalAlign:Ks,verticalAlign:Ws}=_m(fi);(function(Ln,En,Fs,Os,ks,go,po,Tn,mr){let Ls=(En-Fs)*ks,fs=0;fs=go!==po?-Tn*Os-Eh:(-Os*mr+.5)*po;for(let Qn of Ln)for(let ba of Qn.positionedGlyphs)ba.x+=Ls,ba.y+=fs})(Le.positionedLines,Ds,Ks,Ws,kn,Po,Oe,ps,ti.length),Le.top+=-Ws*ps,Le.bottom=Le.top+ps,Le.left+=-Ks*kn,Le.right=Le.left+kn}(ve,e,l,u,Vt,B,S,Q,z,M,et,mt),!function(Le){for(let ni of Le)if(ni.positionedGlyphs.length!==0)return!1;return!0}($t)&&ve}let rd={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},RS={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function I1(a,e,l,u,m,w){if(e.imageName){let B=u[e.imageName];return B?B.displaySize[0]*e.scale*Fn/w+m:0}{let B=l[e.fontStack],S=B&&B[a];return S?S.metrics.advance*e.scale+m:0}}function y1(a,e,l,u){let m=Math.pow(a-e,2);return u?a=0,D=0;for(let et=0;etB.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=mh([]),this.placementViewportMatrix=mh([]);let l=this.layers[0]._unevaluatedLayout._values;this.textSizeData=B1(this.zoom,l["text-size"]),this.iconSizeData=B1(this.zoom,l["icon-size"]);let u=this.layers[0].layout,m=u.get("symbol-sort-key"),w=u.get("symbol-z-order");this.canOverlap=xm(u,"text-overlap","text-allow-overlap")!=="never"||xm(u,"icon-overlap","icon-allow-overlap")!=="never"||u.get("text-ignore-placement")||u.get("icon-ignore-placement"),this.sortFeaturesByKey=w!=="viewport-y"&&!m.isConstant(),this.sortFeaturesByY=(w==="viewport-y"||w==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,u.get("symbol-placement")==="point"&&(this.writingModes=u.get("text-writing-mode").map(B=>A.ah[B])),this.stateDependentLayerIds=this.layers.filter(B=>B.isStateDependent()).map(B=>B.id),this.sourceID=e.sourceID}createArrays(){this.text=new Fm(new _r(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Fm(new _r(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new f,this.lineVertexArray=new b,this.symbolInstances=new p,this.textAnchorOffsets=new E}calculateGlyphDependencies(e,l,u,m,w){for(let B=0;B0)&&(B.value.kind!=="constant"||B.value.value.length>0),D=Q.value.kind!=="constant"||!!Q.value.value||Object.keys(Q.parameters).length>0,z=w.get("symbol-sort-key");if(this.features=[],!M&&!D)return;let et=l.iconDependencies,nt=l.glyphDependencies,st=l.availableImages,mt=new Hr(this.zoom);for(let{feature:St,id:Vt,index:oe,sourceLayerIndex:Wt}of e){let $t=m._featureFilter.needGeometry,ve=sa(St,$t);if(!m._featureFilter.filter(mt,ve,u))continue;let Le,ni;if($t||(ve.geometry=Zr(St)),M){let ri=m.getValueAndResolveTokens("text-field",ve,u,st),ti=Sr.factory(ri),Oe=this.hasRTLText=this.hasRTLText||VS(ti);(!Oe||Go.getRTLTextPluginStatus()==="unavailable"||Oe&&Go.isParsed())&&(Le=wS(ti,m,ve))}if(D){let ri=m.getValueAndResolveTokens("icon-image",ve,u,st);ni=ri instanceof Dn?ri:Dn.fromString(ri)}if(!Le&&!ni)continue;let bi=this.sortFeaturesByKey?z.evaluate(ve,{},u):void 0;if(this.features.push({id:Vt,text:Le,icon:ni,index:oe,sourceLayerIndex:Wt,geometry:ve.geometry,properties:St.properties,type:MS[St.type],sortKey:bi}),ni&&(et[ni.name]=!0),Le){let ri=B.evaluate(ve,{},u).join(","),ti=w.get("text-rotation-alignment")!=="viewport"&&w.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(A.ah.vertical)>=0;for(let Oe of Le.sections)if(Oe.image)et[Oe.image.name]=!0;else{let fi=Pa(Le.toString()),qe=Oe.fontStack||ri,Ze=nt[qe]=nt[qe]||{};this.calculateGlyphDependencies(Oe.text,Ze,ti,this.allowVerticalPlacement,fi)}}}w.get("symbol-placement")==="line"&&(this.features=function(St){let Vt={},oe={},Wt=[],$t=0;function ve(ri){Wt.push(St[ri]),$t++}function Le(ri,ti,Oe){let fi=oe[ri];return delete oe[ri],oe[ti]=fi,Wt[fi].geometry[0].pop(),Wt[fi].geometry[0]=Wt[fi].geometry[0].concat(Oe[0]),fi}function ni(ri,ti,Oe){let fi=Vt[ti];return delete Vt[ti],Vt[ri]=fi,Wt[fi].geometry[0].shift(),Wt[fi].geometry[0]=Oe[0].concat(Wt[fi].geometry[0]),fi}function bi(ri,ti,Oe){let fi=Oe?ti[0][ti[0].length-1]:ti[0][0];return`${ri}:${fi.x}:${fi.y}`}for(let ri=0;riri.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((St,Vt)=>St.sortKey-Vt.sortKey)}update(e,l,u){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,l,this.layers,u),this.icon.programConfigurations.updatePaintArrays(e,l,this.layers,u))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,l){let u=this.lineVertexArray.length;if(e.segment!==void 0){let m=e.dist(l[e.segment+1]),w=e.dist(l[e.segment]),B={};for(let S=e.segment+1;S=0;S--)B[S]={x:l[S].x,y:l[S].y,tileUnitDistanceFromAnchor:w},S>0&&(w+=l[S-1].dist(l[S]));for(let S=0;S0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,l){let u=e.placedSymbolArray.get(l),m=u.vertexStartIndex+4*u.numGlyphs;for(let w=u.vertexStartIndex;wm[S]-m[Q]||w[Q]-w[S]),B}addToSortKeyRanges(e,l){let u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===l?u.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:l,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let l of this.symbolInstanceIndexes){let u=this.symbolInstances.get(l);this.featureSortOrder.push(u.featureIndex),[u.rightJustifiedTextSymbolIndex,u.centerJustifiedTextSymbolIndex,u.leftJustifiedTextSymbolIndex].forEach((m,w,B)=>{m>=0&&B.indexOf(m)===w&&this.addIndicesForPlacedSymbol(this.text,m)}),u.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,u.verticalPlacedTextSymbolIndex),u.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.placedIconSymbolIndex),u.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let _1,x1;si("SymbolBucket",bu,{omit:["layers","collisionBoxArray","features","compareText"]}),bu.MAX_GLYPHS=65535,bu.addDynamicAttributes=Sm;var Lm={get paint(){return x1=x1||new Jn({"icon-opacity":new Hi(xt.paint_symbol["icon-opacity"]),"icon-color":new Hi(xt.paint_symbol["icon-color"]),"icon-halo-color":new Hi(xt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Hi(xt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Hi(xt.paint_symbol["icon-halo-blur"]),"icon-translate":new wi(xt.paint_symbol["icon-translate"]),"icon-translate-anchor":new wi(xt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Hi(xt.paint_symbol["text-opacity"]),"text-color":new Hi(xt.paint_symbol["text-color"],{runtimeType:Zi,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new Hi(xt.paint_symbol["text-halo-color"]),"text-halo-width":new Hi(xt.paint_symbol["text-halo-width"]),"text-halo-blur":new Hi(xt.paint_symbol["text-halo-blur"]),"text-translate":new wi(xt.paint_symbol["text-translate"]),"text-translate-anchor":new wi(xt.paint_symbol["text-translate-anchor"])})},get layout(){return _1=_1||new Jn({"symbol-placement":new wi(xt.layout_symbol["symbol-placement"]),"symbol-spacing":new wi(xt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new wi(xt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Hi(xt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new wi(xt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new wi(xt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new wi(xt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new wi(xt.layout_symbol["icon-ignore-placement"]),"icon-optional":new wi(xt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new wi(xt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Hi(xt.layout_symbol["icon-size"]),"icon-text-fit":new wi(xt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new wi(xt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Hi(xt.layout_symbol["icon-image"]),"icon-rotate":new Hi(xt.layout_symbol["icon-rotate"]),"icon-padding":new Hi(xt.layout_symbol["icon-padding"]),"icon-keep-upright":new wi(xt.layout_symbol["icon-keep-upright"]),"icon-offset":new Hi(xt.layout_symbol["icon-offset"]),"icon-anchor":new Hi(xt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new wi(xt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new wi(xt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new wi(xt.layout_symbol["text-rotation-alignment"]),"text-field":new Hi(xt.layout_symbol["text-field"]),"text-font":new Hi(xt.layout_symbol["text-font"]),"text-size":new Hi(xt.layout_symbol["text-size"]),"text-max-width":new Hi(xt.layout_symbol["text-max-width"]),"text-line-height":new wi(xt.layout_symbol["text-line-height"]),"text-letter-spacing":new Hi(xt.layout_symbol["text-letter-spacing"]),"text-justify":new Hi(xt.layout_symbol["text-justify"]),"text-radial-offset":new Hi(xt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new wi(xt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Hi(xt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Hi(xt.layout_symbol["text-anchor"]),"text-max-angle":new wi(xt.layout_symbol["text-max-angle"]),"text-writing-mode":new wi(xt.layout_symbol["text-writing-mode"]),"text-rotate":new Hi(xt.layout_symbol["text-rotate"]),"text-padding":new wi(xt.layout_symbol["text-padding"]),"text-keep-upright":new wi(xt.layout_symbol["text-keep-upright"]),"text-transform":new Hi(xt.layout_symbol["text-transform"]),"text-offset":new Hi(xt.layout_symbol["text-offset"]),"text-allow-overlap":new wi(xt.layout_symbol["text-allow-overlap"]),"text-overlap":new wi(xt.layout_symbol["text-overlap"]),"text-ignore-placement":new wi(xt.layout_symbol["text-ignore-placement"]),"text-optional":new wi(xt.layout_symbol["text-optional"])})}};class S1{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:We,this.defaultValue=e}evaluate(e){if(e.formattedSection){let l=this.defaultValue.property.overrides;if(l&&l.hasOverride(e.formattedSection))return l.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}si("FormatSectionOverride",S1,{omit:["defaultValue"]});class sd extends ns{constructor(e){super(e,Lm)}recalculate(e,l){if(super.recalculate(e,l),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){let u=this.layout.get("text-writing-mode");if(u){let m=[];for(let w of u)m.indexOf(w)<0&&m.push(w);this.layout._values["text-writing-mode"]=m}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,l,u,m){let w=this.layout.get(e).evaluate(l,{},u,m),B=this._unevaluatedLayout._values[e];return B.isDataDriven()||Xi(B.value)||!w?w:function(S,Q){return Q.replace(/{([^{}]+)}/g,(M,D)=>S&&D in S?String(S[D]):"")}(l.properties,w)}createBucket(e){return new bu(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of Lm.paint.overridableProperties){if(!sd.hasPaintOverride(this.layout,e))continue;let l=this.paint.get(e),u=new S1(l),m=new Vr(u,l.property.specification),w=null;w=l.value.kind==="constant"||l.value.kind==="source"?new un("source",m):new hn("composite",m,l.value.zoomStops),this.paint._values[e]=new Ao(l.property,w,l.parameters)}}_handleOverridablePaintPropertyUpdate(e,l,u){return!(!this.layout||l.isDataDriven()||u.isDataDriven())&&sd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,l){let u=e.get("text-field"),m=Lm.paint.properties[l],w=!1,B=S=>{for(let Q of S)if(m.overrides&&m.overrides.hasOverride(Q))return void(w=!0)};if(u.value.kind==="constant"&&u.value.value instanceof Sr)B(u.value.value.sections);else if(u.value.kind==="source"){let S=M=>{w||(M instanceof Fr&&Qr(M.value)===Lr?B(M.value.sections):M instanceof Xo?B(M.sections):M.eachChild(S))},Q=u.value;Q._styleExpression&&S(Q._styleExpression.expression)}return w}}let F1;var DS={get paint(){return F1=F1||new Jn({"background-color":new wi(xt.paint_background["background-color"]),"background-pattern":new wc(xt.paint_background["background-pattern"]),"background-opacity":new wi(xt.paint_background["background-opacity"])})}};class KS extends ns{constructor(e){super(e,DS)}}let k1;var WS={get paint(){return k1=k1||new Jn({"raster-opacity":new wi(xt.paint_raster["raster-opacity"]),"raster-hue-rotate":new wi(xt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new wi(xt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new wi(xt.paint_raster["raster-brightness-max"]),"raster-saturation":new wi(xt.paint_raster["raster-saturation"]),"raster-contrast":new wi(xt.paint_raster["raster-contrast"]),"raster-resampling":new wi(xt.paint_raster["raster-resampling"]),"raster-fade-duration":new wi(xt.paint_raster["raster-fade-duration"])})}};class OS extends ns{constructor(e){super(e,WS)}}class zS extends ns{constructor(e){super(e,{}),this.onAdd=l=>{this.implementation.onAdd&&this.implementation.onAdd(l,l.painter.context.gl)},this.onRemove=l=>{this.implementation.onRemove&&this.implementation.onRemove(l,l.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class JS{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let Em=63710088e-1;class Yl{constructor(e,l){if(isNaN(e)||isNaN(l))throw new Error(`Invalid LngLat object: (${e}, ${l})`);if(this.lng=+e,this.lat=+l,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Yl(Lt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let l=Math.PI/180,u=this.lat*l,m=e.lat*l,w=Math.sin(u)*Math.sin(m)+Math.cos(u)*Math.cos(m)*Math.cos((e.lng-this.lng)*l);return Em*Math.acos(Math.min(w,1))}static convert(e){if(e instanceof Yl)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Yl(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Yl(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}let L1=2*Math.PI*Em;function E1(a){return L1*Math.cos(a*Math.PI/180)}function T1(a){return(180+a)/360}function Q1(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function U1(a,e){return a/E1(e)}function Tm(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}class od{constructor(e,l,u=0){this.x=+e,this.y=+l,this.z=+u}static fromLngLat(e,l=0){let u=Yl.convert(e);return new od(T1(u.lng),Q1(u.lat),U1(l,u.lat))}toLngLat(){return new Yl(360*this.x-180,Tm(this.y))}toAltitude(){return this.z*E1(Tm(this.y))}meterInMercatorCoordinateUnits(){return 1/L1*(e=Tm(this.y),1/Math.cos(e*Math.PI/180));var e}}function G1(a,e,l){var u=2*Math.PI*6378137/256/Math.pow(2,l);return[a*u-2*Math.PI*6378137/2,e*u-2*Math.PI*6378137/2]}class Qm{constructor(e,l,u){if(e<0||e>25||u<0||u>=Math.pow(2,e)||l<0||l>=Math.pow(2,e))throw new Error(`x=${l}, y=${u}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=l,this.y=u,this.key=Uh(0,e,e,l,u)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,l,u){let m=(B=this.y,S=this.z,Q=G1(256*(w=this.x),256*(B=Math.pow(2,S)-B-1),S),M=G1(256*(w+1),256*(B+1),S),Q[0]+","+Q[1]+","+M[0]+","+M[1]);var w,B,S,Q,M;let D=function(z,et,nt){let st,mt="";for(let St=z;St>0;St--)st=1<1?"@2x":"").replace(/{quadkey}/g,D).replace(/{bbox-epsg-3857}/g,m)}isChildOf(e){let l=this.z-e.z;return l>0&&e.x===this.x>>l&&e.y===this.y>>l}getTilePoint(e){let l=Math.pow(2,this.z);return new v((e.x*l-this.x)*$i,(e.y*l-this.y)*$i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class R1{constructor(e,l){this.wrap=e,this.canonical=l,this.key=Uh(e,l.z,l.z,l.x,l.y)}}class oa{constructor(e,l,u,m,w){if(e= z; overscaledZ = ${e}; z = ${u}`);this.overscaledZ=e,this.wrap=l,this.canonical=new Qm(u,+m,+w),this.key=Uh(l,e,u,m,w)}clone(){return new oa(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let l=this.canonical.z-e;return e>this.canonical.z?new oa(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oa(e,this.wrap,e,this.canonical.x>>l,this.canonical.y>>l)}calculateScaledKey(e,l){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let u=this.canonical.z-e;return e>this.canonical.z?Uh(this.wrap*+l,e,this.canonical.z,this.canonical.x,this.canonical.y):Uh(this.wrap*+l,e,e,this.canonical.x>>u,this.canonical.y>>u)}isChildOf(e){if(e.wrap!==this.wrap)return!1;let l=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>l&&e.canonical.y===this.canonical.y>>l}children(e){if(this.overscaledZ>=e)return[new oa(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let l=this.canonical.z+1,u=2*this.canonical.x,m=2*this.canonical.y;return[new oa(l,this.wrap,l,u,m),new oa(l,this.wrap,l,u+1,m),new oa(l,this.wrap,l,u,m+1),new oa(l,this.wrap,l,u+1,m+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.max&&(this.max=z),z=this.dim+1||l<-1||l>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(l+1)*this.stride+(e+1)}unpack(e,l,u){return e*this.redFactor+l*this.greenFactor+u*this.blueFactor-this.baseShift}getPixels(){return new Vs({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,l,u){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let m=l*this.dim,w=l*this.dim+this.dim,B=u*this.dim,S=u*this.dim+this.dim;switch(l){case-1:m=w-1;break;case 1:w=m+1}switch(u){case-1:B=S-1;break;case 1:S=B+1}let Q=-l*this.dim,M=-u*this.dim;for(let D=B;D=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class P1{constructor(e,l,u,m,w){this.type="Feature",this._vectorTileFeature=e,e._z=l,e._x=u,e._y=m,this.properties=e.properties,this.id=w}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let l in this)l!=="_geometry"&&l!=="_vectorTileFeature"&&(e[l]=this[l]);return e}}class M1{constructor(e,l){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new cs($i,16,0),this.grid3D=new cs($i,16,0),this.featureIndexArray=new h,this.promoteId=l}insert(e,l,u,m,w,B){let S=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(u,m,w);let Q=B?this.grid3D:this.grid;for(let M=0;M=0&&z[3]>=0&&Q.insert(S,z[0],z[1],z[2],z[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new zl.VectorTile(new bm(this.rawTileData)).layers,this.sourceLayerCoder=new Z1(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,l,u,m){this.loadVTLayers();let w=e.params||{},B=$i/e.tileSize/e.scale,S=ga(w.filter),Q=e.queryGeometry,M=e.queryPadding*B,D=V1(Q),z=this.grid.query(D.minX-M,D.minY-M,D.maxX+M,D.maxY+M),et=V1(e.cameraQueryGeometry),nt=this.grid3D.query(et.minX-M,et.minY-M,et.maxX+M,et.maxY+M,(St,Vt,oe,Wt)=>function($t,ve,Le,ni,bi){for(let ti of $t)if(ve<=ti.x&&Le<=ti.y&&ni>=ti.x&&bi>=ti.y)return!0;let ri=[new v(ve,Le),new v(ve,bi),new v(ni,bi),new v(ni,Le)];if($t.length>2){for(let ti of ri)if(Wa($t,ti))return!0}for(let ti=0;ti<$t.length-1;ti++)if(fh($t[ti],$t[ti+1],ri))return!0;return!1}(e.cameraQueryGeometry,St-M,Vt-M,oe+M,Wt+M));for(let St of nt)z.push(St);z.sort(XS);let st={},mt;for(let St=0;St(Wt||(Wt=Zr($t)),ve.queryIntersectsFeature(Q,$t,Le,Wt,this.z,e.transform,B,e.pixelPosMatrix)))}return st}loadMatchingFeature(e,l,u,m,w,B,S,Q,M,D,z){let et=this.bucketLayerIDs[l];if(B&&!function(St,Vt){for(let oe=0;oe=0)return!0;return!1}(B,et))return;let nt=this.sourceLayerCoder.decode(u),st=this.vtLayers[nt].feature(m);if(w.needGeometry){let St=sa(st,!0);if(!w.filter(new Hr(this.tileID.overscaledZ),St,this.tileID.canonical))return}else if(!w.filter(new Hr(this.tileID.overscaledZ),st))return;let mt=this.getId(st,nt);for(let St=0;St{let S=e instanceof SA?e.get(B):null;return S&&S.evaluate?S.evaluate(l,u,m):S})}function V1(a){let e=1/0,l=1/0,u=-1/0,m=-1/0;for(let w of a)e=Math.min(e,w.x),l=Math.min(l,w.y),u=Math.max(u,w.x),m=Math.max(m,w.y);return{minX:e,minY:l,maxX:u,maxY:m}}function XS(a,e){return e-a}function D1(a,e,l,u,m){let w=[];for(let B=0;B=u&&z.x>=u||(D.x>=u?D=new v(u,D.y+(u-D.x)/(z.x-D.x)*(z.y-D.y))._round():z.x>=u&&(z=new v(u,D.y+(u-D.x)/(z.x-D.x)*(z.y-D.y))._round()),D.y>=m&&z.y>=m||(D.y>=m?D=new v(D.x+(m-D.y)/(z.y-D.y)*(z.x-D.x),m)._round():z.y>=m&&(z=new v(D.x+(m-D.y)/(z.y-D.y)*(z.x-D.x),m)._round()),Q&&D.equals(Q[Q.length-1])||(Q=[D],w.push(Q)),Q.push(z)))))}}return w}si("FeatureIndex",M1,{omit:["rawTileData","sourceLayerCoder"]});class jl extends v{constructor(e,l,u,m){super(e,l),this.angle=u,m!==void 0&&(this.segment=m)}clone(){return new jl(this.x,this.y,this.angle,this.segment)}}function K1(a,e,l,u,m){if(e.segment===void 0||l===0)return!0;let w=e,B=e.segment+1,S=0;for(;S>-l/2;){if(B--,B<0)return!1;S-=a[B].dist(w),w=a[B]}S+=a[B].dist(a[B+1]),B++;let Q=[],M=0;for(;Su;)M-=Q.shift().angleDelta;if(M>m)return!1;B++,S+=D.dist(z)}return!0}function W1(a){let e=0;for(let l=0;lM){let st=(M-Q)/nt,mt=qn.number(z.x,et.x,st),St=qn.number(z.y,et.y,st),Vt=new jl(mt,St,et.angleTo(z),D);return Vt._round(),!B||K1(a,Vt,S,B,e)?Vt:void 0}Q+=nt}}function jS(a,e,l,u,m,w,B,S,Q){let M=O1(u,w,B),D=z1(u,m),z=D*B,et=a[0].x===0||a[0].x===Q||a[0].y===0||a[0].y===Q;return e-z=0&&$t=0&&ve=0&&et+M<=D){let Le=new jl($t,ve,oe,st);Le._round(),u&&!K1(a,Le,w,u,m)||nt.push(Le)}}z+=Vt}return S||nt.length||B||(nt=J1(a,z/2,l,u,m,w,B,!0,Q)),nt}si("Anchor",jl);let vu=ho;function X1(a,e,l,u){let m=[],w=a.image,B=w.pixelRatio,S=w.paddedRect.w-2*vu,Q=w.paddedRect.h-2*vu,M=a.right-a.left,D=a.bottom-a.top,z=w.stretchX||[[0,S]],et=w.stretchY||[[0,Q]],nt=(Oe,fi)=>Oe+fi[1]-fi[0],st=z.reduce(nt,0),mt=et.reduce(nt,0),St=S-st,Vt=Q-mt,oe=0,Wt=st,$t=0,ve=mt,Le=0,ni=St,bi=0,ri=Vt;if(w.content&&u){let Oe=w.content;oe=ad(z,0,Oe[0]),$t=ad(et,0,Oe[1]),Wt=ad(z,Oe[0],Oe[2]),ve=ad(et,Oe[1],Oe[3]),Le=Oe[0]-oe,bi=Oe[1]-$t,ni=Oe[2]-Oe[0]-Wt,ri=Oe[3]-Oe[1]-ve}let ti=(Oe,fi,qe,Ze)=>{let Gi=Ad(Oe.stretch-oe,Wt,M,a.left),Bi=ld(Oe.fixed-Le,ni,Oe.stretch,st),hr=Ad(fi.stretch-$t,ve,D,a.top),jr=ld(fi.fixed-bi,ri,fi.stretch,mt),nn=Ad(qe.stretch-oe,Wt,M,a.left),kn=ld(qe.fixed-Le,ni,qe.stretch,st),Po=Ad(Ze.stretch-$t,ve,D,a.top),Ds=ld(Ze.fixed-bi,ri,Ze.stretch,mt),wn=new v(Gi,hr),os=new v(nn,hr),ps=new v(nn,Po),Ks=new v(Gi,Po),Ws=new v(Bi/B,jr/B),Ln=new v(kn/B,Ds/B),En=e*Math.PI/180;if(En){let ks=Math.sin(En),go=Math.cos(En),po=[go,-ks,ks,go];wn._matMult(po),os._matMult(po),Ks._matMult(po),ps._matMult(po)}let Fs=Oe.stretch+Oe.fixed,Os=fi.stretch+fi.fixed;return{tl:wn,tr:os,bl:Ks,br:ps,tex:{x:w.paddedRect.x+vu+Fs,y:w.paddedRect.y+vu+Os,w:qe.stretch+qe.fixed-Fs,h:Ze.stretch+Ze.fixed-Os},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ws,pixelOffsetBR:Ln,minFontScaleX:ni/B/M,minFontScaleY:ri/B/D,isSDF:l}};if(u&&(w.stretchX||w.stretchY)){let Oe=Y1(z,St,st),fi=Y1(et,Vt,mt);for(let qe=0;qe0&&(st=Math.max(10,st),this.circleDiameter=st)}else{let z=B.top*S-Q[0],et=B.bottom*S+Q[2],nt=B.left*S-Q[3],st=B.right*S+Q[1],mt=B.collisionPadding;if(mt&&(nt-=mt[0]*S,z-=mt[1]*S,st+=mt[2]*S,et+=mt[3]*S),D){let St=new v(nt,z),Vt=new v(st,z),oe=new v(nt,et),Wt=new v(st,et),$t=D*Math.PI/180;St._rotate($t),Vt._rotate($t),oe._rotate($t),Wt._rotate($t),nt=Math.min(St.x,Vt.x,oe.x,Wt.x),st=Math.max(St.x,Vt.x,oe.x,Wt.x),z=Math.min(St.y,Vt.y,oe.y,Wt.y),et=Math.max(St.y,Vt.y,oe.y,Wt.y)}e.emplaceBack(l.x,l.y,nt,z,st,et,u,m,w)}this.boxEndIndex=e.length}}class qS{constructor(e=[],l=$S){if(this.data=e,this.length=this.data.length,this.compare=l,this.length>0)for(let u=(this.length>>1)-1;u>=0;u--)this._down(u)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let e=this.data[0],l=this.data.pop();return this.length--,this.length>0&&(this.data[0]=l,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:l,compare:u}=this,m=l[e];for(;e>0;){let w=e-1>>1,B=l[w];if(u(m,B)>=0)break;l[e]=B,e=w}l[e]=m}_down(e){let{data:l,compare:u}=this,m=this.length>>1,w=l[e];for(;e=0)break;l[e]=S,e=B}l[e]=w}}function $S(a,e){return ae?1:0}function t3(a,e=1,l=!1){let u=1/0,m=1/0,w=-1/0,B=-1/0,S=a[0];for(let nt=0;ntw)&&(w=st.x),(!nt||st.y>B)&&(B=st.y)}let Q=Math.min(w-u,B-m),M=Q/2,D=new qS([],e3);if(Q===0)return new v(u,m);for(let nt=u;ntz.d||!z.d)&&(z=nt,l&&console.log("found best %d after %d probes",Math.round(1e4*nt.d)/1e4,et)),nt.max-z.d<=e||(M=nt.h/2,D.push(new wu(nt.p.x-M,nt.p.y-M,M,a)),D.push(new wu(nt.p.x+M,nt.p.y-M,M,a)),D.push(new wu(nt.p.x-M,nt.p.y+M,M,a)),D.push(new wu(nt.p.x+M,nt.p.y+M,M,a)),et+=4)}return l&&(console.log(`num probes: ${et}`),console.log(`best distance: ${z.d}`)),z.p}function e3(a,e){return e.max-a.max}function wu(a,e,l,u){this.p=new v(a,e),this.h=l,this.d=function(m,w){let B=!1,S=1/0;for(let Q=0;Qm.y!=st.y>m.y&&m.x<(st.x-nt.x)*(m.y-nt.y)/(st.y-nt.y)+nt.x&&(B=!B),S=Math.min(S,Fc(m,nt,st))}}return(B?1:-1)*Math.sqrt(S)}(this.p,u),this.max=this.d+this.h*Math.SQRT2}var ds;A.ap=void 0,(ds=A.ap||(A.ap={}))[ds.center=1]="center",ds[ds.left=2]="left",ds[ds.right=3]="right",ds[ds.top=4]="top",ds[ds.bottom=5]="bottom",ds[ds["top-left"]=6]="top-left",ds[ds["top-right"]=7]="top-right",ds[ds["bottom-left"]=8]="bottom-left",ds[ds["bottom-right"]=9]="bottom-right";let ql=7,Um=Number.POSITIVE_INFINITY;function j1(a,e){return e[1]!==Um?function(l,u,m){let w=0,B=0;switch(u=Math.abs(u),m=Math.abs(m),l){case"top-right":case"top-left":case"top":B=m-ql;break;case"bottom-right":case"bottom-left":case"bottom":B=-m+ql}switch(l){case"top-right":case"bottom-right":case"right":w=-u;break;case"top-left":case"bottom-left":case"left":w=u}return[w,B]}(a,e[0],e[1]):function(l,u){let m=0,w=0;u<0&&(u=0);let B=u/Math.SQRT2;switch(l){case"top-right":case"top-left":w=B-ql;break;case"bottom-right":case"bottom-left":w=-B+ql;break;case"bottom":w=-u+ql;break;case"top":w=u-ql}switch(l){case"top-right":case"bottom-right":m=-B;break;case"top-left":case"bottom-left":m=B;break;case"left":m=u;break;case"right":m=-u}return[m,w]}(a,e[0])}function q1(a,e,l){var u;let m=a.layout,w=(u=m.get("text-variable-anchor-offset"))===null||u===void 0?void 0:u.evaluate(e,{},l);if(w){let S=w.values,Q=[];for(let M=0;Met*Fn);D.startsWith("top")?z[1]-=ql:D.startsWith("bottom")&&(z[1]+=ql),Q[M+1]=z}return new an(Q)}let B=m.get("text-variable-anchor");if(B){let S;S=a._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[m.get("text-radial-offset").evaluate(e,{},l)*Fn,Um]:m.get("text-offset").evaluate(e,{},l).map(M=>M*Fn);let Q=[];for(let M of B)Q.push(M,j1(M,S));return new an(Q)}return null}function Gm(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function i3(a,e,l,u,m,w,B,S,Q,M,D){let z=w.textMaxSize.evaluate(e,{});z===void 0&&(z=B);let et=a.layers[0].layout,nt=et.get("icon-offset").evaluate(e,{},D),st=tb(l.horizontal),mt=B/24,St=a.tilePixelRatio*mt,Vt=a.tilePixelRatio*z/24,oe=a.tilePixelRatio*S,Wt=a.tilePixelRatio*et.get("symbol-spacing"),$t=et.get("text-padding")*a.tilePixelRatio,ve=function(Ze,Gi,Bi,hr=1){let jr=Ze.get("icon-padding").evaluate(Gi,{},Bi),nn=jr&&jr.values;return[nn[0]*hr,nn[1]*hr,nn[2]*hr,nn[3]*hr]}(et,e,D,a.tilePixelRatio),Le=et.get("text-max-angle")/180*Math.PI,ni=et.get("text-rotation-alignment")!=="viewport"&&et.get("symbol-placement")!=="point",bi=et.get("icon-rotation-alignment")==="map"&&et.get("symbol-placement")!=="point",ri=et.get("symbol-placement"),ti=Wt/2,Oe=et.get("icon-text-fit"),fi;u&&Oe!=="none"&&(a.allowVerticalPlacement&&l.vertical&&(fi=w1(u,l.vertical,Oe,et.get("icon-text-fit-padding"),nt,mt)),st&&(u=w1(u,st,Oe,et.get("icon-text-fit-padding"),nt,mt)));let qe=(Ze,Gi)=>{Gi.x<0||Gi.x>=$i||Gi.y<0||Gi.y>=$i||function(Bi,hr,jr,nn,kn,Po,Ds,wn,os,ps,Ks,Ws,Ln,En,Fs,Os,ks,go,po,Tn,mr,Ls,fs,Qn,ba){let Ja=Bi.addToLineVertexArray(hr,jr),Xa,fl,va,aa,fo=0,ml=0,Hh=0,nb=0,Dm=-1,Km=-1,Cl={},sb=pi("");if(Bi.allowVerticalPlacement&&nn.vertical){let Es=wn.layout.get("text-rotate").evaluate(mr,{},Qn)+90;va=new cd(os,hr,ps,Ks,Ws,nn.vertical,Ln,En,Fs,Es),Ds&&(aa=new cd(os,hr,ps,Ks,Ws,Ds,ks,go,Fs,Es))}if(kn){let Es=wn.layout.get("icon-rotate").evaluate(mr,{}),Aa=wn.layout.get("icon-text-fit")!=="none",Tc=X1(kn,Es,fs,Aa),ja=Ds?X1(Ds,Es,fs,Aa):void 0;fl=new cd(os,hr,ps,Ks,Ws,kn,ks,go,!1,Es),fo=4*Tc.length;let Qc=Bi.iconSizeData,VA=null;Qc.kind==="source"?(VA=[NA*wn.layout.get("icon-size").evaluate(mr,{})],VA[0]>Xl&&At(`${Bi.layerIds[0]}: Value for "icon-size" is >= ${Qh}. Reduce your "icon-size".`)):Qc.kind==="composite"&&(VA=[NA*Ls.compositeIconSizes[0].evaluate(mr,{},Qn),NA*Ls.compositeIconSizes[1].evaluate(mr,{},Qn)],(VA[0]>Xl||VA[1]>Xl)&&At(`${Bi.layerIds[0]}: Value for "icon-size" is >= ${Qh}. Reduce your "icon-size".`)),Bi.addSymbols(Bi.icon,Tc,VA,Tn,po,mr,A.ah.none,hr,Ja.lineStartIndex,Ja.lineLength,-1,Qn),Dm=Bi.icon.placedSymbolArray.length-1,ja&&(ml=4*ja.length,Bi.addSymbols(Bi.icon,ja,VA,Tn,po,mr,A.ah.vertical,hr,Ja.lineStartIndex,Ja.lineLength,-1,Qn),Km=Bi.icon.placedSymbolArray.length-1)}let ob=Object.keys(nn.horizontal);for(let Es of ob){let Aa=nn.horizontal[Es];if(!Xa){sb=pi(Aa.text);let ja=wn.layout.get("text-rotate").evaluate(mr,{},Qn);Xa=new cd(os,hr,ps,Ks,Ws,Aa,Ln,En,Fs,ja)}let Tc=Aa.positionedLines.length===1;if(Hh+=$1(Bi,hr,Aa,Po,wn,Fs,mr,Os,Ja,nn.vertical?A.ah.horizontal:A.ah.horizontalOnly,Tc?ob:[Es],Cl,Dm,Ls,Qn),Tc)break}nn.vertical&&(nb+=$1(Bi,hr,nn.vertical,Po,wn,Fs,mr,Os,Ja,A.ah.vertical,["vertical"],Cl,Km,Ls,Qn));let s3=Xa?Xa.boxStartIndex:Bi.collisionBoxArray.length,o3=Xa?Xa.boxEndIndex:Bi.collisionBoxArray.length,a3=va?va.boxStartIndex:Bi.collisionBoxArray.length,A3=va?va.boxEndIndex:Bi.collisionBoxArray.length,l3=fl?fl.boxStartIndex:Bi.collisionBoxArray.length,c3=fl?fl.boxEndIndex:Bi.collisionBoxArray.length,u3=aa?aa.boxStartIndex:Bi.collisionBoxArray.length,h3=aa?aa.boxEndIndex:Bi.collisionBoxArray.length,Ya=-1,hd=(Es,Aa)=>Es&&Es.circleDiameter?Math.max(Es.circleDiameter,Aa):Aa;Ya=hd(Xa,Ya),Ya=hd(va,Ya),Ya=hd(fl,Ya),Ya=hd(aa,Ya);let ab=Ya>-1?1:0;ab&&(Ya*=ba/Fn),Bi.glyphOffsetArray.length>=bu.MAX_GLYPHS&&At("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),mr.sortKey!==void 0&&Bi.addToSortKeyRanges(Bi.symbolInstances.length,mr.sortKey);let g3=q1(wn,mr,Qn),[d3,p3]=function(Es,Aa){let Tc=Es.length,ja=Aa?.values;if(ja?.length>0)for(let Qc=0;Qc=0?Cl.right:-1,Cl.center>=0?Cl.center:-1,Cl.left>=0?Cl.left:-1,Cl.vertical||-1,Dm,Km,sb,s3,o3,a3,A3,l3,c3,u3,h3,ps,Hh,nb,fo,ml,ab,0,Ln,Ya,d3,p3)}(a,Gi,Ze,l,u,m,fi,a.layers[0],a.collisionBoxArray,e.index,e.sourceLayerIndex,a.index,St,[$t,$t,$t,$t],ni,Q,oe,ve,bi,nt,e,w,M,D,B)};if(ri==="line")for(let Ze of D1(e.geometry,0,0,$i,$i)){let Gi=jS(Ze,Wt,Le,l.vertical||st,u,24,Vt,a.overscaling,$i);for(let Bi of Gi)st&&r3(a,st.text,ti,Bi)||qe(Ze,Bi)}else if(ri==="line-center"){for(let Ze of e.geometry)if(Ze.length>1){let Gi=YS(Ze,Le,l.vertical||st,u,24,Vt);Gi&&qe(Ze,Gi)}}else if(e.type==="Polygon")for(let Ze of gm(e.geometry,0)){let Gi=t3(Ze,16);qe(Ze[0],new jl(Gi.x,Gi.y,0))}else if(e.type==="LineString")for(let Ze of e.geometry)qe(Ze,new jl(Ze[0].x,Ze[0].y,0));else if(e.type==="Point")for(let Ze of e.geometry)for(let Gi of Ze)qe([Gi],new jl(Gi.x,Gi.y,0))}function $1(a,e,l,u,m,w,B,S,Q,M,D,z,et,nt,st){let mt=function(oe,Wt,$t,ve,Le,ni,bi,ri){let ti=ve.layout.get("text-rotate").evaluate(ni,{})*Math.PI/180,Oe=[];for(let fi of Wt.positionedLines)for(let qe of fi.positionedGlyphs){if(!qe.rect)continue;let Ze=qe.rect||{},Gi=f1+1,Bi=!0,hr=1,jr=0,nn=(Le||ri)&&qe.vertical,kn=qe.metrics.advance*qe.scale/2;if(ri&&Wt.verticalizable&&(jr=fi.lineOffset/2-(qe.imageName?-(Fn-qe.metrics.width*qe.scale)/2:(qe.scale-1)*Fn)),qe.imageName){let Tn=bi[qe.imageName];Bi=Tn.sdf,hr=Tn.pixelRatio,Gi=ho/hr}let Po=Le?[qe.x+kn,qe.y]:[0,0],Ds=Le?[0,0]:[qe.x+kn+$t[0],qe.y+$t[1]-jr],wn=[0,0];nn&&(wn=Ds,Ds=[0,0]);let os=qe.metrics.isDoubleResolution?2:1,ps=(qe.metrics.left-Gi)*qe.scale-kn+Ds[0],Ks=(-qe.metrics.top-Gi)*qe.scale+Ds[1],Ws=ps+Ze.w/os*qe.scale/hr,Ln=Ks+Ze.h/os*qe.scale/hr,En=new v(ps,Ks),Fs=new v(Ws,Ks),Os=new v(ps,Ln),ks=new v(Ws,Ln);if(nn){let Tn=new v(-kn,kn-Eh),mr=-Math.PI/2,Ls=Fn/2-kn,fs=new v(5-Eh-Ls,-(qe.imageName?Ls:0)),Qn=new v(...wn);En._rotateAround(mr,Tn)._add(fs)._add(Qn),Fs._rotateAround(mr,Tn)._add(fs)._add(Qn),Os._rotateAround(mr,Tn)._add(fs)._add(Qn),ks._rotateAround(mr,Tn)._add(fs)._add(Qn)}if(ti){let Tn=Math.sin(ti),mr=Math.cos(ti),Ls=[mr,-Tn,Tn,mr];En._matMult(Ls),Fs._matMult(Ls),Os._matMult(Ls),ks._matMult(Ls)}let go=new v(0,0),po=new v(0,0);Oe.push({tl:En,tr:Fs,bl:Os,br:ks,tex:Ze,writingMode:Wt.writingMode,glyphOffset:Po,sectionIndex:qe.sectionIndex,isSDF:Bi,pixelOffsetTL:go,pixelOffsetBR:po,minFontScaleX:0,minFontScaleY:0})}return Oe}(0,l,S,m,w,B,u,a.allowVerticalPlacement),St=a.textSizeData,Vt=null;St.kind==="source"?(Vt=[NA*m.layout.get("text-size").evaluate(B,{})],Vt[0]>Xl&&At(`${a.layerIds[0]}: Value for "text-size" is >= ${Qh}. Reduce your "text-size".`)):St.kind==="composite"&&(Vt=[NA*nt.compositeTextSizes[0].evaluate(B,{},st),NA*nt.compositeTextSizes[1].evaluate(B,{},st)],(Vt[0]>Xl||Vt[1]>Xl)&&At(`${a.layerIds[0]}: Value for "text-size" is >= ${Qh}. Reduce your "text-size".`)),a.addSymbols(a.text,mt,Vt,S,w,B,M,e,Q.lineStartIndex,Q.lineLength,et,st);for(let oe of D)z[oe]=a.text.placedSymbolArray.length-1;return 4*mt.length}function tb(a){for(let e in a)return a[e];return null}function r3(a,e,l,u){let m=a.compareText;if(e in m){let w=m[e];for(let B=w.length-1;B>=0;B--)if(u.dist(w[B])>4;if(m!==1)throw new Error(`Got v${m} data when expected v1.`);let w=eb[15&u];if(!w)throw new Error("Unrecognized array type.");let[B]=new Uint16Array(e,2,1),[S]=new Uint32Array(e,4,1);return new Rm(S,B,w,e)}constructor(e,l=64,u=Float64Array,m){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+l,2),65535),this.ArrayType=u,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let w=eb.indexOf(this.ArrayType),B=2*e*this.ArrayType.BYTES_PER_ELEMENT,S=e*this.IndexArrayType.BYTES_PER_ELEMENT,Q=(8-S%8)%8;if(w<0)throw new Error(`Unexpected typed array class: ${u}.`);m&&m instanceof ArrayBuffer?(this.data=m,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+S+Q,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+B+S+Q),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+S+Q,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+w]),new Uint16Array(this.data,2,1)[0]=l,new Uint32Array(this.data,4,1)[0]=e)}add(e,l){let u=this._pos>>1;return this.ids[u]=u,this.coords[this._pos++]=e,this.coords[this._pos++]=l,u}finish(){let e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Hm(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,l,u,m){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:w,coords:B,nodeSize:S}=this,Q=[0,w.length-1,0],M=[];for(;Q.length;){let D=Q.pop()||0,z=Q.pop()||0,et=Q.pop()||0;if(z-et<=S){for(let St=et;St<=z;St++){let Vt=B[2*St],oe=B[2*St+1];Vt>=e&&Vt<=u&&oe>=l&&oe<=m&&M.push(w[St])}continue}let nt=et+z>>1,st=B[2*nt],mt=B[2*nt+1];st>=e&&st<=u&&mt>=l&&mt<=m&&M.push(w[nt]),(D===0?e<=st:l<=mt)&&(Q.push(et),Q.push(nt-1),Q.push(1-D)),(D===0?u>=st:m>=mt)&&(Q.push(nt+1),Q.push(z),Q.push(1-D))}return M}within(e,l,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:m,coords:w,nodeSize:B}=this,S=[0,m.length-1,0],Q=[],M=u*u;for(;S.length;){let D=S.pop()||0,z=S.pop()||0,et=S.pop()||0;if(z-et<=B){for(let St=et;St<=z;St++)rb(w[2*St],w[2*St+1],e,l)<=M&&Q.push(m[St]);continue}let nt=et+z>>1,st=w[2*nt],mt=w[2*nt+1];rb(st,mt,e,l)<=M&&Q.push(m[nt]),(D===0?e-u<=st:l-u<=mt)&&(S.push(et),S.push(nt-1),S.push(1-D)),(D===0?e+u>=st:l+u>=mt)&&(S.push(nt+1),S.push(z),S.push(1-D))}return Q}}function Hm(a,e,l,u,m,w){if(m-u<=l)return;let B=u+m>>1;ib(a,e,B,u,m,w),Hm(a,e,l,u,B-1,1-w),Hm(a,e,l,B+1,m,1-w)}function ib(a,e,l,u,m,w){for(;m>u;){if(m-u>600){let M=m-u+1,D=l-u+1,z=Math.log(M),et=.5*Math.exp(2*z/3),nt=.5*Math.sqrt(z*et*(M-et)/M)*(D-M/2<0?-1:1);ib(a,e,l,Math.max(u,Math.floor(l-D*et/M+nt)),Math.min(m,Math.floor(l+(M-D)*et/M+nt)),w)}let B=e[2*l+w],S=u,Q=m;for(Gh(a,e,u,l),e[2*m+w]>B&&Gh(a,e,u,m);SB;)Q--}e[2*u+w]===B?Gh(a,e,u,Q):(Q++,Gh(a,e,Q,m)),Q<=l&&(u=Q+1),l<=Q&&(m=Q-1)}}function Gh(a,e,l,u){Zm(a,l,u),Zm(e,2*l,2*u),Zm(e,2*l+1,2*u+1)}function Zm(a,e,l){let u=a[e];a[e]=a[l],a[l]=u}function rb(a,e,l,u){let m=a-l,w=e-u;return m*m+w*w}var Pm;A.bd=void 0,(Pm=A.bd||(A.bd={})).create="create",Pm.load="load",Pm.fullLoad="fullLoad";let ud=null,Rh=[],Mm=1e3/60,Nm="loadTime",Vm="fullLoadTime",n3={mark(a){performance.mark(a)},frame(a){let e=a;ud!=null&&Rh.push(e-ud),ud=e},clearMetrics(){ud=null,Rh=[],performance.clearMeasures(Nm),performance.clearMeasures(Vm);for(let a in A.bd)performance.clearMarks(A.bd[a])},getPerformanceMetrics(){performance.measure(Nm,A.bd.create,A.bd.load),performance.measure(Vm,A.bd.create,A.bd.fullLoad);let a=performance.getEntriesByName(Nm)[0].duration,e=performance.getEntriesByName(Vm)[0].duration,l=Rh.length,u=1/(Rh.reduce((w,B)=>w+B,0)/l/1e3),m=Rh.filter(w=>w>Mm).reduce((w,B)=>w+(B-Mm)/Mm,0);return{loadTime:a,fullLoadTime:e,fps:u,percentDroppedFrames:m/(l+m)*100,totalFrames:l}}};A.$=Ct,A.A=Vl,A.B=function(a){if(le==null){let e=a.navigator?a.navigator.userAgent:null;le=!!a.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return le},A.C=class{constructor(a,e){this.target=a,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new JS(()=>this.process()),this.subscription=function(l,u,m,w){return l.addEventListener(u,m,!1),{unsubscribe:()=>{l.removeEventListener(u,m,!1)}}}(this.target,"message",l=>this.receive(l)),this.globalScope=_t(self)?a:window}registerMessageHandler(a,e){this.messageHandlers[a]=e}sendAsync(a,e){return new Promise((l,u)=>{let m=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[m]={resolve:l,reject:u},e&&e.signal.addEventListener("abort",()=>{delete this.resolveRejects[m];let S={id:m,type:"",origin:location.origin,targetMapId:a.targetMapId,sourceMapId:this.mapId};this.target.postMessage(S)},{once:!0});let w=[],B=Object.assign(Object.assign({},a),{id:m,sourceMapId:this.mapId,origin:location.origin,data:Ca(a.data,w)});this.target.postMessage(B,{transfer:w})})}receive(a){let e=a.data,l=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type===""){delete this.tasks[l];let u=this.abortControllers[l];return delete this.abortControllers[l],void(u&&u.abort())}if(_t(self)||e.mustQueue)return this.tasks[l]=e,this.taskQueue.push(l),void this.invoker.trigger();this.processTask(l,e)}}process(){if(this.taskQueue.length===0)return;let a=this.taskQueue.shift(),e=this.tasks[a];delete this.tasks[a],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(a,e)}processTask(a,e){return o(this,void 0,void 0,function*(){if(e.type===""){let m=this.resolveRejects[a];return delete this.resolveRejects[a],m?void(e.error?m.reject(Za(e.error)):m.resolve(Za(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(a,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));let l=Za(e.data),u=new AbortController;this.abortControllers[a]=u;try{let m=yield this.messageHandlers[e.type](e.sourceMapId,l,u);this.completeTask(a,null,m)}catch(m){this.completeTask(a,m)}})}completeTask(a,e,l){let u=[];delete this.abortControllers[a];let m={id:a,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Ca(e):null,data:Ca(l,u)};this.target.postMessage(m,{transfer:u})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},A.D=wi,A.E=gi,A.F=function(){var a=new Vl(16);return Vl!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},A.G=Ht,A.H=function(a,e,l){var u,m,w,B,S,Q,M,D,z,et,nt,st,mt=l[0],St=l[1],Vt=l[2];return e===a?(a[12]=e[0]*mt+e[4]*St+e[8]*Vt+e[12],a[13]=e[1]*mt+e[5]*St+e[9]*Vt+e[13],a[14]=e[2]*mt+e[6]*St+e[10]*Vt+e[14],a[15]=e[3]*mt+e[7]*St+e[11]*Vt+e[15]):(m=e[1],w=e[2],B=e[3],S=e[4],Q=e[5],M=e[6],D=e[7],z=e[8],et=e[9],nt=e[10],st=e[11],a[0]=u=e[0],a[1]=m,a[2]=w,a[3]=B,a[4]=S,a[5]=Q,a[6]=M,a[7]=D,a[8]=z,a[9]=et,a[10]=nt,a[11]=st,a[12]=u*mt+S*St+z*Vt+e[12],a[13]=m*mt+Q*St+et*Vt+e[13],a[14]=w*mt+M*St+nt*Vt+e[14],a[15]=B*mt+D*St+st*Vt+e[15]),a},A.I=wm,A.J=function(a,e,l){var u=l[0],m=l[1],w=l[2];return a[0]=e[0]*u,a[1]=e[1]*u,a[2]=e[2]*u,a[3]=e[3]*u,a[4]=e[4]*m,a[5]=e[5]*m,a[6]=e[6]*m,a[7]=e[7]*m,a[8]=e[8]*w,a[9]=e[9]*w,a[10]=e[10]*w,a[11]=e[11]*w,a[12]=e[12],a[13]=e[13],a[14]=e[14],a[15]=e[15],a},A.K=Ch,A.L=function(a,e){let l={};for(let u=0;u{let e=window.document.createElement("video");return e.muted=!0,new Promise(l=>{e.onloadstart=()=>{l(e)};for(let u of a){let m=window.document.createElement("source");de(u)||(e.crossOrigin="Anonymous"),m.src=u,e.appendChild(m)}})},A.a3=function(){return Qt++},A.a4=Au,A.a5=bu,A.a6=ga,A.a7=sa,A.a8=Hr,A.a9=P1,A.aA=Jt,A.aB=function(a,e){if(!a)return[{command:"setStyle",args:[e]}];let l=[];try{if(!Ue(a.version,e.version))return[{command:"setStyle",args:[e]}];Ue(a.center,e.center)||l.push({command:"setCenter",args:[e.center]}),Ue(a.zoom,e.zoom)||l.push({command:"setZoom",args:[e.zoom]}),Ue(a.bearing,e.bearing)||l.push({command:"setBearing",args:[e.bearing]}),Ue(a.pitch,e.pitch)||l.push({command:"setPitch",args:[e.pitch]}),Ue(a.sprite,e.sprite)||l.push({command:"setSprite",args:[e.sprite]}),Ue(a.glyphs,e.glyphs)||l.push({command:"setGlyphs",args:[e.glyphs]}),Ue(a.transition,e.transition)||l.push({command:"setTransition",args:[e.transition]}),Ue(a.light,e.light)||l.push({command:"setLight",args:[e.light]}),Ue(a.terrain,e.terrain)||l.push({command:"setTerrain",args:[e.terrain]}),Ue(a.sky,e.sky)||l.push({command:"setSky",args:[e.sky]});let u={},m=[];(function(B,S,Q,M){let D;for(D in S=S||{},B=B||{})Object.prototype.hasOwnProperty.call(B,D)&&(Object.prototype.hasOwnProperty.call(S,D)||Je(D,Q,M));for(D in S)Object.prototype.hasOwnProperty.call(S,D)&&(Object.prototype.hasOwnProperty.call(B,D)?Ue(B[D],S[D])||(B[D].type==="geojson"&&S[D].type==="geojson"&&ui(B,S,D)?Ee(Q,{command:"setGeoJSONSourceData",args:[D,S[D].data]}):ze(D,S,Q,M)):Ne(D,S,Q))})(a.sources,e.sources,m,u);let w=[];a.layers&&a.layers.forEach(B=>{"source"in B&&u[B.source]?l.push({command:"removeLayer",args:[B.id]}):w.push(B)}),l=l.concat(m),function(B,S,Q){S=S||[];let M=(B=B||[]).map(Ei),D=S.map(Ei),z=B.reduce(Pi,{}),et=S.reduce(Pi,{}),nt=M.slice(),st=Object.create(null),mt,St,Vt,oe,Wt;for(let $t=0,ve=0;$t@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(l,u,m,w)=>{let B=m||w;return e[u]=!B||B.toLowerCase(),""}),e["max-age"]){let l=parseInt(e["max-age"],10);isNaN(l)?delete e["max-age"]:e["max-age"]=l}return e},A.ab=function(a,e){let l=[];for(let u in a)u in e||l.push(u);return l},A.ac=at,A.ad=function(a,e,l){var u=Math.sin(l),m=Math.cos(l),w=e[0],B=e[1],S=e[2],Q=e[3],M=e[4],D=e[5],z=e[6],et=e[7];return e!==a&&(a[8]=e[8],a[9]=e[9],a[10]=e[10],a[11]=e[11],a[12]=e[12],a[13]=e[13],a[14]=e[14],a[15]=e[15]),a[0]=w*m+M*u,a[1]=B*m+D*u,a[2]=S*m+z*u,a[3]=Q*m+et*u,a[4]=M*m-w*u,a[5]=D*m-B*u,a[6]=z*m-S*u,a[7]=et*m-Q*u,a},A.ae=function(a){var e=new Vl(16);return e[0]=a[0],e[1]=a[1],e[2]=a[2],e[3]=a[3],e[4]=a[4],e[5]=a[5],e[6]=a[6],e[7]=a[7],e[8]=a[8],e[9]=a[9],e[10]=a[10],e[11]=a[11],e[12]=a[12],e[13]=a[13],e[14]=a[14],e[15]=a[15],e},A.af=kc,A.ag=function(a,e){let l=0,u=0;if(a.kind==="constant")u=a.layoutSize;else if(a.kind!=="source"){let{interpolationType:m,minZoom:w,maxZoom:B}=a,S=m?at(cn.interpolationFactor(m,e,w,B),0,1):0;a.kind==="camera"?u=qn.number(a.minSize,a.maxSize,S):l=S}return{uSizeT:l,uSize:u}},A.ai=function(a,{uSize:e,uSizeT:l},{lowerSize:u,upperSize:m}){return a.kind==="source"?u/NA:a.kind==="composite"?qn.number(u/NA,m/NA,l):e},A.aj=Sm,A.ak=function(a,e,l,u){let m=e.y-a.y,w=e.x-a.x,B=u.y-l.y,S=u.x-l.x,Q=B*w-S*m;if(Q===0)return null;let M=(S*(a.y-l.y)-B*(a.x-l.x))/Q;return new v(a.x+M*w,a.y+M*m)},A.al=D1,A.am=Ro,A.an=mh,A.ao=Fn,A.aq=xm,A.ar=function(a,e){var l=e[0],u=e[1],m=e[2],w=e[3],B=e[4],S=e[5],Q=e[6],M=e[7],D=e[8],z=e[9],et=e[10],nt=e[11],st=e[12],mt=e[13],St=e[14],Vt=e[15],oe=l*S-u*B,Wt=l*Q-m*B,$t=l*M-w*B,ve=u*Q-m*S,Le=u*M-w*S,ni=m*M-w*Q,bi=D*mt-z*st,ri=D*St-et*st,ti=D*Vt-nt*st,Oe=z*St-et*mt,fi=z*Vt-nt*mt,qe=et*Vt-nt*St,Ze=oe*qe-Wt*fi+$t*Oe+ve*ti-Le*ri+ni*bi;return Ze?(a[0]=(S*qe-Q*fi+M*Oe)*(Ze=1/Ze),a[1]=(m*fi-u*qe-w*Oe)*Ze,a[2]=(mt*ni-St*Le+Vt*ve)*Ze,a[3]=(et*Le-z*ni-nt*ve)*Ze,a[4]=(Q*ti-B*qe-M*ri)*Ze,a[5]=(l*qe-m*ti+w*ri)*Ze,a[6]=(St*$t-st*ni-Vt*Wt)*Ze,a[7]=(D*ni-et*$t+nt*Wt)*Ze,a[8]=(B*fi-S*ti+M*bi)*Ze,a[9]=(u*ti-l*fi-w*bi)*Ze,a[10]=(st*Le-mt*$t+Vt*oe)*Ze,a[11]=(z*$t-D*Le-nt*oe)*Ze,a[12]=(S*ri-B*Oe-Q*bi)*Ze,a[13]=(l*Oe-u*ri+m*bi)*Ze,a[14]=(mt*Wt-st*ve-St*oe)*Ze,a[15]=(D*ve-z*Wt+et*oe)*Ze,a):null},A.as=Gm,A.at=_m,A.au=Rm,A.av=function(){let a={},e=xt.$version;for(let l in xt.$root){let u=xt.$root[l];if(u.required){let m=null;m=l==="version"?e:u.type==="array"?[]:{},m!=null&&(a[l]=m)}}return a},A.aw=Ul,A.ax=Ae,A.ay=function(a){a=a.slice();let e=Object.create(null);for(let l=0;lZe*Fn)}let ri=B?"center":l.get("text-justify").evaluate(M,{},a.canonical),ti=l.get("symbol-placement"),Oe=ti==="point"?l.get("text-max-width").evaluate(M,{},a.canonical)*Fn:0,fi=()=>{a.bucket.allowVerticalPlacement&&Pa($t)&&(st.vertical=id(mt,a.glyphMap,a.glyphPositions,a.imagePositions,D,Oe,w,ni,"left",Le,Vt,A.ah.vertical,!0,ti,et,z))};if(!B&&bi){let qe=new Set;if(ri==="auto")for(let Gi=0;Gio(void 0,void 0,void 0,function*(){if(a.byteLength===0)return createImageBitmap(new ImageData(1,1));let e=new Blob([new Uint8Array(a)],{type:"image/png"});try{return createImageBitmap(e)}catch(l){throw new Error(`Could not load image because of ${l.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),A.e=Tt,A.f=a=>new Promise((e,l)=>{let u=new Image;u.onload=()=>{e(u),URL.revokeObjectURL(u.src),u.onload=null,window.requestAnimationFrame(()=>{u.src=ne})},u.onerror=()=>l(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."));let m=new Blob([new Uint8Array(a)],{type:"image/png"});u.src=a.byteLength?URL.createObjectURL(m):ne}),A.g=It,A.h=(a,e)=>he(Tt(a,{type:"json"}),e),A.i=_t,A.j=Me,A.k=je,A.l=(a,e)=>he(Tt(a,{type:"arrayBuffer"}),e),A.m=he,A.n=function(a){return new bm(a).readFields(QS,[])},A.o=Zo,A.p=m1,A.q=Jn,A.r=en,A.s=de,A.t=ea,A.u=ei,A.v=xt,A.w=At,A.x=kr,A.y=function([a,e,l]){return e+=90,e*=Math.PI/180,l*=Math.PI/180,{x:a*Math.cos(e)*Math.sin(l),y:a*Math.sin(e)*Math.sin(l),z:a*Math.cos(l)}},A.z=qn}),i("worker",["./shared"],function(A){"use strict";class o{constructor(Y){this.keyCache={},Y&&this.replace(Y)}replace(Y){this._layerConfigs={},this._layers={},this.update(Y,[])}update(Y,q){for(let ht of Y){this._layerConfigs[ht.id]=ht;let Zt=this._layers[ht.id]=A.az(ht);Zt._featureFilter=A.a6(Zt.filter),this.keyCache[ht.id]&&delete this.keyCache[ht.id]}for(let ht of q)delete this.keyCache[ht],delete this._layerConfigs[ht],delete this._layers[ht];this.familiesBySource={};let rt=A.bh(Object.values(this._layerConfigs),this.keyCache);for(let ht of rt){let Zt=ht.map(pe=>this._layers[pe.id]),zt=Zt[0];if(zt.visibility==="none")continue;let Xt=zt.source||"",Mt=this.familiesBySource[Xt];Mt||(Mt=this.familiesBySource[Xt]={});let re=zt.sourceLayer||"_geojsonTileLayer",ce=Mt[re];ce||(ce=Mt[re]=[]),ce.push(Zt)}}}class g{constructor(Y){let q={},rt=[];for(let Xt in Y){let Mt=Y[Xt],re=q[Xt]={};for(let ce in Mt){let pe=Mt[+ce];if(!pe||pe.bitmap.width===0||pe.bitmap.height===0)continue;let me={x:0,y:0,w:pe.bitmap.width+2,h:pe.bitmap.height+2};rt.push(me),re[ce]={rect:me,metrics:pe.metrics}}}let{w:ht,h:Zt}=A.p(rt),zt=new A.o({width:ht||1,height:Zt||1});for(let Xt in Y){let Mt=Y[Xt];for(let re in Mt){let ce=Mt[+re];if(!ce||ce.bitmap.width===0||ce.bitmap.height===0)continue;let pe=q[Xt][re].rect;A.o.copy(ce.bitmap,zt,{x:0,y:0},{x:pe.x+1,y:pe.y+1},ce.bitmap)}}this.image=zt,this.positions=q}}A.bi("GlyphAtlas",g);class d{constructor(Y){this.tileID=new A.Q(Y.tileID.overscaledZ,Y.tileID.wrap,Y.tileID.canonical.z,Y.tileID.canonical.x,Y.tileID.canonical.y),this.uid=Y.uid,this.zoom=Y.zoom,this.pixelRatio=Y.pixelRatio,this.tileSize=Y.tileSize,this.source=Y.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Y.showCollisionBoxes,this.collectResourceTiming=!!Y.collectResourceTiming,this.returnDependencies=!!Y.returnDependencies,this.promoteId=Y.promoteId,this.inFlightDependencies=[]}parse(Y,q,rt,ht){return A._(this,void 0,void 0,function*(){this.status="parsing",this.data=Y,this.collisionBoxArray=new A.a4;let Zt=new A.bj(Object.keys(Y.layers).sort()),zt=new A.bk(this.tileID,this.promoteId);zt.bucketLayerIDs=[];let Xt={},Mt={featureIndex:zt,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:rt},re=q.familiesBySource[this.source];for(let ki in re){let fr=Y.layers[ki];if(!fr)continue;fr.version===1&&A.w(`Vector tile source "${this.source}" layer "${ki}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let br=Zt.encode(ki),Tr=[];for(let Dt=0;Dt=Ke.maxzoom||Ke.visibility!=="none"&&(C(Dt,this.zoom,rt),(Xt[Ke.id]=Ke.createBucket({index:zt.bucketLayerIDs.length,layers:Dt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:br,sourceID:this.source})).populate(Tr,Mt,this.tileID.canonical),zt.bucketLayerIDs.push(Dt.map(Te=>Te.id)))}}let ce=A.aE(Mt.glyphDependencies,ki=>Object.keys(ki).map(Number));this.inFlightDependencies.forEach(ki=>ki?.abort()),this.inFlightDependencies=[];let pe=Promise.resolve({});if(Object.keys(ce).length){let ki=new AbortController;this.inFlightDependencies.push(ki),pe=ht.sendAsync({type:"getGlyphs",data:{stacks:ce,source:this.source,tileID:this.tileID,type:"glyphs"}},ki)}let me=Object.keys(Mt.iconDependencies),Xe=Promise.resolve({});if(me.length){let ki=new AbortController;this.inFlightDependencies.push(ki),Xe=ht.sendAsync({type:"getImages",data:{icons:me,source:this.source,tileID:this.tileID,type:"icons"}},ki)}let oi=Object.keys(Mt.patternDependencies),ii=Promise.resolve({});if(oi.length){let ki=new AbortController;this.inFlightDependencies.push(ki),ii=ht.sendAsync({type:"getImages",data:{icons:oi,source:this.source,tileID:this.tileID,type:"patterns"}},ki)}let[Ni,Qi,rr]=yield Promise.all([pe,Xe,ii]),zi=new g(Ni),Cr=new A.bl(Qi,rr);for(let ki in Xt){let fr=Xt[ki];fr instanceof A.a5?(C(fr.layers,this.zoom,rt),A.bm({bucket:fr,glyphMap:Ni,glyphPositions:zi.positions,imageMap:Qi,imagePositions:Cr.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):fr.hasPattern&&(fr instanceof A.bn||fr instanceof A.bo||fr instanceof A.bp)&&(C(fr.layers,this.zoom,rt),fr.addFeatures(Mt,this.tileID.canonical,Cr.patternPositions))}return this.status="done",{buckets:Object.values(Xt).filter(ki=>!ki.isEmpty()),featureIndex:zt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:zi.image,imageAtlas:Cr,glyphMap:this.returnDependencies?Ni:null,iconMap:this.returnDependencies?Qi:null,glyphPositions:this.returnDependencies?zi.positions:null}})}}function C(ft,Y,q){let rt=new A.a8(Y);for(let ht of ft)ht.recalculate(rt,q)}class v{constructor(Y,q,rt){this.actor=Y,this.layerIndex=q,this.availableImages=rt,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(Y,q){return A._(this,void 0,void 0,function*(){let rt=yield A.l(Y.request,q);try{return{vectorTile:new A.bq.VectorTile(new A.br(rt.data)),rawData:rt.data,cacheControl:rt.cacheControl,expires:rt.expires}}catch(ht){let Zt=new Uint8Array(rt.data),zt=`Unable to parse the tile at ${Y.request.url}, `;throw zt+=Zt[0]===31&&Zt[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${ht.messge}`,new Error(zt)}})}loadTile(Y){return A._(this,void 0,void 0,function*(){let q=Y.uid,rt=!!(Y&&Y.request&&Y.request.collectResourceTiming)&&new A.bs(Y.request),ht=new d(Y);this.loading[q]=ht;let Zt=new AbortController;ht.abort=Zt;try{let zt=yield this.loadVectorTile(Y,Zt);if(delete this.loading[q],!zt)return null;let Xt=zt.rawData,Mt={};zt.expires&&(Mt.expires=zt.expires),zt.cacheControl&&(Mt.cacheControl=zt.cacheControl);let re={};if(rt){let pe=rt.finish();pe&&(re.resourceTiming=JSON.parse(JSON.stringify(pe)))}ht.vectorTile=zt.vectorTile;let ce=ht.parse(zt.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[q]=ht,this.fetching[q]={rawTileData:Xt,cacheControl:Mt,resourceTiming:re};try{let pe=yield ce;return A.e({rawTileData:Xt.slice(0)},pe,Mt,re)}finally{delete this.fetching[q]}}catch(zt){throw delete this.loading[q],ht.status="done",this.loaded[q]=ht,zt}})}reloadTile(Y){return A._(this,void 0,void 0,function*(){let q=Y.uid;if(!this.loaded||!this.loaded[q])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");let rt=this.loaded[q];if(rt.showCollisionBoxes=Y.showCollisionBoxes,rt.status==="parsing"){let ht=yield rt.parse(rt.vectorTile,this.layerIndex,this.availableImages,this.actor),Zt;if(this.fetching[q]){let{rawTileData:zt,cacheControl:Xt,resourceTiming:Mt}=this.fetching[q];delete this.fetching[q],Zt=A.e({rawTileData:zt.slice(0)},ht,Xt,Mt)}else Zt=ht;return Zt}if(rt.status==="done"&&rt.vectorTile)return rt.parse(rt.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(Y){return A._(this,void 0,void 0,function*(){let q=this.loading,rt=Y.uid;q&&q[rt]&&q[rt].abort&&(q[rt].abort.abort(),delete q[rt])})}removeTile(Y){return A._(this,void 0,void 0,function*(){this.loaded&&this.loaded[Y.uid]&&delete this.loaded[Y.uid]})}}class x{constructor(){this.loaded={}}loadTile(Y){return A._(this,void 0,void 0,function*(){let{uid:q,encoding:rt,rawImageData:ht,redFactor:Zt,greenFactor:zt,blueFactor:Xt,baseShift:Mt}=Y,re=ht.width+2,ce=ht.height+2,pe=A.b(ht)?new A.R({width:re,height:ce},yield A.bt(ht,-1,-1,re,ce)):ht,me=new A.bu(q,pe,rt,Zt,zt,Xt,Mt);return this.loaded=this.loaded||{},this.loaded[q]=me,me})}removeTile(Y){let q=this.loaded,rt=Y.uid;q&&q[rt]&&delete q[rt]}}function T(ft,Y){if(ft.length!==0){G(ft[0],Y);for(var q=1;q=Math.abs(Xt)?q-Mt+Xt:Xt-Mt+q,q=Mt}q+rt>=0!=!!Y&&ft.reverse()}var k=A.bv(function ft(Y,q){var rt,ht=Y&&Y.type;if(ht==="FeatureCollection")for(rt=0;rt>31}function kt(ft,Y){for(var q=ft.loadGeometry(),rt=ft.type,ht=0,Zt=0,zt=q.length,Xt=0;Xtft},ne=Math.fround||(te=new Float32Array(1),ft=>(te[0]=+ft,te[0]));var te;let wt=3,Ut=5,fe=6;class j{constructor(Y){this.options=Object.assign(Object.create(ie),Y),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Y){let{log:q,minZoom:rt,maxZoom:ht}=this.options;q&&console.time("total time");let Zt=`prepare ${Y.length} points`;q&&console.time(Zt),this.points=Y;let zt=[];for(let Mt=0;Mt=rt;Mt--){let re=+Date.now();Xt=this.trees[Mt]=this._createTree(this._cluster(Xt,Mt)),q&&console.log("z%d: %d clusters in %dms",Mt,Xt.numItems,+Date.now()-re)}return q&&console.timeEnd("total time"),this}getClusters(Y,q){let rt=((Y[0]+180)%360+360)%360-180,ht=Math.max(-90,Math.min(90,Y[1])),Zt=Y[2]===180?180:((Y[2]+180)%360+360)%360-180,zt=Math.max(-90,Math.min(90,Y[3]));if(Y[2]-Y[0]>=360)rt=-180,Zt=180;else if(rt>Zt){let pe=this.getClusters([rt,ht,180,zt],q),me=this.getClusters([-180,ht,Zt,zt],q);return pe.concat(me)}let Xt=this.trees[this._limitZoom(q)],Mt=Xt.range(Ht(rt),Ot(zt),Ht(Zt),Ot(ht)),re=Xt.data,ce=[];for(let pe of Mt){let me=this.stride*pe;ce.push(re[me+Ut]>1?bt(re,me,this.clusterProps):this.points[re[me+wt]])}return ce}getChildren(Y){let q=this._getOriginId(Y),rt=this._getOriginZoom(Y),ht="No cluster with the specified id.",Zt=this.trees[rt];if(!Zt)throw new Error(ht);let zt=Zt.data;if(q*this.stride>=zt.length)throw new Error(ht);let Xt=this.options.radius/(this.options.extent*Math.pow(2,rt-1)),Mt=Zt.within(zt[q*this.stride],zt[q*this.stride+1],Xt),re=[];for(let ce of Mt){let pe=ce*this.stride;zt[pe+4]===Y&&re.push(zt[pe+Ut]>1?bt(zt,pe,this.clusterProps):this.points[zt[pe+wt]])}if(re.length===0)throw new Error(ht);return re}getLeaves(Y,q,rt){let ht=[];return this._appendLeaves(ht,Y,q=q||10,rt=rt||0,0),ht}getTile(Y,q,rt){let ht=this.trees[this._limitZoom(Y)],Zt=Math.pow(2,Y),{extent:zt,radius:Xt}=this.options,Mt=Xt/zt,re=(rt-Mt)/Zt,ce=(rt+1+Mt)/Zt,pe={features:[]};return this._addTileFeatures(ht.range((q-Mt)/Zt,re,(q+1+Mt)/Zt,ce),ht.data,q,rt,Zt,pe),q===0&&this._addTileFeatures(ht.range(1-Mt/Zt,re,1,ce),ht.data,Zt,rt,Zt,pe),q===Zt-1&&this._addTileFeatures(ht.range(0,re,Mt/Zt,ce),ht.data,-1,rt,Zt,pe),pe.features.length?pe:null}getClusterExpansionZoom(Y){let q=this._getOriginZoom(Y)-1;for(;q<=this.options.maxZoom;){let rt=this.getChildren(Y);if(q++,rt.length!==1)break;Y=rt[0].properties.cluster_id}return q}_appendLeaves(Y,q,rt,ht,Zt){let zt=this.getChildren(q);for(let Xt of zt){let Mt=Xt.properties;if(Mt&&Mt.cluster?Zt+Mt.point_count<=ht?Zt+=Mt.point_count:Zt=this._appendLeaves(Y,Mt.cluster_id,rt,ht,Zt):Zt1,ce,pe,me;if(re)ce=It(q,Mt,this.clusterProps),pe=q[Mt],me=q[Mt+1];else{let ii=this.points[q[Mt+wt]];ce=ii.properties;let[Ni,Qi]=ii.geometry.coordinates;pe=Ht(Ni),me=Ot(Qi)}let Xe={type:1,geometry:[[Math.round(this.options.extent*(pe*Zt-rt)),Math.round(this.options.extent*(me*Zt-ht))]],tags:ce},oi;oi=re||this.options.generateId?q[Mt+wt]:this.points[q[Mt+wt]].id,oi!==void 0&&(Xe.id=oi),zt.features.push(Xe)}}_limitZoom(Y){return Math.max(this.options.minZoom,Math.min(Math.floor(+Y),this.options.maxZoom+1))}_cluster(Y,q){let{radius:rt,extent:ht,reduce:Zt,minPoints:zt}=this.options,Xt=rt/(ht*Math.pow(2,q)),Mt=Y.data,re=[],ce=this.stride;for(let pe=0;peq&&(Ni+=Mt[rr+Ut])}if(Ni>ii&&Ni>=zt){let Qi,rr=me*ii,zi=Xe*ii,Cr=-1,ki=((pe/ce|0)<<5)+(q+1)+this.points.length;for(let fr of oi){let br=fr*ce;if(Mt[br+2]<=q)continue;Mt[br+2]=q;let Tr=Mt[br+Ut];rr+=Mt[br]*Tr,zi+=Mt[br+1]*Tr,Mt[br+4]=ki,Zt&&(Qi||(Qi=this._map(Mt,pe,!0),Cr=this.clusterProps.length,this.clusterProps.push(Qi)),Zt(Qi,this._map(Mt,br)))}Mt[pe+4]=ki,re.push(rr/Ni,zi/Ni,1/0,ki,-1,Ni),Zt&&re.push(Cr)}else{for(let Qi=0;Qi1)for(let Qi of oi){let rr=Qi*ce;if(!(Mt[rr+2]<=q)){Mt[rr+2]=q;for(let zi=0;zi>5}_getOriginZoom(Y){return(Y-this.points.length)%32}_map(Y,q,rt){if(Y[q+Ut]>1){let zt=this.clusterProps[Y[q+fe]];return rt?Object.assign({},zt):zt}let ht=this.points[Y[q+wt]].properties,Zt=this.options.map(ht);return rt&&Zt===ht?Object.assign({},Zt):Zt}}function bt(ft,Y,q){return{type:"Feature",id:ft[Y+wt],properties:It(ft,Y,q),geometry:{type:"Point",coordinates:[(rt=ft[Y],360*(rt-.5)),Ae(ft[Y+1])]}};var rt}function It(ft,Y,q){let rt=ft[Y+Ut],ht=rt>=1e4?`${Math.round(rt/1e3)}k`:rt>=1e3?Math.round(rt/100)/10+"k":rt,Zt=ft[Y+fe],zt=Zt===-1?{}:Object.assign({},q[Zt]);return Object.assign(zt,{cluster:!0,cluster_id:ft[Y+wt],point_count:rt,point_count_abbreviated:ht})}function Ht(ft){return ft/360+.5}function Ot(ft){let Y=Math.sin(ft*Math.PI/180),q=.5-.25*Math.log((1+Y)/(1-Y))/Math.PI;return q<0?0:q>1?1:q}function Ae(ft){let Y=(180-360*ft)*Math.PI/180;return 360*Math.atan(Math.exp(Y))/Math.PI-90}function he(ft,Y,q,rt){for(var ht,Zt=rt,zt=q-Y>>1,Xt=q-Y,Mt=ft[Y],re=ft[Y+1],ce=ft[q],pe=ft[q+1],me=Y+3;meZt)ht=me,Zt=Xe;else if(Xe===Zt){var oi=Math.abs(me-zt);oirt&&(ht-Y>3&&he(ft,Y,ht,rt),ft[ht+2]=Zt,q-ht>3&&he(ft,ht,q,rt))}function de(ft,Y,q,rt,ht,Zt){var zt=ht-q,Xt=Zt-rt;if(zt!==0||Xt!==0){var Mt=((ft-q)*zt+(Y-rt)*Xt)/(zt*zt+Xt*Xt);Mt>1?(q=ht,rt=Zt):Mt>0&&(q+=zt*Mt,rt+=Xt*Mt)}return(zt=ft-q)*zt+(Xt=Y-rt)*Xt}function He(ft,Y,q,rt){var ht={id:ft===void 0?null:ft,type:Y,geometry:q,tags:rt,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Zt){var zt=Zt.geometry,Xt=Zt.type;if(Xt==="Point"||Xt==="MultiPoint"||Xt==="LineString")Re(Zt,zt);else if(Xt==="Polygon"||Xt==="MultiLineString")for(var Mt=0;Mt0&&(zt+=rt?(ht*re-Mt*Zt)/2:Math.sqrt(Math.pow(Mt-ht,2)+Math.pow(re-Zt,2))),ht=Mt,Zt=re}var ce=Y.length-3;Y[2]=1,he(Y,0,ce,q),Y[ce+2]=1,Y.size=Math.abs(zt),Y.start=0,Y.end=Y.size}function xt(ft,Y,q,rt){for(var ht=0;ht1?1:q}function Ue(ft,Y,q,rt,ht,Zt,zt,Xt){if(rt/=Y,Zt>=(q/=Y)&&zt=rt)return null;for(var Mt=[],re=0;re=q&&oi=rt)){var ii=[];if(me==="Point"||me==="MultiPoint")Ee(pe,ii,q,rt,ht);else if(me==="LineString")Ne(pe,ii,q,rt,ht,!1,Xt.lineMetrics);else if(me==="MultiLineString")ze(pe,ii,q,rt,ht,!1);else if(me==="Polygon")ze(pe,ii,q,rt,ht,!0);else if(me==="MultiPolygon")for(var Ni=0;Ni=q&&zt<=rt&&(Y.push(ft[Zt]),Y.push(ft[Zt+1]),Y.push(ft[Zt+2]))}}function Ne(ft,Y,q,rt,ht,Zt,zt){for(var Xt,Mt,re=Je(ft),ce=ht===0?hi:Ei,pe=ft.start,me=0;meq&&(Mt=ce(re,Xe,oi,Ni,Qi,q),zt&&(re.start=pe+Xt*Mt)):rr>rt?zi=q&&(Mt=ce(re,Xe,oi,Ni,Qi,q),Cr=!0),zi>rt&&rr<=rt&&(Mt=ce(re,Xe,oi,Ni,Qi,rt),Cr=!0),!Zt&&Cr&&(zt&&(re.end=pe+Xt*Mt),Y.push(re),re=Je(ft)),zt&&(pe+=Xt)}var ki=ft.length-3;Xe=ft[ki],oi=ft[ki+1],ii=ft[ki+2],(rr=ht===0?Xe:oi)>=q&&rr<=rt&&ui(re,Xe,oi,ii),ki=re.length-3,Zt&&ki>=3&&(re[ki]!==re[0]||re[ki+1]!==re[1])&&ui(re,re[0],re[1],re[2]),re.length&&Y.push(re)}function Je(ft){var Y=[];return Y.size=ft.size,Y.start=ft.start,Y.end=ft.end,Y}function ze(ft,Y,q,rt,ht,Zt){for(var zt=0;ztzt.maxX&&(zt.maxX=ce),pe>zt.maxY&&(zt.maxY=pe)}return zt}function We(ft,Y,q,rt){var ht=Y.geometry,Zt=Y.type,zt=[];if(Zt==="Point"||Zt==="MultiPoint")for(var Xt=0;Xt0&&Y.size<(ht?zt:rt))q.numPoints+=Y.length/3;else{for(var Xt=[],Mt=0;Mtzt)&&(q.numSimplified++,Xt.push(Y[Mt]),Xt.push(Y[Mt+1])),q.numPoints++;ht&&function(re,ce){for(var pe=0,me=0,Xe=re.length,oi=Xe-2;me0===ce)for(me=0,Xe=re.length;me24)throw new Error("maxZoom should be in the 0-24 range");if(Y.promoteId&&Y.generateId)throw new Error("promoteId and generateId cannot be used together.");var rt=function(ht,Zt){var zt=[];if(ht.type==="FeatureCollection")for(var Xt=0;Xt1&&console.time("creation"),me=this.tiles[pe]=Vi(ft,Y,q,rt,Mt),this.tileCoords.push({z:Y,x:q,y:rt}),re)){re>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Y,q,rt,me.numFeatures,me.numPoints,me.numSimplified),console.timeEnd("creation"));var Xe="z"+Y;this.stats[Xe]=(this.stats[Xe]||0)+1,this.total++}if(me.source=ft,ht){if(Y===Mt.maxZoom||Y===ht)continue;var oi=1<1&&console.time("clipping");var ii,Ni,Qi,rr,zi,Cr,ki=.5*Mt.buffer/Mt.extent,fr=.5-ki,br=.5+ki,Tr=1+ki;ii=Ni=Qi=rr=null,zi=Ue(ft,ce,q-ki,q+br,0,me.minX,me.maxX,Mt),Cr=Ue(ft,ce,q+fr,q+Tr,0,me.minX,me.maxX,Mt),ft=null,zi&&(ii=Ue(zi,ce,rt-ki,rt+br,1,me.minY,me.maxY,Mt),Ni=Ue(zi,ce,rt+fr,rt+Tr,1,me.minY,me.maxY,Mt),zi=null),Cr&&(Qi=Ue(Cr,ce,rt-ki,rt+br,1,me.minY,me.maxY,Mt),rr=Ue(Cr,ce,rt+fr,rt+Tr,1,me.minY,me.maxY,Mt),Cr=null),re>1&&console.timeEnd("clipping"),Xt.push(ii||[],Y+1,2*q,2*rt),Xt.push(Ni||[],Y+1,2*q,2*rt+1),Xt.push(Qi||[],Y+1,2*q+1,2*rt),Xt.push(rr||[],Y+1,2*q+1,2*rt+1)}}},$e.prototype.getTile=function(ft,Y,q){var rt=this.options,ht=rt.extent,Zt=rt.debug;if(ft<0||ft>24)return null;var zt=1<1&&console.log("drilling down to z%d-%d-%d",ft,Y,q);for(var Mt,re=ft,ce=Y,pe=q;!Mt&&re>0;)re--,ce=Math.floor(ce/2),pe=Math.floor(pe/2),Mt=this.tiles[di(re,ce,pe)];return Mt&&Mt.source?(Zt>1&&console.log("found parent tile z%d-%d-%d",re,ce,pe),Zt>1&&console.time("drilling down"),this.splitTile(Mt.source,re,ce,pe,ft,Y,q),Zt>1&&console.timeEnd("drilling down"),this.tiles[Xt]?Oi(this.tiles[Xt],ht):null):null};class tr extends v{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(Y,q){return A._(this,void 0,void 0,function*(){let rt=Y.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");let ht=this._geoJSONIndex.getTile(rt.z,rt.x,rt.y);if(!ht)return null;let Zt=new class{constructor(Xt){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=A.W,this.length=Xt.length,this._features=Xt}feature(Xt){return new class{constructor(Mt){this._feature=Mt,this.extent=A.W,this.type=Mt.type,this.properties=Mt.tags,"id"in Mt&&!isNaN(Mt.id)&&(this.id=parseInt(Mt.id,10))}loadGeometry(){if(this._feature.type===1){let Mt=[];for(let re of this._feature.geometry)Mt.push([new A.P(re[0],re[1])]);return Mt}{let Mt=[];for(let re of this._feature.geometry){let ce=[];for(let pe of re)ce.push(new A.P(pe[0],pe[1]));Mt.push(ce)}return Mt}}toGeoJSON(Mt,re,ce){return W.call(this,Mt,re,ce)}}(this._features[Xt])}}(ht.features),zt=le(Zt);return zt.byteOffset===0&&zt.byteLength===zt.buffer.byteLength||(zt=new Uint8Array(zt)),{vectorTile:Zt,rawData:zt.buffer}})}loadData(Y){return A._(this,void 0,void 0,function*(){var q;(q=this._pendingRequest)===null||q===void 0||q.abort();let rt=!!(Y&&Y.request&&Y.request.collectResourceTiming)&&new A.bs(Y.request);this._pendingRequest=new AbortController;try{let ht=yield this.loadGeoJSON(Y,this._pendingRequest);if(delete this._pendingRequest,typeof ht!="object")throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`);if(k(ht,!0),Y.filter){let zt=A.by(Y.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(zt.result==="error")throw new Error(zt.value.map(Mt=>`${Mt.key}: ${Mt.message}`).join(", "));ht={type:"FeatureCollection",features:ht.features.filter(Mt=>zt.value.evaluate({zoom:0},Mt))}}this._geoJSONIndex=Y.cluster?new j(function({superclusterOptions:zt,clusterProperties:Xt}){if(!Xt||!zt)return zt;let Mt={},re={},ce={accumulated:null,zoom:0},pe={properties:null},me=Object.keys(Xt);for(let Xe of me){let[oi,ii]=Xt[Xe],Ni=A.by(ii),Qi=A.by(typeof oi=="string"?[oi,["accumulated"],["get",Xe]]:oi);Mt[Xe]=Ni.value,re[Xe]=Qi.value}return zt.map=Xe=>{pe.properties=Xe;let oi={};for(let ii of me)oi[ii]=Mt[ii].evaluate(ce,pe);return oi},zt.reduce=(Xe,oi)=>{pe.properties=oi;for(let ii of me)ce.accumulated=Xe[ii],Xe[ii]=re[ii].evaluate(ce,pe)},zt}(Y)).load(ht.features):function(zt,Xt){return new $e(zt,Xt)}(ht,Y.geojsonVtOptions),this.loaded={};let Zt={};if(rt){let zt=rt.finish();zt&&(Zt.resourceTiming={},Zt.resourceTiming[Y.source]=JSON.parse(JSON.stringify(zt)))}return Zt}catch(ht){if(delete this._pendingRequest,A.bz(ht))return{abandoned:!0};throw ht}})}reloadTile(Y){let q=this.loaded;return q&&q[Y.uid]?super.reloadTile(Y):this.loadTile(Y)}loadGeoJSON(Y,q){return A._(this,void 0,void 0,function*(){let{promoteId:rt}=Y;if(Y.request){let ht=yield A.h(Y.request,q);return this._dataUpdateable=qi(ht.data,rt)?vi(ht.data,rt):void 0,ht.data}if(typeof Y.data=="string")try{let ht=JSON.parse(Y.data);return this._dataUpdateable=qi(ht,rt)?vi(ht,rt):void 0,ht}catch{throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`)}if(!Y.dataDiff)throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${Y.source}`);return function(ht,Zt,zt){var Xt,Mt,re,ce;if(Zt.removeAll&&ht.clear(),Zt.remove)for(let pe of Zt.remove)ht.delete(pe);if(Zt.add)for(let pe of Zt.add){let me=Zi(pe,zt);me!=null&&ht.set(me,pe)}if(Zt.update)for(let pe of Zt.update){let me=ht.get(pe.id);if(me==null)continue;let Xe=!pe.removeAllProperties&&(((Xt=pe.removeProperties)===null||Xt===void 0?void 0:Xt.length)>0||((Mt=pe.addOrUpdateProperties)===null||Mt===void 0?void 0:Mt.length)>0);if((pe.newGeometry||pe.removeAllProperties||Xe)&&(me=Object.assign({},me),ht.set(pe.id,me),Xe&&(me.properties=Object.assign({},me.properties))),pe.newGeometry&&(me.geometry=pe.newGeometry),pe.removeAllProperties)me.properties={};else if(((re=pe.removeProperties)===null||re===void 0?void 0:re.length)>0)for(let oi of pe.removeProperties)Object.prototype.hasOwnProperty.call(me.properties,oi)&&delete me.properties[oi];if(((ce=pe.addOrUpdateProperties)===null||ce===void 0?void 0:ce.length)>0)for(let{key:oi,value:ii}of pe.addOrUpdateProperties)me.properties[oi]=ii}}(this._dataUpdateable,Y.dataDiff,rt),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(Y){return A._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(Y){return this._geoJSONIndex.getClusterExpansionZoom(Y.clusterId)}getClusterChildren(Y){return this._geoJSONIndex.getChildren(Y.clusterId)}getClusterLeaves(Y){return this._geoJSONIndex.getLeaves(Y.clusterId,Y.limit,Y.offset)}}class Lr{constructor(Y){this.self=Y,this.actor=new A.C(Y),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(q,rt)=>{if(this.externalWorkerSourceTypes[q])throw new Error(`Worker source with name "${q}" already registered.`);this.externalWorkerSourceTypes[q]=rt},this.self.addProtocol=A.bf,this.self.removeProtocol=A.bg,this.self.registerRTLTextPlugin=q=>{if(A.bA.isParsed())throw new Error("RTL text plugin already registered.");A.bA.setMethods(q)},this.actor.registerMessageHandler("loadDEMTile",(q,rt)=>this._getDEMWorkerSource(q,rt.source).loadTile(rt)),this.actor.registerMessageHandler("removeDEMTile",(q,rt)=>A._(this,void 0,void 0,function*(){this._getDEMWorkerSource(q,rt.source).removeTile(rt)})),this.actor.registerMessageHandler("getClusterExpansionZoom",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterExpansionZoom(rt)})),this.actor.registerMessageHandler("getClusterChildren",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterChildren(rt)})),this.actor.registerMessageHandler("getClusterLeaves",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterLeaves(rt)})),this.actor.registerMessageHandler("loadData",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).loadData(rt)),this.actor.registerMessageHandler("loadTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).loadTile(rt)),this.actor.registerMessageHandler("reloadTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).reloadTile(rt)),this.actor.registerMessageHandler("abortTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).abortTile(rt)),this.actor.registerMessageHandler("removeTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).removeTile(rt)),this.actor.registerMessageHandler("removeSource",(q,rt)=>A._(this,void 0,void 0,function*(){if(!this.workerSources[q]||!this.workerSources[q][rt.type]||!this.workerSources[q][rt.type][rt.source])return;let ht=this.workerSources[q][rt.type][rt.source];delete this.workerSources[q][rt.type][rt.source],ht.removeSource!==void 0&&ht.removeSource(rt)})),this.actor.registerMessageHandler("removeMap",q=>A._(this,void 0,void 0,function*(){delete this.layerIndexes[q],delete this.availableImages[q],delete this.workerSources[q],delete this.demWorkerSources[q]})),this.actor.registerMessageHandler("setReferrer",(q,rt)=>A._(this,void 0,void 0,function*(){this.referrer=rt})),this.actor.registerMessageHandler("syncRTLPluginState",(q,rt)=>this._syncRTLPluginState(q,rt)),this.actor.registerMessageHandler("importScript",(q,rt)=>A._(this,void 0,void 0,function*(){this.self.importScripts(rt)})),this.actor.registerMessageHandler("setImages",(q,rt)=>this._setImages(q,rt)),this.actor.registerMessageHandler("updateLayers",(q,rt)=>A._(this,void 0,void 0,function*(){this._getLayerIndex(q).update(rt.layers,rt.removedIds)})),this.actor.registerMessageHandler("setLayers",(q,rt)=>A._(this,void 0,void 0,function*(){this._getLayerIndex(q).replace(rt)}))}_setImages(Y,q){return A._(this,void 0,void 0,function*(){this.availableImages[Y]=q;for(let rt in this.workerSources[Y]){let ht=this.workerSources[Y][rt];for(let Zt in ht)ht[Zt].availableImages=q}})}_syncRTLPluginState(Y,q){return A._(this,void 0,void 0,function*(){if(A.bA.isParsed())return A.bA.getState();if(q.pluginStatus!=="loading")return A.bA.setState(q),q;let rt=q.pluginURL;if(this.self.importScripts(rt),A.bA.isParsed()){let ht={pluginStatus:"loaded",pluginURL:rt};return A.bA.setState(ht),ht}throw A.bA.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${rt}`)})}_getAvailableImages(Y){let q=this.availableImages[Y];return q||(q=[]),q}_getLayerIndex(Y){let q=this.layerIndexes[Y];return q||(q=this.layerIndexes[Y]=new o),q}_getWorkerSource(Y,q,rt){if(this.workerSources[Y]||(this.workerSources[Y]={}),this.workerSources[Y][q]||(this.workerSources[Y][q]={}),!this.workerSources[Y][q][rt]){let ht={sendAsync:(Zt,zt)=>(Zt.targetMapId=Y,this.actor.sendAsync(Zt,zt))};switch(q){case"vector":this.workerSources[Y][q][rt]=new v(ht,this._getLayerIndex(Y),this._getAvailableImages(Y));break;case"geojson":this.workerSources[Y][q][rt]=new tr(ht,this._getLayerIndex(Y),this._getAvailableImages(Y));break;default:this.workerSources[Y][q][rt]=new this.externalWorkerSourceTypes[q](ht,this._getLayerIndex(Y),this._getAvailableImages(Y))}}return this.workerSources[Y][q][rt]}_getDEMWorkerSource(Y,q){return this.demWorkerSources[Y]||(this.demWorkerSources[Y]={}),this.demWorkerSources[Y][q]||(this.demWorkerSources[Y][q]=new x),this.demWorkerSources[Y][q]}}return A.i(self)&&(self.worker=new Lr(self)),Lr}),i("index",["exports","./shared"],function(A,o){"use strict";var g="4.1.2";let d,C,v={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:y=>new Promise((n,c)=>{let p=requestAnimationFrame(n);y.signal.addEventListener("abort",()=>{cancelAnimationFrame(p),c(o.c())})}),getImageData(y,n=0){return this.getImageCanvasContext(y).getImageData(-n,-n,y.width+2*n,y.height+2*n)},getImageCanvasContext(y){let n=window.document.createElement("canvas"),c=n.getContext("2d",{willReadFrequently:!0});if(!c)throw new Error("failed to create canvas 2d context");return n.width=y.width,n.height=y.height,c.drawImage(y,0,0,y.width,y.height),c},resolveURL:y=>(d||(d=document.createElement("a")),d.href=y,d.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(C==null&&(C=matchMedia("(prefers-reduced-motion: reduce)")),C.matches)}};class x{static testProp(n){if(!x.docStyle)return n[0];for(let c=0;c{window.removeEventListener("click",x.suppressClickInternal,!0)},0)}static getScale(n){let c=n.getBoundingClientRect();return{x:c.width/n.offsetWidth||1,y:c.height/n.offsetHeight||1,boundingClientRect:c}}static getPoint(n,c,p){let f=c.boundingClientRect;return new o.P((p.clientX-f.left)/c.x-n.clientLeft,(p.clientY-f.top)/c.y-n.clientTop)}static mousePos(n,c){let p=x.getScale(n);return x.getPoint(n,p,c)}static touchPos(n,c){let p=[],f=x.getScale(n);for(let b=0;b{n=[],c=0,p=0,f={}},y.addThrottleControl=H=>{let h=p++;return f[h]=H,h},y.removeThrottleControl=H=>{delete f[H],L()},y.getImage=(H,h,I=!0)=>new Promise((_,F)=>{T.supported&&(H.headers||(H.headers={}),H.headers.accept="image/webp,*/*"),o.e(H,{type:"image"}),n.push({abortController:h,requestParameters:H,supportImageRefresh:I,state:"queued",onError:R=>{F(R)},onSuccess:R=>{_(R)}}),L()});let b=H=>o._(this,void 0,void 0,function*(){H.state="running";let{requestParameters:h,supportImageRefresh:I,onError:_,onSuccess:F,abortController:R}=H,Z=I===!1&&!o.i(self)&&!o.g(h.url)&&(!h.headers||Object.keys(h.headers).reduce((V,X)=>V&&X==="accept",!0));c++;let N=Z?E(h,R):o.m(h,R);try{let V=yield N;delete H.abortController,H.state="completed",V.data instanceof HTMLImageElement||o.b(V.data)?F(V):V.data&&F({data:yield(P=V.data,typeof createImageBitmap=="function"?o.d(P):o.f(P)),cacheControl:V.cacheControl,expires:V.expires})}catch(V){delete H.abortController,_(V)}finally{c--,L()}var P}),L=()=>{let H=(()=>{for(let h of Object.keys(f))if(f[h]())return!0;return!1})()?o.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:o.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let h=c;h0;h++){let I=n.shift();I.abortController.signal.aborted?h--:b(I)}},E=(H,h)=>new Promise((I,_)=>{let F=new Image,R=H.url,Z=H.credentials;Z&&Z==="include"?F.crossOrigin="use-credentials":(Z&&Z==="same-origin"||!o.s(R))&&(F.crossOrigin="anonymous"),h.signal.addEventListener("abort",()=>{F.src="",_(o.c())}),F.fetchPriority="high",F.onload=()=>{F.onerror=F.onload=null,I({data:F})},F.onerror=()=>{F.onerror=F.onload=null,h.signal.aborted||_(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."))},F.src=R})}(O||(O={})),O.resetRequestQueue(),function(y){y.Glyphs="Glyphs",y.Image="Image",y.Source="Source",y.SpriteImage="SpriteImage",y.SpriteJSON="SpriteJSON",y.Style="Style",y.Tile="Tile",y.Unknown="Unknown"}(tt||(tt={}));class at{constructor(n){this._transformRequestFn=n}transformRequest(n,c){return this._transformRequestFn&&this._transformRequestFn(n,c)||{url:n}}normalizeSpriteURL(n,c,p){let f=function(b){let L=b.match(Lt);if(!L)throw new Error(`Unable to parse URL "${b}"`);return{protocol:L[1],authority:L[2],path:L[3]||"/",params:L[4]?L[4].split("&"):[]}}(n);return f.path+=`${c}${p}`,function(b){let L=b.params.length?`?${b.params.join("&")}`:"";return`${b.protocol}://${b.authority}${b.path}${L}`}(f)}setTransformRequest(n){this._transformRequestFn=n}}let Lt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Tt(y){var n=new o.A(3);return n[0]=y[0],n[1]=y[1],n[2]=y[2],n}var Qt,Ft=function(y,n,c){return y[0]=n[0]-c[0],y[1]=n[1]-c[1],y[2]=n[2]-c[2],y};Qt=new o.A(3),o.A!=Float32Array&&(Qt[0]=0,Qt[1]=0,Qt[2]=0);var vt=function(y){var n=y[0],c=y[1];return n*n+c*c};function Jt(y){let n=[];if(typeof y=="string")n.push({id:"default",url:y});else if(y&&y.length>0){let c=[];for(let{id:p,url:f}of y){let b=`${p}${f}`;c.indexOf(b)===-1&&(c.push(b),n.push({id:p,url:f}))}}return n}(function(){var y=new o.A(2);o.A!=Float32Array&&(y[0]=0,y[1]=0)})();class qt{constructor(n,c,p,f){this.context=n,this.format=p,this.texture=n.gl.createTexture(),this.update(c,f)}update(n,c,p){let{width:f,height:b}=n,L=!(this.size&&this.size[0]===f&&this.size[1]===b||p),{context:E}=this,{gl:H}=E;if(this.useMipmap=Boolean(c&&c.useMipmap),H.bindTexture(H.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===H.RGBA&&(!c||c.premultiply!==!1)),L)this.size=[f,b],n instanceof HTMLImageElement||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageData||o.b(n)?H.texImage2D(H.TEXTURE_2D,0,this.format,this.format,H.UNSIGNED_BYTE,n):H.texImage2D(H.TEXTURE_2D,0,this.format,f,b,0,this.format,H.UNSIGNED_BYTE,n.data);else{let{x:h,y:I}=p||{x:0,y:0};n instanceof HTMLImageElement||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageData||o.b(n)?H.texSubImage2D(H.TEXTURE_2D,0,h,I,H.RGBA,H.UNSIGNED_BYTE,n):H.texSubImage2D(H.TEXTURE_2D,0,h,I,f,b,H.RGBA,H.UNSIGNED_BYTE,n.data)}this.useMipmap&&this.isSizePowerOfTwo()&&H.generateMipmap(H.TEXTURE_2D)}bind(n,c,p){let{context:f}=this,{gl:b}=f;b.bindTexture(b.TEXTURE_2D,this.texture),p!==b.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(p=b.LINEAR),n!==this.filter&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,n),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,p||n),this.filter=n),c!==this.wrap&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,c),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,c),this.wrap=c)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}}function At(y){let{userImage:n}=y;return!!(n&&n.render&&n.render())&&(y.data.replace(new Uint8Array(n.data.buffer)),!0)}class lt extends o.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new o.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(n){if(this.loaded!==n&&(this.loaded=n,n)){for(let{ids:c,promiseResolve:p}of this.requestors)p(this._getImagesForIds(c));this.requestors=[]}}getImage(n){let c=this.images[n];if(c&&!c.data&&c.spriteData){let p=c.spriteData;c.data=new o.R({width:p.width,height:p.height},p.context.getImageData(p.x,p.y,p.width,p.height).data),c.spriteData=null}return c}addImage(n,c){if(this.images[n])throw new Error(`Image id ${n} already exist, use updateImage instead`);this._validate(n,c)&&(this.images[n]=c)}_validate(n,c){let p=!0,f=c.data||c.spriteData;return this._validateStretch(c.stretchX,f&&f.width)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "stretchX" value`))),p=!1),this._validateStretch(c.stretchY,f&&f.height)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "stretchY" value`))),p=!1),this._validateContent(c.content,c)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "content" value`))),p=!1),p}_validateStretch(n,c){if(!n)return!0;let p=0;for(let f of n){if(f[0]{let f=!0;if(!this.isLoaded())for(let b of n)this.images[b]||(f=!1);this.isLoaded()||f?c(this._getImagesForIds(n)):this.requestors.push({ids:n,promiseResolve:c})})}_getImagesForIds(n){let c={};for(let p of n){let f=this.getImage(p);f||(this.fire(new o.k("styleimagemissing",{id:p})),f=this.getImage(p)),f?c[p]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:Boolean(f.userImage&&f.userImage.render)}:o.w(`Image "${p}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return c}getPixelSize(){let{width:n,height:c}=this.atlasImage;return{width:n,height:c}}getPattern(n){let c=this.patterns[n],p=this.getImage(n);if(!p)return null;if(c&&c.position.version===p.version)return c.position;if(c)c.position.version=p.version;else{let f={w:p.data.width+2,h:p.data.height+2,x:0,y:0},b=new o.I(f,p);this.patterns[n]={bin:f,position:b}}return this._updatePatternAtlas(),this.patterns[n].position}bind(n){let c=n.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new qt(n,this.atlasImage,c.RGBA),this.atlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(){let n=[];for(let b in this.patterns)n.push(this.patterns[b].bin);let{w:c,h:p}=o.p(n),f=this.atlasImage;f.resize({width:c||1,height:p||1});for(let b in this.patterns){let{bin:L}=this.patterns[b],E=L.x+1,H=L.y+1,h=this.getImage(b).data,I=h.width,_=h.height;o.R.copy(h,f,{x:0,y:0},{x:E,y:H},{width:I,height:_}),o.R.copy(h,f,{x:0,y:_-1},{x:E,y:H-1},{width:I,height:1}),o.R.copy(h,f,{x:0,y:0},{x:E,y:H+_},{width:I,height:1}),o.R.copy(h,f,{x:I-1,y:0},{x:E-1,y:H},{width:1,height:_}),o.R.copy(h,f,{x:0,y:0},{x:E+I,y:H},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(n){for(let c of n){if(this.callbackDispatchedThisFrame[c])continue;this.callbackDispatchedThisFrame[c]=!0;let p=this.getImage(c);p||o.w(`Image with ID: "${c}" was not found`),At(p)&&this.updateImage(c,p)}}}let kt=1e20;function _t(y,n,c,p,f,b,L,E,H){for(let h=n;h-1);H++,b[H]=E,L[H]=h,L[H+1]=kt}for(let E=0,H=0;E65535)throw new Error("glyphs > 65535 not supported");if(p.ranges[b])return{stack:n,id:c,glyph:f};if(!this.url)throw new Error("glyphsUrl is not set");if(!p.requests[b]){let E=ie.loadGlyphRange(n,b,this.url,this.requestManager);p.requests[b]=E}let L=yield p.requests[b];for(let E in L)this._doesCharSupportLocalGlyph(+E)||(p.glyphs[+E]=L[+E]);return p.ranges[b]=!0,{stack:n,id:c,glyph:L[c]||null}})}_doesCharSupportLocalGlyph(n){return!!this.localIdeographFontFamily&&(o.u["CJK Unified Ideographs"](n)||o.u["Hangul Syllables"](n)||o.u.Hiragana(n)||o.u.Katakana(n))}_tinySDF(n,c,p){let f=this.localIdeographFontFamily;if(!f||!this._doesCharSupportLocalGlyph(p))return;let b=n.tinySDF;if(!b){let E="400";/bold/i.test(c)?E="900":/medium/i.test(c)?E="500":/light/i.test(c)&&(E="200"),b=n.tinySDF=new ie.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:f,fontWeight:E})}let L=b.draw(String.fromCharCode(p));return{id:p,bitmap:new o.o({width:L.width||60,height:L.height||60},L.data),metrics:{width:L.glyphWidth/2||24,height:L.glyphHeight/2||24,left:L.glyphLeft/2+.5||0,top:L.glyphTop/2-27.5||-8,advance:L.glyphAdvance/2||24,isDoubleResolution:!0}}}}ie.loadGlyphRange=function(y,n,c,p){return o._(this,void 0,void 0,function*(){let f=256*n,b=f+255,L=p.transformRequest(c.replace("{fontstack}",y).replace("{range}",`${f}-${b}`),tt.Glyphs),E=yield o.l(L,new AbortController);if(!E||!E.data)throw new Error(`Could not load glyph range. range: ${n}, ${f}-${b}`);let H={};for(let h of o.n(E.data))H[h.id]=h;return H})},ie.TinySDF=class{constructor({fontSize:y=24,buffer:n=3,radius:c=8,cutoff:p=.25,fontFamily:f="sans-serif",fontWeight:b="normal",fontStyle:L="normal"}={}){this.buffer=n,this.cutoff=p,this.radius=c;let E=this.size=y+4*n,H=this._createCanvas(E),h=this.ctx=H.getContext("2d",{willReadFrequently:!0});h.font=`${L} ${b} ${y}px ${f}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(E*E),this.gridInner=new Float64Array(E*E),this.f=new Float64Array(E),this.z=new Float64Array(E+1),this.v=new Uint16Array(E)}_createCanvas(y){let n=document.createElement("canvas");return n.width=n.height=y,n}draw(y){let{width:n,actualBoundingBoxAscent:c,actualBoundingBoxDescent:p,actualBoundingBoxLeft:f,actualBoundingBoxRight:b}=this.ctx.measureText(y),L=Math.ceil(c),E=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(b-f))),H=Math.min(this.size-this.buffer,L+Math.ceil(p)),h=E+2*this.buffer,I=H+2*this.buffer,_=Math.max(h*I,0),F=new Uint8ClampedArray(_),R={data:F,width:h,height:I,glyphWidth:E,glyphHeight:H,glyphTop:L,glyphLeft:0,glyphAdvance:n};if(E===0||H===0)return R;let{ctx:Z,buffer:N,gridInner:P,gridOuter:V}=this;Z.clearRect(N,N,E,H),Z.fillText(y,N,N+L);let X=Z.getImageData(N,N,E,H);V.fill(kt,0,_),P.fill(0,0,_);for(let J=0;J0?Gt*Gt:0,P[ut]=Gt<0?Gt*Gt:0}}_t(V,0,0,h,I,h,this.f,this.v,this.z),_t(P,N,N,E,H,h,this.f,this.v,this.z);for(let J=0;J<_;J++){let ot=Math.sqrt(V[J])-Math.sqrt(P[J]);F[J]=Math.round(255-255*(ot/this.radius+this.cutoff))}return R}};class ne{constructor(){this.specification=o.v.light.position}possiblyEvaluate(n,c){return o.y(n.expression.evaluate(c))}interpolate(n,c,p){return{x:o.z.number(n.x,c.x,p),y:o.z.number(n.y,c.y,p),z:o.z.number(n.z,c.z,p)}}}let te;class wt extends o.E{constructor(n){super(),te=te||new o.q({anchor:new o.D(o.v.light.anchor),position:new ne,color:new o.D(o.v.light.color),intensity:new o.D(o.v.light.intensity)}),this._transitionable=new o.T(te),this.setLight(n),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(n,c={}){if(!this._validate(o.r,n,c))for(let p in n){let f=n[p];p.endsWith("-transition")?this._transitionable.setTransition(p.slice(0,-11),f):this._transitionable.setValue(p,f)}}updateTransitions(n){this._transitioning=this._transitionable.transitioned(n,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(n){this.properties=this._transitioning.possiblyEvaluate(n)}_validate(n,c,p){return(!p||p.validate!==!1)&&o.t(this,n.call(o.x,{value:c,style:{glyphs:!0,sprite:!0},styleSpec:o.v}))}}class Ut{constructor(n,c){this.width=n,this.height=c,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(n,c){let p=n.join(",")+String(c);return this.dashEntry[p]||(this.dashEntry[p]=this.addDash(n,c)),this.dashEntry[p]}getDashRanges(n,c,p){let f=[],b=n.length%2==1?-n[n.length-1]*p:0,L=n[0]*p,E=!0;f.push({left:b,right:L,isDash:E,zeroLength:n[0]===0});let H=n[0];for(let h=1;h1&&(H=n[++E]);let I=Math.abs(h-H.left),_=Math.abs(h-H.right),F=Math.min(I,_),R,Z=b/p*(f+1);if(H.isDash){let N=f-Math.abs(Z);R=Math.sqrt(F*F+N*N)}else R=f-Math.sqrt(F*F+Z*Z);this.data[L+h]=Math.max(0,Math.min(255,R+128))}}}addRegularDash(n){for(let E=n.length-1;E>=0;--E){let H=n[E],h=n[E+1];H.zeroLength?n.splice(E,1):h&&h.isDash===H.isDash&&(h.left=H.left,n.splice(E,1))}let c=n[0],p=n[n.length-1];c.isDash===p.isDash&&(c.left=p.left-this.width,p.right=c.right+this.width);let f=this.width*this.nextRow,b=0,L=n[b];for(let E=0;E1&&(L=n[++b]);let H=Math.abs(E-L.left),h=Math.abs(E-L.right),I=Math.min(H,h);this.data[f+E]=Math.max(0,Math.min(255,(L.isDash?I:-I)+128))}}addDash(n,c){let p=c?7:0,f=2*p+1;if(this.nextRow+f>this.height)return o.w("LineAtlas out of space"),null;let b=0;for(let E=0;E{c.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[fe]}numActive(){return Object.keys(this.active).length}}let bt=Math.floor(v.hardwareConcurrency/2),It,Ht;function Ot(){return It||(It=new j),It}j.workerCount=o.B(globalThis)?Math.max(Math.min(bt,3),1):1;class Ae{constructor(n,c){this.workerPool=n,this.actors=[],this.currentActor=0,this.id=c;let p=this.workerPool.acquire(c);for(let f=0;f{c.remove()}),this.actors=[],n&&this.workerPool.release(this.id)}registerMessageHandler(n,c){for(let p of this.actors)p.registerMessageHandler(n,c)}}function he(){return Ht||(Ht=new Ae(Ot(),o.G),Ht.registerMessageHandler("getResource",(y,n,c)=>o.m(n,c))),Ht}function de(y,n){let c=o.F();return o.H(c,c,[1,1,0]),o.J(c,c,[.5*y.width,.5*y.height,1]),o.K(c,c,y.calculatePosMatrix(n.toUnwrapped()))}function He(y,n,c,p,f,b){let L=function(_,F,R){if(_)for(let Z of _){let N=F[Z];if(N&&N.source===R&&N.type==="fill-extrusion")return!0}else for(let Z in F){let N=F[Z];if(N.source===R&&N.type==="fill-extrusion")return!0}return!1}(f&&f.layers,n,y.id),E=b.maxPitchScaleFactor(),H=y.tilesIn(p,E,L);H.sort(Re);let h=[];for(let _ of H)h.push({wrappedTileID:_.tileID.wrapped().key,queryResults:_.tile.queryRenderedFeatures(n,c,y._state,_.queryGeometry,_.cameraQueryGeometry,_.scale,f,b,E,de(y.transform,_.tileID))});let I=function(_){let F={},R={};for(let Z of _){let N=Z.queryResults,P=Z.wrappedTileID,V=R[P]=R[P]||{};for(let X in N){let J=N[X],ot=V[X]=V[X]||{},dt=F[X]=F[X]||[];for(let ut of J)ot[ut.featureIndex]||(ot[ut.featureIndex]=!0,dt.push(ut))}}return F}(h);for(let _ in I)I[_].forEach(F=>{let R=F.feature,Z=y.getFeatureState(R.layer["source-layer"],R.id);R.source=R.layer.source,R.layer["source-layer"]&&(R.sourceLayer=R.layer["source-layer"]),R.state=Z});return I}function Re(y,n){let c=y.tileID,p=n.tileID;return c.overscaledZ-p.overscaledZ||c.canonical.y-p.canonical.y||c.wrap-p.wrap||c.canonical.x-p.canonical.x}function je(y,n,c){return o._(this,void 0,void 0,function*(){let p=y;if(y.url?p=(yield o.h(n.transformRequest(y.url,tt.Source),c)).data:yield v.frameAsync(c),!p)return null;let f=o.L(o.e(p,y),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in p&&p.vector_layers&&(f.vectorLayerIds=p.vector_layers.map(b=>b.id)),f})}class Me{constructor(n,c){n&&(c?this.setSouthWest(n).setNorthEast(c):Array.isArray(n)&&(n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1])))}setNorthEast(n){return this._ne=n instanceof o.M?new o.M(n.lng,n.lat):o.M.convert(n),this}setSouthWest(n){return this._sw=n instanceof o.M?new o.M(n.lng,n.lat):o.M.convert(n),this}extend(n){let c=this._sw,p=this._ne,f,b;if(n instanceof o.M)f=n,b=n;else{if(!(n instanceof Me))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(Me.convert(n)):this.extend(o.M.convert(n)):n&&("lng"in n||"lon"in n)&&"lat"in n?this.extend(o.M.convert(n)):this;if(f=n._sw,b=n._ne,!f||!b)return this}return c||p?(c.lng=Math.min(f.lng,c.lng),c.lat=Math.min(f.lat,c.lat),p.lng=Math.max(b.lng,p.lng),p.lat=Math.max(b.lat,p.lat)):(this._sw=new o.M(f.lng,f.lat),this._ne=new o.M(b.lng,b.lat)),this}getCenter(){return new o.M((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 o.M(this.getWest(),this.getNorth())}getSouthEast(){return new o.M(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(n){let{lng:c,lat:p}=o.M.convert(n),f=this._sw.lng<=c&&c<=this._ne.lng;return this._sw.lng>this._ne.lng&&(f=this._sw.lng>=c&&c>=this._ne.lng),this._sw.lat<=p&&p<=this._ne.lat&&f}static convert(n){return n instanceof Me?n:n&&new Me(n)}static fromLngLat(n,c=0){let p=360*c/40075017,f=p/Math.cos(Math.PI/180*n.lat);return new Me(new o.M(n.lng-f,n.lat-p),new o.M(n.lng+f,n.lat+p))}}class gi{constructor(n,c,p){this.bounds=Me.convert(this.validateBounds(n)),this.minzoom=c||0,this.maxzoom=p||24}validateBounds(n){return Array.isArray(n)&&n.length===4?[Math.max(-180,n[0]),Math.max(-90,n[1]),Math.min(180,n[2]),Math.min(90,n[3])]:[-180,-90,180,90]}contains(n){let c=Math.pow(2,n.z),p=Math.floor(o.N(this.bounds.getWest())*c),f=Math.floor(o.O(this.bounds.getNorth())*c),b=Math.ceil(o.N(this.bounds.getEast())*c),L=Math.ceil(o.O(this.bounds.getSouth())*c);return n.x>=p&&n.x=f&&n.y{this._options.tiles=n}),this}setUrl(n){return this.setSourceProperty(()=>{this.url=n,this._options.url=n}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return o.e({},this._options)}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p={request:this.map._requestManager.transformRequest(c,tt.Tile),uid:n.uid,tileID:n.tileID,zoom:n.tileID.overscaledZ,tileSize:this.tileSize*n.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};p.request.collectResourceTiming=this._collectResourceTiming;let f="reloadTile";if(n.actor&&n.state!=="expired"){if(n.state==="loading")return new Promise((b,L)=>{n.reloadPromise={resolve:b,reject:L}})}else n.actor=this.dispatcher.getActor(),f="loadTile";n.abortController=new AbortController;try{let b=yield n.actor.sendAsync({type:f,data:p},n.abortController);if(delete n.abortController,n.aborted)return;this._afterTileLoadWorkerResponse(n,b)}catch(b){if(delete n.abortController,n.aborted)return;if(b&&b.status!==404)throw b;this._afterTileLoadWorkerResponse(n,null)}})}_afterTileLoadWorkerResponse(n,c){if(c&&c.resourceTiming&&(n.resourceTiming=c.resourceTiming),c&&this.map._refreshExpiredTiles&&n.setExpiryData(c),n.loadVectorData(c,this.map.painter),n.reloadPromise){let p=n.reloadPromise;n.reloadPromise=null,this.loadTile(n).then(p.resolve).catch(p.reject)}}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController),n.actor&&(yield n.actor.sendAsync({type:"abortTile",data:{uid:n.uid,type:this.type,source:this.id}}))})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.unloadVectorData(),n.actor&&(yield n.actor.sendAsync({type:"removeTile",data:{uid:n.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Rt extends o.E{constructor(n,c,p,f){super(),this.id=n,this.dispatcher=p,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=o.e({type:"raster"},c),o.e(this,o.L(c,["url","scheme","tileSize"]))}load(){return o._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let n=yield je(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(o.e(this,n),n.bounds&&(this.tileBounds=new gi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new o.k("data",{dataType:"source",sourceDataType:"content"})))}catch(n){this._tileJSONRequest=null,this.fire(new o.j(n))}})}loaded(){return this._loaded}onAdd(n){this.map=n,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(n){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),n(),this.load()}setTiles(n){return this.setSourceProperty(()=>{this._options.tiles=n}),this}setUrl(n){return this.setSourceProperty(()=>{this.url=n,this._options.url=n}),this}serialize(){return o.e({},this._options)}hasTile(n){return!this.tileBounds||this.tileBounds.contains(n.canonical)}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);n.abortController=new AbortController;try{let p=yield O.getImage(this.map._requestManager.transformRequest(c,tt.Tile),n.abortController,this.map._refreshExpiredTiles);if(delete n.abortController,n.aborted)return void(n.state="unloaded");if(p&&p.data){this.map._refreshExpiredTiles&&p.cacheControl&&p.expires&&n.setExpiryData({cacheControl:p.cacheControl,expires:p.expires});let f=this.map.painter.context,b=f.gl,L=p.data;n.texture=this.map.painter.getTileTexture(L.width),n.texture?n.texture.update(L,{useMipmap:!0}):(n.texture=new qt(f,L,b.RGBA,{useMipmap:!0}),n.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE,b.LINEAR_MIPMAP_NEAREST),f.extTextureFilterAnisotropic&&b.texParameterf(b.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax)),n.state="loaded"}}catch(p){if(delete n.abortController,n.aborted)n.state="unloaded";else if(p)throw n.state="errored",p}})}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController)})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.texture&&this.map.painter.saveTileTexture(n.texture)})}hasTransition(){return!1}}class Li extends Rt{constructor(n,c,p,f){super(n,c,p,f),this.type="raster-dem",this.maxzoom=22,this._options=o.e({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox",this.redFactor=c.redFactor,this.greenFactor=c.greenFactor,this.blueFactor=c.blueFactor,this.baseShift=c.baseShift}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p=this.map._requestManager.transformRequest(c,tt.Tile);n.neighboringTiles=this._getNeighboringTiles(n.tileID),n.abortController=new AbortController;try{let f=yield O.getImage(p,n.abortController,this.map._refreshExpiredTiles);if(delete n.abortController,n.aborted)return void(n.state="unloaded");if(f&&f.data){let b=f.data;this.map._refreshExpiredTiles&&f.cacheControl&&f.expires&&n.setExpiryData({cacheControl:f.cacheControl,expires:f.expires});let L=o.b(b)&&o.S()?b:yield this.readImageNow(b),E={type:this.type,uid:n.uid,source:this.id,rawImageData:L,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!n.actor||n.state==="expired"){n.actor=this.dispatcher.getActor();let H=yield n.actor.sendAsync({type:"loadDEMTile",data:E});n.dem=H,n.needsHillshadePrepare=!0,n.needsTerrainPrepare=!0,n.state="loaded"}}}catch(f){if(delete n.abortController,n.aborted)n.state="unloaded";else if(f)throw n.state="errored",f}})}readImageNow(n){return o._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&o.U()){let c=n.width+2,p=n.height+2;try{return new o.R({width:c,height:p},yield o.V(n,-1,-1,c,p))}catch{}}return v.getImageData(n,1)})}_getNeighboringTiles(n){let c=n.canonical,p=Math.pow(2,c.z),f=(c.x-1+p)%p,b=c.x===0?n.wrap-1:n.wrap,L=(c.x+1+p)%p,E=c.x+1===p?n.wrap+1:n.wrap,H={};return H[new o.Q(n.overscaledZ,b,c.z,f,c.y).key]={backfilled:!1},H[new o.Q(n.overscaledZ,E,c.z,L,c.y).key]={backfilled:!1},c.y>0&&(H[new o.Q(n.overscaledZ,b,c.z,f,c.y-1).key]={backfilled:!1},H[new o.Q(n.overscaledZ,n.wrap,c.z,c.x,c.y-1).key]={backfilled:!1},H[new o.Q(n.overscaledZ,E,c.z,L,c.y-1).key]={backfilled:!1}),c.y+10&&o.e(b,{resourceTiming:f}),this.fire(new o.k("data",Object.assign(Object.assign({},b),{sourceDataType:"metadata"}))),this.fire(new o.k("data",Object.assign(Object.assign({},b),{sourceDataType:"content"})))}catch(p){if(this._pendingLoads--,this._removed)return void this.fire(new o.k("dataabort",{dataType:"source"}));this.fire(new o.j(p))}})}loaded(){return this._pendingLoads===0}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.actor?"reloadTile":"loadTile";n.actor=this.actor;let p={type:this.type,uid:n.uid,tileID:n.tileID,zoom:n.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};n.abortController=new AbortController;let f=yield this.actor.sendAsync({type:c,data:p},n.abortController);delete n.abortController,n.unloadVectorData(),n.aborted||n.loadVectorData(f,this.map.painter,c==="reloadTile")})}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController),n.aborted=!0})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.unloadVectorData(),yield this.actor.sendAsync({type:"removeTile",data:{uid:n.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"removeSource",data:{type:this.type,source:this.id}})}serialize(){return o.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Ee=o.X([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ne extends o.E{constructor(n,c,p,f){super(),this.id=n,this.dispatcher=p,this.coordinates=c.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(f),this.options=c}load(n){return o._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{let c=yield O.getImage(this.map._requestManager.transformRequest(this.url,tt.Image),this._request);this._request=null,this._loaded=!0,c&&c.data&&(this.image=c.data,n&&(this.coordinates=n),this._finishLoading())}catch(c){this._request=null,this.fire(new o.j(c))}})}loaded(){return this._loaded}updateImage(n){return n.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=n.url,this.load(n.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(n){this.map=n,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(n){this.coordinates=n;let c=n.map(o.Y.fromLngLat);this.tileID=function(f){let b=1/0,L=1/0,E=-1/0,H=-1/0;for(let F of f)b=Math.min(b,F.x),L=Math.min(L,F.y),E=Math.max(E,F.x),H=Math.max(H,F.y);let h=Math.max(E-b,H-L),I=Math.max(0,Math.floor(-Math.log(h)/Math.LN2)),_=Math.pow(2,I);return new o.a0(I,Math.floor((b+E)/2*_),Math.floor((L+H)/2*_))}(c),this.minzoom=this.maxzoom=this.tileID.z;let p=c.map(f=>this.tileID.getTilePoint(f)._round());return this._boundsArray=new o.Z,this._boundsArray.emplaceBack(p[0].x,p[0].y,0,0),this._boundsArray.emplaceBack(p[1].x,p[1].y,o.W,0),this._boundsArray.emplaceBack(p[3].x,p[3].y,0,o.W),this._boundsArray.emplaceBack(p[2].x,p[2].y,o.W,o.W),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new o.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let n=this.map.painter.context,c=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture||(this.texture=new qt(n,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(let f in this.tiles){let b=this.tiles[f];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,p=!0)}p&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(n){return o._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(n.tileID.canonical)?(this.tiles[String(n.tileID.wrap)]=n,n.buckets={}):n.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Je extends Ne{constructor(n,c,p,f){super(n,c,p,f),this.roundZoom=!0,this.type="video",this.options=c}load(){return o._(this,void 0,void 0,function*(){this._loaded=!1;let n=this.options;this.urls=[];for(let c of n.urls)this.urls.push(this.map._requestManager.transformRequest(c,tt.Source).url);try{let c=yield o.a2(this.urls);if(this._loaded=!0,!c)return;this.video=c,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(c){this.fire(new o.j(c))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(n){if(this.video){let c=this.video.seekable;nc.end(0)?this.fire(new o.j(new o.a1(`sources.${this.id}`,null,`Playback for this video can be set only between the ${c.start(0)} and ${c.end(0)}-second mark.`))):this.video.currentTime=n}}getVideo(){return this.video}onAdd(n){this.map||(this.map=n,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let n=this.map.painter.context,c=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,this.video)):(this.texture=new qt(n,this.video,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(let f in this.tiles){let b=this.tiles[f];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,p=!0)}p&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ze extends Ne{constructor(n,c,p,f){super(n,c,p,f),c.coordinates?Array.isArray(c.coordinates)&&c.coordinates.length===4&&!c.coordinates.some(b=>!Array.isArray(b)||b.length!==2||b.some(L=>typeof L!="number"))||this.fire(new o.j(new o.a1(`sources.${n}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new o.j(new o.a1(`sources.${n}`,null,'missing required property "coordinates"'))),c.animate&&typeof c.animate!="boolean"&&this.fire(new o.j(new o.a1(`sources.${n}`,null,'optional "animate" property must be a boolean value'))),c.canvas?typeof c.canvas=="string"||c.canvas instanceof HTMLCanvasElement||this.fire(new o.j(new o.a1(`sources.${n}`,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 o.j(new o.a1(`sources.${n}`,null,'missing required property "canvas"'))),this.options=c,this.animate=c.animate===void 0||c.animate}load(){return o._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new o.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(n){this.map=n,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let n=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,n=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,n=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let c=this.map.painter.context,p=c.gl;this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture?(n||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new qt(c,this.canvas,p.RGBA,{premultiply:!0});let f=!1;for(let b in this.tiles){let L=this.tiles[b];L.state!=="loaded"&&(L.state="loaded",L.texture=this.texture,f=!0)}f&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let n of[this.canvas.width,this.canvas.height])if(isNaN(n)||n<=0)return!0;return!1}}let ui={},hi=y=>{switch(y){case"geojson":return Ue;case"image":return Ne;case"raster":return Rt;case"raster-dem":return Li;case"vector":return xt;case"video":return Je;case"canvas":return ze}return ui[y]},Ei="RTLPluginLoaded";class Pi extends o.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=he()}_syncState(n){return this.status=n,this.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:n,pluginURL:this.url}).catch(c=>{throw this.status="error",c})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(n){return o._(this,arguments,void 0,function*(c,p=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=v.resolveURL(c),!this.url)throw new Error(`requested url ${c} is invalid`);if(this.status==="unavailable"){if(!p)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return o._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new o.k(Ei))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Ie=null;function Oi(){return Ie||(Ie=new Pi),Ie}class mi{constructor(n,c){this.timeAdded=0,this.fadeEndTime=0,this.tileID=n,this.uid=o.a3(),this.uses=0,this.tileSize=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(n){let c=n+this.timeAdded;cb.getLayer(h)).filter(Boolean);if(H.length!==0){E.layers=H,E.stateDependentLayerIds&&(E.stateDependentLayers=E.stateDependentLayerIds.map(h=>H.filter(I=>I.id===h)[0]));for(let h of H)L[h.id]=E}}return L}(n.buckets,c.style),this.hasSymbolBuckets=!1;for(let f in this.buckets){let b=this.buckets[f];if(b instanceof o.a5){if(this.hasSymbolBuckets=!0,!p)break;b.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let f in this.buckets){let b=this.buckets[f];if(b instanceof o.a5&&b.hasRTLText){this.hasRTLText=!0,Oi().lazyLoad();break}}this.queryPadding=0;for(let f in this.buckets){let b=this.buckets[f];this.queryPadding=Math.max(this.queryPadding,c.style.getLayer(f).queryRadius(b))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage)}else this.collisionBoxArray=new o.a4}unloadVectorData(){for(let n in this.buckets)this.buckets[n].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(n){return this.buckets[n.id]}upload(n){for(let p in this.buckets){let f=this.buckets[p];f.uploadPending()&&f.upload(n)}let c=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new qt(n,this.imageAtlas.image,c.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new qt(n,this.glyphAtlasImage,c.ALPHA),this.glyphAtlasImage=null)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,c,p,f,b,L,E,H,h,I){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:f,cameraQueryGeometry:b,scale:L,tileSize:this.tileSize,pixelPosMatrix:I,transform:H,params:E,queryPadding:this.queryPadding*h},n,c,p):{}}querySourceFeatures(n,c){let p=this.latestFeatureIndex;if(!p||!p.rawTileData)return;let f=p.loadVTLayers(),b=c&&c.sourceLayer?c.sourceLayer:"",L=f._geojsonTileLayer||f[b];if(!L)return;let E=o.a6(c&&c.filter),{z:H,x:h,y:I}=this.tileID.canonical,_={z:H,x:h,y:I};for(let F=0;Fp)f=!1;else if(c)if(this.expirationTime{this.remove(n,b)},p)),this.data[f].push(b),this.order.push(f),this.order.length>this.max){let L=this._getAndRemoveByKey(this.order[0]);L&&this.onRemove(L)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){let c=this.data[n].shift();return c.timeout&&clearTimeout(c.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),c.value}getByKey(n){let c=this.data[n];return c?c[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,c){if(!this.has(n))return this;let p=n.wrapped().key,f=c===void 0?0:this.data[p].indexOf(c),b=this.data[p][f];return this.data[p].splice(f,1),b.timeout&&clearTimeout(b.timeout),this.data[p].length===0&&delete this.data[p],this.onRemove(b.value),this.order.splice(this.order.indexOf(p),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){let c=this._getAndRemoveByKey(this.order[0]);c&&this.onRemove(c)}return this}filter(n){let c=[];for(let p in this.data)for(let f of this.data[p])n(f.value)||c.push(f);for(let p of c)this.remove(p.value.tileID,p)}}class We{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(n,c,p){let f=String(c);if(this.stateChanges[n]=this.stateChanges[n]||{},this.stateChanges[n][f]=this.stateChanges[n][f]||{},o.e(this.stateChanges[n][f],p),this.deletedStates[n]===null){this.deletedStates[n]={};for(let b in this.state[n])b!==f&&(this.deletedStates[n][b]=null)}else if(this.deletedStates[n]&&this.deletedStates[n][f]===null){this.deletedStates[n][f]={};for(let b in this.state[n][f])p[b]||(this.deletedStates[n][f][b]=null)}else for(let b in p)this.deletedStates[n]&&this.deletedStates[n][f]&&this.deletedStates[n][f][b]===null&&delete this.deletedStates[n][f][b]}removeFeatureState(n,c,p){if(this.deletedStates[n]===null)return;let f=String(c);if(this.deletedStates[n]=this.deletedStates[n]||{},p&&c!==void 0)this.deletedStates[n][f]!==null&&(this.deletedStates[n][f]=this.deletedStates[n][f]||{},this.deletedStates[n][f][p]=null);else if(c!==void 0)if(this.stateChanges[n]&&this.stateChanges[n][f])for(p in this.deletedStates[n][f]={},this.stateChanges[n][f])this.deletedStates[n][f][p]=null;else this.deletedStates[n][f]=null;else this.deletedStates[n]=null}getState(n,c){let p=String(c),f=o.e({},(this.state[n]||{})[p],(this.stateChanges[n]||{})[p]);if(this.deletedStates[n]===null)return{};if(this.deletedStates[n]){let b=this.deletedStates[n][c];if(b===null)return{};for(let L in b)delete f[L]}return f}initializeTileState(n,c){n.setFeatureState(this.state,c)}coalesceChanges(n,c){let p={};for(let f in this.stateChanges){this.state[f]=this.state[f]||{};let b={};for(let L in this.stateChanges[f])this.state[f][L]||(this.state[f][L]={}),o.e(this.state[f][L],this.stateChanges[f][L]),b[L]=this.state[f][L];p[f]=b}for(let f in this.deletedStates){this.state[f]=this.state[f]||{};let b={};if(this.deletedStates[f]===null)for(let L in this.state[f])b[L]={},this.state[f][L]={};else for(let L in this.deletedStates[f]){if(this.deletedStates[f][L]===null)this.state[f][L]={};else for(let E of Object.keys(this.deletedStates[f][L]))delete this.state[f][L][E];b[L]=this.state[f][L]}p[f]=p[f]||{},o.e(p[f],b)}if(this.stateChanges={},this.deletedStates={},Object.keys(p).length!==0)for(let f in n)n[f].setFeatureState(p,c)}}class Se extends o.E{constructor(n,c,p){super(),this.id=n,this.dispatcher=p,this.on("data",f=>{f.dataType==="source"&&f.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&f.dataType==="source"&&f.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((f,b,L,E)=>{let H=new(hi(b.type))(f,b,L,E);if(H.id!==f)throw new Error(`Expected Source id to be ${f} instead of ${H.id}`);return H})(n,c,p,this),this._tiles={},this._cache=new Vi(0,f=>this._unloadTile(f)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new We,this._didEmitContent=!1,this._updated=!1}onAdd(n){this.map=n,this._maxTileCacheSize=n?n._maxTileCacheSize:null,this._maxTileCacheZoomLevels=n?n._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(n)}onRemove(n){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(n)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let n in this._tiles){let c=this._tiles[n];if(c.state!=="loaded"&&c.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(n,c,p){return o._(this,void 0,void 0,function*(){try{yield this._source.loadTile(n),this._tileLoaded(n,c,p)}catch(f){n.state="errored",f.status!==404?this._source.fire(new o.j(f,{tile:n})):this.update(this.transform,this.terrain)}})}_unloadTile(n){this._source.unloadTile&&this._source.unloadTile(n)}_abortTile(n){this._source.abortTile&&this._source.abortTile(n),this._source.fire(new o.k("dataabort",{tile:n,coord:n.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(n){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let c in this._tiles){let p=this._tiles[c];p.upload(n),p.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(n=>n.tileID).sort($e).map(n=>n.key)}getRenderableIds(n){let c=[];for(let p in this._tiles)this._isIdRenderable(p,n)&&c.push(this._tiles[p]);return n?c.sort((p,f)=>{let b=p.tileID,L=f.tileID,E=new o.P(b.canonical.x,b.canonical.y)._rotate(this.transform.angle),H=new o.P(L.canonical.x,L.canonical.y)._rotate(this.transform.angle);return b.overscaledZ-L.overscaledZ||H.y-E.y||H.x-E.x}).map(p=>p.tileID.key):c.map(p=>p.tileID).sort($e).map(p=>p.key)}hasRenderableParent(n){let c=this.findLoadedParent(n,0);return!!c&&this._isIdRenderable(c.tileID.key)}_isIdRenderable(n,c){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(c||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(n,"reloading")}}_reloadTile(n,c){return o._(this,void 0,void 0,function*(){let p=this._tiles[n];p&&(p.state!=="loading"&&(p.state=c),yield this._loadTile(p,n,c))})}_tileLoaded(n,c,p){n.timeAdded=v.now(),p==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(c,n),this.getSource().type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),n.aborted||this._source.fire(new o.k("data",{dataType:"source",tile:n,coord:n.tileID}))}_backfillDEM(n){let c=this.getRenderableIds();for(let f=0;f1||(Math.abs(L)>1&&(Math.abs(L+H)===1?L+=H:Math.abs(L-H)===1&&(L-=H)),b.dem&&f.dem&&(f.dem.backfillBorder(b.dem,L,E),f.neighboringTiles&&f.neighboringTiles[h]&&(f.neighboringTiles[h].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,c,p,f){for(let b in this._tiles){let L=this._tiles[b];if(f[b]||!L.hasData()||L.tileID.overscaledZ<=c||L.tileID.overscaledZ>p)continue;let E=L.tileID;for(;L&&L.tileID.overscaledZ>c+1;){let h=L.tileID.scaledTo(L.tileID.overscaledZ-1);L=this._tiles[h.key],L&&L.hasData()&&(E=h)}let H=E;for(;H.overscaledZ>c;)if(H=H.scaledTo(H.overscaledZ-1),n[H.key]){f[E.key]=E;break}}}findLoadedParent(n,c){if(n.key in this._loadedParentTiles){let p=this._loadedParentTiles[n.key];return p&&p.tileID.overscaledZ>=c?p:null}for(let p=n.overscaledZ-1;p>=c;p--){let f=n.scaledTo(p),b=this._getLoadedTile(f);if(b)return b}}_getLoadedTile(n){let c=this._tiles[n.key];return c&&c.hasData()?c:this._cache.getByKey(n.wrapped().key)}updateCacheSize(n){let c=Math.ceil(n.width/this._source.tileSize)+1,p=Math.ceil(n.height/this._source.tileSize)+1,f=Math.floor(c*p*(this._maxTileCacheZoomLevels===null?o.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),b=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,f):f;this._cache.setMaxSize(b)}handleWrapJump(n){let c=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,c){let p={};for(let f in this._tiles){let b=this._tiles[f];b.tileID=b.tileID.unwrapTo(b.tileID.wrap+c),p[b.tileID.key]=b}this._tiles=p;for(let f in this._timers)clearTimeout(this._timers[f]),delete this._timers[f];for(let f in this._tiles)this._setTileReloadTimer(f,this._tiles[f])}}update(n,c){if(this.transform=n,this.terrain=c,!this._sourceLoaded||this._paused)return;let p;this.updateCacheSize(n),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?p=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(I=>new o.Q(I.canonical.z,I.wrap,I.canonical.z,I.canonical.x,I.canonical.y)):(p=n.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:c}),this._source.hasTile&&(p=p.filter(I=>this._source.hasTile(I)))):p=[];let f=n.coveringZoomLevel(this._source),b=Math.max(f-Se.maxOverzooming,this._source.minzoom),L=Math.max(f+Se.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let I={};for(let _ of p)if(_.canonical.z>this._source.minzoom){let F=_.scaledTo(_.canonical.z-1);I[F.key]=F;let R=_.scaledTo(Math.max(this._source.minzoom,Math.min(_.canonical.z,5)));I[R.key]=R}p=p.concat(Object.values(I))}let E=p.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,E&&this.fire(new o.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));let H=this._updateRetainedTiles(p,f);if(di(this._source.type)){let I={},_={},F=Object.keys(H),R=v.now();for(let Z of F){let N=H[Z],P=this._tiles[Z];if(!P||P.fadeEndTime!==0&&P.fadeEndTime<=R)continue;let V=this.findLoadedParent(N,b);V&&(this._addTile(V.tileID),I[V.tileID.key]=V.tileID),_[Z]=N}this._retainLoadedChildren(_,f,L,H);for(let Z in I)H[Z]||(this._coveredTiles[Z]=!0,H[Z]=I[Z]);if(c){let Z={},N={};for(let P of p)this._tiles[P.key].hasData()?Z[P.key]=P:N[P.key]=P;for(let P in N){let V=N[P].children(this._source.maxzoom);this._tiles[V[0].key]&&this._tiles[V[1].key]&&this._tiles[V[2].key]&&this._tiles[V[3].key]&&(Z[V[0].key]=H[V[0].key]=V[0],Z[V[1].key]=H[V[1].key]=V[1],Z[V[2].key]=H[V[2].key]=V[2],Z[V[3].key]=H[V[3].key]=V[3],delete N[P])}for(let P in N){let V=this.findLoadedParent(N[P],this._source.minzoom);if(V){Z[V.tileID.key]=H[V.tileID.key]=V.tileID;for(let X in Z)Z[X].isChildOf(V.tileID)&&delete Z[X]}}for(let P in this._tiles)Z[P]||(this._coveredTiles[P]=!0)}}for(let I in H)this._tiles[I].clearFadeHold();let h=o.ab(this._tiles,H);for(let I of h){let _=this._tiles[I];_.hasSymbolBuckets&&!_.holdingForFade()?_.setHoldDuration(this.map._fadeDuration):_.hasSymbolBuckets&&!_.symbolFadeFinished()||this._removeTile(I)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(let n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(n)}_updateRetainedTiles(n,c){let p={},f={},b=Math.max(c-Se.maxOverzooming,this._source.minzoom),L=Math.max(c+Se.maxUnderzooming,this._source.minzoom),E={};for(let H of n){let h=this._addTile(H);p[H.key]=H,h.hasData()||cthis._source.maxzoom){let _=H.children(this._source.maxzoom)[0],F=this.getTile(_);if(F&&F.hasData()){p[_.key]=_;continue}}else{let _=H.children(this._source.maxzoom);if(p[_[0].key]&&p[_[1].key]&&p[_[2].key]&&p[_[3].key])continue}let I=h.wasRequested();for(let _=H.overscaledZ-1;_>=b;--_){let F=H.scaledTo(_);if(f[F.key])break;if(f[F.key]=!0,h=this.getTile(F),!h&&I&&(h=this._addTile(F)),h){let R=h.hasData();if((I||R)&&(p[F.key]=F),I=h.wasRequested(),R)break}}}return p}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let n in this._tiles){let c=[],p,f=this._tiles[n].tileID;for(;f.overscaledZ>0;){if(f.key in this._loadedParentTiles){p=this._loadedParentTiles[f.key];break}c.push(f.key);let b=f.scaledTo(f.overscaledZ-1);if(p=this._getLoadedTile(b),p)break;f=b}for(let b of c)this._loadedParentTiles[b]=p}}_addTile(n){let c=this._tiles[n.key];if(c)return c;c=this._cache.getAndRemove(n),c&&(this._setTileReloadTimer(n.key,c),c.tileID=n,this._state.initializeTileState(c,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,c)));let p=c;return c||(c=new mi(n,this._source.tileSize*n.overscaleFactor()),this._loadTile(c,n.key,c.state)),c.uses++,this._tiles[n.key]=c,p||this._source.fire(new o.k("dataloading",{tile:c,coord:c.tileID,dataType:"source"})),c}_setTileReloadTimer(n,c){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);let p=c.getExpiryTimeout();p&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},p))}_removeTile(n){let c=this._tiles[n];c&&(c.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),c.uses>0||(c.hasData()&&c.state!=="reloading"?this._cache.add(c.tileID,c,c.getExpiryTimeout()):(c.aborted=!0,this._abortTile(c),this._unloadTile(c))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let n in this._tiles)this._removeTile(n);this._cache.reset()}tilesIn(n,c,p){let f=[],b=this.transform;if(!b)return f;let L=p?b.getCameraQueryGeometry(n):n,E=n.map(Z=>b.pointCoordinate(Z,this.terrain)),H=L.map(Z=>b.pointCoordinate(Z,this.terrain)),h=this.getIds(),I=1/0,_=1/0,F=-1/0,R=-1/0;for(let Z of H)I=Math.min(I,Z.x),_=Math.min(_,Z.y),F=Math.max(F,Z.x),R=Math.max(R,Z.y);for(let Z=0;Z=0&&J[1].y+X>=0){let ot=E.map(ut=>P.getTilePoint(ut)),dt=H.map(ut=>P.getTilePoint(ut));f.push({tile:N,tileID:P,queryGeometry:ot,cameraQueryGeometry:dt,scale:V})}}return f}getVisibleCoordinates(n){let c=this.getRenderableIds(n).map(p=>this._tiles[p].tileID);for(let p of c)p.posMatrix=this.transform.calculatePosMatrix(p.toUnwrapped());return c}hasTransition(){if(this._source.hasTransition())return!0;if(di(this._source.type)){let n=v.now();for(let c in this._tiles)if(this._tiles[c].fadeEndTime>=n)return!0}return!1}setFeatureState(n,c,p){this._state.updateState(n=n||"_geojsonTileLayer",c,p)}removeFeatureState(n,c,p){this._state.removeFeatureState(n=n||"_geojsonTileLayer",c,p)}getFeatureState(n,c){return this._state.getState(n=n||"_geojsonTileLayer",c)}setDependencies(n,c,p){let f=this._tiles[n];f&&f.setDependencies(c,p)}reloadTilesForDependencies(n,c){for(let p in this._tiles)this._tiles[p].hasDependency(n,c)&&this._reloadTile(p,"reloading");this._cache.filter(p=>!p.hasDependency(n,c))}}function $e(y,n){let c=Math.abs(2*y.wrap)-+(y.wrap<0),p=Math.abs(2*n.wrap)-+(n.wrap<0);return y.overscaledZ-n.overscaledZ||p-c||n.canonical.y-y.canonical.y||n.canonical.x-y.canonical.x}function di(y){return y==="raster"||y==="image"||y==="video"}Se.maxOverzooming=10,Se.maxUnderzooming=3;class Zi{constructor(n,c){this.reset(n,c)}reset(n,c){this.points=n||[],this._distances=[0];for(let p=1;p0?(f-L)/E:0;return this.points[b].mult(1-H).add(this.points[c].mult(H))}}function qi(y,n){let c=!0;return y==="always"||y!=="never"&&n!=="never"||(c=!1),c}class vi{constructor(n,c,p){let f=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(n/p),this.yCellCount=Math.ceil(c/p);for(let L=0;Lthis.width||f<0||c>this.height)return[];let H=[];if(n<=0&&c<=0&&this.width<=p&&this.height<=f){if(b)return[{key:null,x1:n,y1:c,x2:p,y2:f}];for(let h=0;h0}hitTestCircle(n,c,p,f,b){let L=n-p,E=n+p,H=c-p,h=c+p;if(E<0||L>this.width||h<0||H>this.height)return!1;let I=[];return this._forEachCell(L,H,E,h,this._queryCellCircle,I,{hitTest:!0,overlapMode:f,circle:{x:n,y:c,radius:p},seenUids:{box:{},circle:{}}},b),I.length>0}_queryCell(n,c,p,f,b,L,E,H){let{seenUids:h,hitTest:I,overlapMode:_}=E,F=this.boxCells[b];if(F!==null){let Z=this.bboxes;for(let N of F)if(!h.box[N]){h.box[N]=!0;let P=4*N,V=this.boxKeys[N];if(n<=Z[P+2]&&c<=Z[P+3]&&p>=Z[P+0]&&f>=Z[P+1]&&(!H||H(V))&&(!I||!qi(_,V.overlapMode))&&(L.push({key:V,x1:Z[P],y1:Z[P+1],x2:Z[P+2],y2:Z[P+3]}),I))return!0}}let R=this.circleCells[b];if(R!==null){let Z=this.circles;for(let N of R)if(!h.circle[N]){h.circle[N]=!0;let P=3*N,V=this.circleKeys[N];if(this._circleAndRectCollide(Z[P],Z[P+1],Z[P+2],n,c,p,f)&&(!H||H(V))&&(!I||!qi(_,V.overlapMode))){let X=Z[P],J=Z[P+1],ot=Z[P+2];if(L.push({key:V,x1:X-ot,y1:J-ot,x2:X+ot,y2:J+ot}),I)return!0}}}return!1}_queryCellCircle(n,c,p,f,b,L,E,H){let{circle:h,seenUids:I,overlapMode:_}=E,F=this.boxCells[b];if(F!==null){let Z=this.bboxes;for(let N of F)if(!I.box[N]){I.box[N]=!0;let P=4*N,V=this.boxKeys[N];if(this._circleAndRectCollide(h.x,h.y,h.radius,Z[P+0],Z[P+1],Z[P+2],Z[P+3])&&(!H||H(V))&&!qi(_,V.overlapMode))return L.push(!0),!0}}let R=this.circleCells[b];if(R!==null){let Z=this.circles;for(let N of R)if(!I.circle[N]){I.circle[N]=!0;let P=3*N,V=this.circleKeys[N];if(this._circlesCollide(Z[P],Z[P+1],Z[P+2],h.x,h.y,h.radius)&&(!H||H(V))&&!qi(_,V.overlapMode))return L.push(!0),!0}}}_forEachCell(n,c,p,f,b,L,E,H){let h=this._convertToXCellCoord(n),I=this._convertToYCellCoord(c),_=this._convertToXCellCoord(p),F=this._convertToYCellCoord(f);for(let R=h;R<=_;R++)for(let Z=I;Z<=F;Z++)if(b.call(this,n,c,p,f,this.xCellCount*Z+R,L,E,H))return}_convertToXCellCoord(n){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(n*this.xScale)))}_convertToYCellCoord(n){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(n*this.yScale)))}_circlesCollide(n,c,p,f,b,L){let E=f-n,H=b-c,h=p+L;return h*h>E*E+H*H}_circleAndRectCollide(n,c,p,f,b,L,E){let H=(L-f)/2,h=Math.abs(n-(f+H));if(h>H+p)return!1;let I=(E-b)/2,_=Math.abs(c-(b+I));if(_>I+p)return!1;if(h<=H||_<=I)return!0;let F=h-H,R=_-I;return F*F+R*R<=p*p}}function tr(y,n,c,p,f){let b=o.F();return n?(o.J(b,b,[1/f,1/f,1]),c||o.ad(b,b,p.angle)):o.K(b,p.labelPlaneMatrix,y),b}function Lr(y,n,c,p,f){if(n){let b=o.ae(y);return o.J(b,b,[f,f,1]),c||o.ad(b,b,-p.angle),b}return p.glCoordMatrix}function ft(y,n,c){let p;c?(p=[y.x,y.y,c(y.x,y.y),1],o.af(p,p,n)):(p=[y.x,y.y,0,1],oi(p,p,n));let f=p[3];return{point:new o.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f}}function Y(y,n){return .5+y/n*.5}function q(y,n){let c=y[0]/y[3],p=y[1]/y[3];return c>=-n[0]&&c<=n[0]&&p>=-n[1]&&p<=n[1]}function rt(y,n,c,p,f,b,L,E,H,h){let I=p?y.textSizeData:y.iconSizeData,_=o.ag(I,c.transform.zoom),F=[256/c.width*2+1,256/c.height*2+1],R=p?y.text.dynamicLayoutVertexArray:y.icon.dynamicLayoutVertexArray;R.clear();let Z=y.lineVertexArray,N=p?y.text.placedSymbolArray:y.icon.placedSymbolArray,P=c.transform.width/c.transform.height,V=!1;for(let X=0;XMath.abs(c.x-n.x)*p?{useVertical:!0}:(y===o.ah.vertical?n.yc.x)?{needsFlipping:!0}:null}function zt(y,n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N){let P=n/24,V=y.lineOffsetX*P,X=y.lineOffsetY*P,J;if(y.numGlyphs>1){let ot=y.glyphStartIndex+y.numGlyphs,dt=y.lineStartIndex,ut=y.lineStartIndex+y.lineLength,Gt=ht(P,E,V,X,c,I,_,y,H,b,F,Z,N);if(!Gt)return{notEnoughRoom:!0};let Pt=ft(Gt.first.point,L,N).point,gt=ft(Gt.last.point,L,N).point;if(p&&!c){let Ct=Zt(y.writingMode,Pt,gt,R);if(Ct)return Ct}J=[Gt.first];for(let Ct=y.glyphStartIndex+1;Ct0?Pt.point:Xt(_,Gt,dt,1,f,N),Ct=Zt(y.writingMode,dt,gt,R);if(Ct)return Ct}let ot=pe(P*E.getoffsetX(y.glyphStartIndex),V,X,c,I,_,y.segment,y.lineStartIndex,y.lineStartIndex+y.lineLength,H,b,F,Z,N);if(!ot)return{notEnoughRoom:!0};J=[ot]}for(let ot of J)o.aj(h,ot.point,ot.angle);return{}}function Xt(y,n,c,p,f,b){let L=ft(y.add(y.sub(n)._unit()),f,b).point,E=c.sub(L);return c.add(E._mult(p/E.mag()))}function Mt(y,n){let{projectionCache:c,lineVertexArray:p,labelPlaneMatrix:f,tileAnchorPoint:b,distanceFromAnchor:L,getElevation:E,previousVertex:H,direction:h,absOffsetX:I}=n;if(c.projections[y])return c.projections[y];let _=new o.P(p.getx(y),p.gety(y)),F=ft(_,f,E);if(F.signedDistanceFromCamera>0)return c.projections[y]=F.point,F.point;let R=y-h;return Xt(L===0?b:new o.P(p.getx(R),p.gety(R)),_,H,I-L+1,f,E)}function re(y,n,c){return y._unit()._perp()._mult(n*c)}function ce(y,n,c,p,f,b,L,E){let{projectionCache:H,direction:h}=E;if(H.offsets[y])return H.offsets[y];let I=c.add(n);if(y+h=f)return H.offsets[y]=I,I;let _=Mt(y+h,E),F=re(_.sub(c),L,h),R=c.add(F),Z=_.add(F);return H.offsets[y]=o.ak(b,I,R,Z)||I,H.offsets[y]}function pe(y,n,c,p,f,b,L,E,H,h,I,_,F,R){let Z=p?y-n:y+n,N=Z>0?1:-1,P=0;p&&(N*=-1,P=Math.PI),N<0&&(P+=Math.PI);let V,X,J=N>0?E+L:E+L+1,ot=f,dt=f,ut=0,Gt=0,Pt=Math.abs(Z),gt=[],Ct;for(;ut+Gt<=Pt;){if(J+=N,J=H)return null;ut+=Gt,dt=ot,X=V;let jt={projectionCache:_,lineVertexArray:h,labelPlaneMatrix:I,tileAnchorPoint:b,distanceFromAnchor:ut,getElevation:R,previousVertex:dt,direction:N,absOffsetX:Pt};if(ot=Mt(J,jt),c===0)gt.push(dt),Ct=ot.sub(dt);else{let Fe,ke=ot.sub(dt);Fe=ke.mag()===0?re(Mt(J+N,jt).sub(ot),c,N):re(ke,c,N),X||(X=dt.add(Fe)),V=ce(J,Fe,ot,E,H,X,c,jt),gt.push(X),Ct=V.sub(X)}Gt=Ct.mag()}let ee=Ct._mult((Pt-ut)/Gt)._add(X||dt),ge=P+Math.atan2(ot.y-dt.y,ot.x-dt.x);return gt.push(ee),{point:ee,angle:F?ge:0,path:gt}}let me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Xe(y,n){for(let c=0;c=1;ci--)ke.push(jt.path[ci]);for(let ci=1;cift(pi,H,Z));ke=ci.some(pi=>pi.signedDistanceFromCamera<=0)?[]:ci.map(pi=>pi.point)}let xe=[];if(ke.length>0){let ci=ke[0].clone(),pi=ke[0].clone();for(let Mi=1;Mi=Ct.x&&pi.x<=ee.x&&ci.y>=Ct.y&&pi.y<=ee.y?[ke]:pi.xee.x||pi.yee.y?[]:o.al([ke],Ct.x,Ct.y,ee.x,ee.y)}for(let ci of xe){ge.reset(ci,.25*gt);let pi=0;pi=ge.length<=.5*gt?1:Math.ceil(ge.paddedLength/Ye)+1;for(let Mi=0;Mi=this.screenRightBoundary||fthis.screenBottomBoundary}isInsideGrid(n,c,p,f){return p>=0&&n=0&&cp.collisionGroupID===c}}return this.collisionGroups[n]}}function Tr(y,n,c,p,f){let{horizontalAlign:b,verticalAlign:L}=o.at(y);return new o.P(-(b-.5)*n+p[0]*f,-(L-.5)*c+p[1]*f)}function Dt(y,n,c,p,f,b){let{x1:L,x2:E,y1:H,y2:h,anchorPointX:I,anchorPointY:_}=y,F=new o.P(n,c);return p&&F._rotate(f?b:-b),{x1:L+F.x,y1:H+F.y,x2:E+F.x,y2:h+F.y,anchorPointX:I,anchorPointY:_}}class Ke{constructor(n,c,p,f,b){this.transform=n.clone(),this.terrain=c,this.collisionIndex=new Ni(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=p,this.retainedQueryData={},this.collisionGroups=new br(f),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(n,c,p,f){let b=p.getBucket(c),L=p.latestFeatureIndex;if(!b||!L||c.id!==b.layerIds[0])return;let E=p.collisionBoxArray,H=b.layers[0].layout,h=Math.pow(2,this.transform.zoom-p.tileID.overscaledZ),I=p.tileSize/o.W,_=this.transform.calculatePosMatrix(p.tileID.toUnwrapped()),F=H.get("text-pitch-alignment")==="map",R=H.get("text-rotation-alignment")==="map",Z=Qi(p,1,this.transform.zoom),N=tr(_,F,R,this.transform,Z),P=null;if(F){let X=Lr(_,F,R,this.transform,Z);P=o.K([],this.transform.labelPlaneMatrix,X)}this.retainedQueryData[b.bucketInstanceId]=new fr(b.bucketInstanceId,L,b.sourceLayerIndex,b.index,p.tileID);let V={bucket:b,layout:H,posMatrix:_,textLabelPlaneMatrix:N,labelToScreenMatrix:P,scale:h,textPixelRatio:I,holdingForFade:p.holdingForFade(),collisionBoxArray:E,partiallyEvaluatedTextSize:o.ag(b.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(b.sourceID)};if(f)for(let X of b.sortKeyRanges){let{sortKey:J,symbolInstanceStart:ot,symbolInstanceEnd:dt}=X;n.push({sortKey:J,symbolInstanceStart:ot,symbolInstanceEnd:dt,parameters:V})}else n.push({symbolInstanceStart:0,symbolInstanceEnd:b.symbolInstances.length,parameters:V})}attemptAnchorPlacement(n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N,P){let V=o.ap[n.textAnchor],X=[n.textOffset0,n.textOffset1],J=Tr(V,p,f,X,b),ot=this.collisionIndex.placeCollisionBox(Dt(c,J.x,J.y,L,E,this.transform.angle),_,H,h,I.predicate,P);if((!N||this.collisionIndex.placeCollisionBox(Dt(N,J.x,J.y,L,E,this.transform.angle),_,H,h,I.predicate,P).box.length!==0)&&ot.box.length>0){let dt;if(this.prevPlacement&&this.prevPlacement.variableOffsets[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID].text&&(dt=this.prevPlacement.variableOffsets[F.crossTileID].anchor),F.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[F.crossTileID]={textOffset:X,width:p,height:f,anchor:V,textBoxScale:b,prevAnchor:dt},this.markUsedJustification(R,V,F,Z),R.allowVerticalPlacement&&(this.markUsedOrientation(R,Z,F),this.placedOrientations[F.crossTileID]=Z),{shift:J,placedGlyphBoxes:ot}}}placeLayerBucketPart(n,c,p){let{bucket:f,layout:b,posMatrix:L,textLabelPlaneMatrix:E,labelToScreenMatrix:H,textPixelRatio:h,holdingForFade:I,collisionBoxArray:_,partiallyEvaluatedTextSize:F,collisionGroup:R}=n.parameters,Z=b.get("text-optional"),N=b.get("icon-optional"),P=o.aq(b,"text-overlap","text-allow-overlap"),V=P==="always",X=o.aq(b,"icon-overlap","icon-allow-overlap"),J=X==="always",ot=b.get("text-rotation-alignment")==="map",dt=b.get("text-pitch-alignment")==="map",ut=b.get("icon-text-fit")!=="none",Gt=b.get("symbol-z-order")==="viewport-y",Pt=V&&(J||!f.hasIconData()||N),gt=J&&(V||!f.hasTextData()||Z);!f.collisionArrays&&_&&f.deserializeCollisionBoxes(_);let Ct=this.retainedQueryData[f.bucketInstanceId].tileID,ee=this.terrain?(jt,Fe)=>this.terrain.getElevation(Ct,jt,Fe):null,ge=(jt,Fe)=>{var ke,Ye;if(c[jt.crossTileID])return;if(I)return void(this.placements[jt.crossTileID]=new Cr(!1,!1,!1));let xe=!1,ci=!1,pi=!0,Mi=null,Si={box:null,offscreen:null},cr={box:null,offscreen:null},ji=null,Ii=null,vr=null,Yr=0,Gr=0,mn=0;Fe.textFeatureIndex?Yr=Fe.textFeatureIndex:jt.useRuntimeCollisionCircles&&(Yr=jt.featureIndex),Fe.verticalTextFeatureIndex&&(Gr=Fe.verticalTextFeatureIndex);let wr=Fe.textBox;if(wr){let ur=_r=>{let Br=o.ah.horizontal;if(f.allowVerticalPlacement&&!_r&&this.prevPlacement){let pn=this.prevPlacement.placedOrientations[jt.crossTileID];pn&&(this.placedOrientations[jt.crossTileID]=pn,Br=pn,this.markUsedOrientation(f,Br,jt))}return Br},sr=(_r,Br)=>{if(f.allowVerticalPlacement&&jt.numVerticalGlyphVertices>0&&Fe.verticalTextBox){for(let pn of f.writingModes)if(pn===o.ah.vertical?(Si=Br(),cr=Si):Si=_r(),Si&&Si.box&&Si.box.length)break}else Si=_r()},Ir=jt.textAnchorOffsetStartIndex,Sn=jt.textAnchorOffsetEndIndex;if(Sn===Ir){let _r=(Br,pn)=>{let $i=this.collisionIndex.placeCollisionBox(Br,P,h,L,R.predicate,ee);return $i&&$i.box&&$i.box.length&&(this.markUsedOrientation(f,pn,jt),this.placedOrientations[jt.crossTileID]=pn),$i};sr(()=>_r(wr,o.ah.horizontal),()=>{let Br=Fe.verticalTextBox;return f.allowVerticalPlacement&&jt.numVerticalGlyphVertices>0&&Br?_r(Br,o.ah.vertical):{box:null,offscreen:null}}),ur(Si&&Si.box&&Si.box.length)}else{let _r=o.ap[(Ye=(ke=this.prevPlacement)===null||ke===void 0?void 0:ke.variableOffsets[jt.crossTileID])===null||Ye===void 0?void 0:Ye.anchor],Br=($i,ya,na)=>{let Zr=$i.x2-$i.x1,sa=$i.y2-$i.y1,dl=jt.textBoxScale,Nl=ut&&X==="never"?ya:null,Ro={box:[],offscreen:!1},EA=P==="never"?1:2,TA="never";_r&&EA++;for(let Ns=0;NsBr(wr,Fe.iconBox,o.ah.horizontal),()=>{let $i=Fe.verticalTextBox;return f.allowVerticalPlacement&&!(Si&&Si.box&&Si.box.length)&&jt.numVerticalGlyphVertices>0&&$i?Br($i,Fe.verticalIconBox,o.ah.vertical):{box:null,offscreen:null}}),Si&&(xe=Si.box,pi=Si.offscreen);let pn=ur(Si&&Si.box);if(!xe&&this.prevPlacement){let $i=this.prevPlacement.variableOffsets[jt.crossTileID];$i&&(this.variableOffsets[jt.crossTileID]=$i,this.markUsedJustification(f,$i.anchor,jt,pn))}}}if(ji=Si,xe=ji&&ji.box&&ji.box.length>0,pi=ji&&ji.offscreen,jt.useRuntimeCollisionCircles){let ur=f.text.placedSymbolArray.get(jt.centerJustifiedTextSymbolIndex),sr=o.ai(f.textSizeData,F,ur),Ir=b.get("text-padding");Ii=this.collisionIndex.placeCollisionCircles(P,ur,f.lineVertexArray,f.glyphOffsetArray,sr,L,E,H,p,dt,R.predicate,jt.collisionCircleDiameter,Ir,ee),Ii.circles.length&&Ii.collisionDetected&&!p&&o.w("Collisions detected, but collision boxes are not shown"),xe=V||Ii.circles.length>0&&!Ii.collisionDetected,pi=pi&&Ii.offscreen}if(Fe.iconFeatureIndex&&(mn=Fe.iconFeatureIndex),Fe.iconBox){let ur=sr=>{let Ir=ut&&Mi?Dt(sr,Mi.x,Mi.y,ot,dt,this.transform.angle):sr;return this.collisionIndex.placeCollisionBox(Ir,X,h,L,R.predicate,ee)};cr&&cr.box&&cr.box.length&&Fe.verticalIconBox?(vr=ur(Fe.verticalIconBox),ci=vr.box.length>0):(vr=ur(Fe.iconBox),ci=vr.box.length>0),pi=pi&&vr.offscreen}let An=Z||jt.numHorizontalGlyphVertices===0&&jt.numVerticalGlyphVertices===0,rn=N||jt.numIconVertices===0;if(An||rn?rn?An||(ci=ci&&xe):xe=ci&&xe:ci=xe=ci&&xe,xe&&ji&&ji.box&&this.collisionIndex.insertCollisionBox(ji.box,P,b.get("text-ignore-placement"),f.bucketInstanceId,cr&&cr.box&&Gr?Gr:Yr,R.ID),ci&&vr&&this.collisionIndex.insertCollisionBox(vr.box,X,b.get("icon-ignore-placement"),f.bucketInstanceId,mn,R.ID),Ii&&(xe&&this.collisionIndex.insertCollisionCircles(Ii.circles,P,b.get("text-ignore-placement"),f.bucketInstanceId,Yr,R.ID),p)){let ur=f.bucketInstanceId,sr=this.collisionCircleArrays[ur];sr===void 0&&(sr=this.collisionCircleArrays[ur]=new ki);for(let Ir=0;Ir=0;--Fe){let ke=jt[Fe];ge(f.symbolInstances.get(ke),f.collisionArrays[ke])}}else for(let jt=n.symbolInstanceStart;jt=0&&(n.text.placedSymbolArray.get(E).crossTileID=b>=0&&E!==b?0:p.crossTileID)}markUsedOrientation(n,c,p){let f=c===o.ah.horizontal||c===o.ah.horizontalOnly?c:0,b=c===o.ah.vertical?c:0,L=[p.leftJustifiedTextSymbolIndex,p.centerJustifiedTextSymbolIndex,p.rightJustifiedTextSymbolIndex];for(let E of L)n.text.placedSymbolArray.get(E).placedOrientation=f;p.verticalPlacedTextSymbolIndex&&(n.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).placedOrientation=b)}commit(n){this.commitTime=n,this.zoomAtLastRecencyCheck=this.transform.zoom;let c=this.prevPlacement,p=!1;this.prevZoomAdjustment=c?c.zoomAdjustment(this.transform.zoom):0;let f=c?c.symbolFadeChange(n):1,b=c?c.opacities:{},L=c?c.variableOffsets:{},E=c?c.placedOrientations:{};for(let H in this.placements){let h=this.placements[H],I=b[H];I?(this.opacities[H]=new zi(I,f,h.text,h.icon),p=p||h.text!==I.text.placed||h.icon!==I.icon.placed):(this.opacities[H]=new zi(null,f,h.text,h.icon,h.skipFade),p=p||h.text||h.icon)}for(let H in b){let h=b[H];if(!this.opacities[H]){let I=new zi(h,f,!1,!1);I.isHidden()||(this.opacities[H]=I,p=p||h.text.placed||h.icon.placed)}}for(let H in L)this.variableOffsets[H]||!this.opacities[H]||this.opacities[H].isHidden()||(this.variableOffsets[H]=L[H]);for(let H in E)this.placedOrientations[H]||!this.opacities[H]||this.opacities[H].isHidden()||(this.placedOrientations[H]=E[H]);if(c&&c.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");p?this.lastPlacementChangeTime=n:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=c?c.lastPlacementChangeTime:n)}updateLayerOpacities(n,c){let p={};for(let f of c){let b=f.getBucket(n);b&&f.latestFeatureIndex&&n.id===b.layerIds[0]&&this.updateBucketOpacities(b,p,f.collisionBoxArray)}}updateBucketOpacities(n,c,p){n.hasTextData()&&(n.text.opacityVertexArray.clear(),n.text.hasVisibleVertices=!1),n.hasIconData()&&(n.icon.opacityVertexArray.clear(),n.icon.hasVisibleVertices=!1),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexArray.clear(),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexArray.clear();let f=n.layers[0],b=f.layout,L=new zi(null,0,!1,!1,!0),E=b.get("text-allow-overlap"),H=b.get("icon-allow-overlap"),h=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),I=b.get("text-rotation-alignment")==="map",_=b.get("text-pitch-alignment")==="map",F=b.get("icon-text-fit")!=="none",R=new zi(null,0,E&&(H||!n.hasIconData()||b.get("icon-optional")),H&&(E||!n.hasTextData()||b.get("text-optional")),!0);!n.collisionArrays&&p&&(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData())&&n.deserializeCollisionBoxes(p);let Z=(N,P,V)=>{for(let X=0;X

0,ut=this.placedOrientations[P.crossTileID],Gt=ut===o.ah.vertical,Pt=ut===o.ah.horizontal||ut===o.ah.horizontalOnly;if(V>0||X>0){let gt=Wo(ot.text);Z(n.text,V,Gt?an:gt),Z(n.text,X,Pt?an:gt);let Ct=ot.text.isHidden();[P.rightJustifiedTextSymbolIndex,P.centerJustifiedTextSymbolIndex,P.leftJustifiedTextSymbolIndex].forEach(jt=>{jt>=0&&(n.text.placedSymbolArray.get(jt).hidden=Ct||Gt?1:0)}),P.verticalPlacedTextSymbolIndex>=0&&(n.text.placedSymbolArray.get(P.verticalPlacedTextSymbolIndex).hidden=Ct||Pt?1:0);let ee=this.variableOffsets[P.crossTileID];ee&&this.markUsedJustification(n,ee.anchor,P,ut);let ge=this.placedOrientations[P.crossTileID];ge&&(this.markUsedJustification(n,"left",P,ge),this.markUsedOrientation(n,ge,P))}if(dt){let gt=Wo(ot.icon),Ct=!(F&&P.verticalPlacedIconSymbolIndex&&Gt);P.placedIconSymbolIndex>=0&&(Z(n.icon,P.numIconVertices,Ct?gt:an),n.icon.placedSymbolArray.get(P.placedIconSymbolIndex).hidden=ot.icon.isHidden()),P.verticalPlacedIconSymbolIndex>=0&&(Z(n.icon,P.numVerticalIconVertices,Ct?an:gt),n.icon.placedSymbolArray.get(P.verticalPlacedIconSymbolIndex).hidden=ot.icon.isHidden())}if(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData()){let gt=n.collisionArrays[N];if(gt){let Ct=new o.P(0,0);if(gt.textBox||gt.verticalTextBox){let ge=!0;if(h){let jt=this.variableOffsets[J];jt?(Ct=Tr(jt.anchor,jt.width,jt.height,jt.textOffset,jt.textBoxScale),I&&Ct._rotate(_?this.transform.angle:-this.transform.angle)):ge=!1}gt.textBox&&Te(n.textCollisionBox.collisionVertexArray,ot.text.placed,!ge||Gt,Ct.x,Ct.y),gt.verticalTextBox&&Te(n.textCollisionBox.collisionVertexArray,ot.text.placed,!ge||Pt,Ct.x,Ct.y)}let ee=Boolean(!Pt&>.verticalIconBox);gt.iconBox&&Te(n.iconCollisionBox.collisionVertexArray,ot.icon.placed,ee,F?Ct.x:0,F?Ct.y:0),gt.verticalIconBox&&Te(n.iconCollisionBox.collisionVertexArray,ot.icon.placed,!ee,F?Ct.x:0,F?Ct.y:0)}}}if(n.sortFeatures(this.transform.angle),this.retainedQueryData[n.bucketInstanceId]&&(this.retainedQueryData[n.bucketInstanceId].featureSortOrder=n.featureSortOrder),n.hasTextData()&&n.text.opacityVertexBuffer&&n.text.opacityVertexBuffer.updateData(n.text.opacityVertexArray),n.hasIconData()&&n.icon.opacityVertexBuffer&&n.icon.opacityVertexBuffer.updateData(n.icon.opacityVertexArray),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexBuffer&&n.iconCollisionBox.collisionVertexBuffer.updateData(n.iconCollisionBox.collisionVertexArray),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexBuffer&&n.textCollisionBox.collisionVertexBuffer.updateData(n.textCollisionBox.collisionVertexArray),n.text.opacityVertexArray.length!==n.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${n.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${n.text.layoutVertexArray.length}) / 4`);if(n.icon.opacityVertexArray.length!==n.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${n.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${n.icon.layoutVertexArray.length}) / 4`);if(n.bucketInstanceId in this.collisionCircleArrays){let N=this.collisionCircleArrays[n.bucketInstanceId];n.placementInvProjMatrix=N.invProjMatrix,n.placementViewportMatrix=N.viewportMatrix,n.collisionCircleArray=N.circles,delete this.collisionCircleArrays[n.bucketInstanceId]}}symbolFadeChange(n){return this.fadeDuration===0?1:(n-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(n){return Math.max(0,(this.transform.zoom-n)/1.5)}hasTransitions(n){return this.stale||n-this.lastPlacementChangeTimen}setStale(){this.stale=!0}}function Te(y,n,c,p,f){y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0)}let or=Math.pow(2,25),Er=Math.pow(2,24),Ji=Math.pow(2,17),Mr=Math.pow(2,16),vs=Math.pow(2,9),Sr=Math.pow(2,8),xr=Math.pow(2,1);function Wo(y){if(y.opacity===0&&!y.placed)return 0;if(y.opacity===1&&y.placed)return 4294967295;let n=y.placed?1:0,c=Math.floor(127*y.opacity);return c*or+n*Er+c*Ji+n*Mr+c*vs+n*Sr+c*xr+n}let an=0;class Dn{constructor(n){this._sortAcrossTiles=n.layout.get("symbol-z-order")!=="viewport-y"&&!n.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(n,c,p,f,b){let L=this._bucketParts;for(;this._currentTileIndexE.sortKey-H.sortKey));this._currentPartIndex!this._forceFullPlacement&&v.now()-f>2;for(;this._currentPlacementIndex>=0;){let L=c[n[this._currentPlacementIndex]],E=this.placement.collisionIndex.transform.zoom;if(L.type==="symbol"&&(!L.minzoom||L.minzoom<=E)&&(!L.maxzoom||L.maxzoom>E)){if(this._inProgressLayer||(this._inProgressLayer=new Dn(L)),this._inProgressLayer.continuePlacement(p[L.source],this.placement,this._showCollisionBoxes,L,b))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(n){return this.placement.commit(n),this.placement}}let As=512/o.W/2;class Qr{constructor(n,c,p){this.tileID=n,this.bucketInstanceId=p,this._symbolsByKey={};let f=new Map;for(let b=0;b({x:Math.floor(H.anchorX*As),y:Math.floor(H.anchorY*As)})),crossTileIDs:L.map(H=>H.crossTileID)};if(E.positions.length>128){let H=new o.au(E.positions.length,16,Uint16Array);for(let{x:h,y:I}of E.positions)H.add(h,I);H.finish(),delete E.positions,E.index=H}this._symbolsByKey[b]=E}}getScaledCoordinates(n,c){let{x:p,y:f,z:b}=this.tileID.canonical,{x:L,y:E,z:H}=c.canonical,h=As/Math.pow(2,H-b),I=(E*o.W+n.anchorY)*h,_=f*o.W*As;return{x:Math.floor((L*o.W+n.anchorX)*h-p*o.W*As),y:Math.floor(I-_)}}findMatches(n,c,p){let f=this.tileID.canonical.zn)}}class zo{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Fr{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(n){let c=Math.round((n-this.lng)/360);if(c!==0)for(let p in this.indexes){let f=this.indexes[p],b={};for(let L in f){let E=f[L];E.tileID=E.tileID.unwrapTo(E.tileID.wrap+c),b[E.tileID.key]=E}this.indexes[p]=b}this.lng=n}addBucket(n,c,p){if(this.indexes[n.overscaledZ]&&this.indexes[n.overscaledZ][n.key]){if(this.indexes[n.overscaledZ][n.key].bucketInstanceId===c.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(n.overscaledZ,this.indexes[n.overscaledZ][n.key])}for(let b=0;bn.overscaledZ)for(let E in L){let H=L[E];H.tileID.isChildOf(n)&&H.findMatches(c.symbolInstances,n,f)}else{let E=L[n.scaledTo(Number(b)).key];E&&E.findMatches(c.symbolInstances,n,f)}}for(let b=0;b{c[p]=!0});for(let p in this.layerIndexes)c[p]||delete this.layerIndexes[p]}}let Gs=(y,n)=>o.t(y,n&&n.filter(c=>c.identifier!=="source.canvas")),Kn=o.av();class to extends o.E{constructor(n,c={}){super(),this._rtlPluginLoaded=()=>{for(let p in this.sourceCaches){let f=this.sourceCaches[p].getSource().type;f!=="vector"&&f!=="geojson"||this.sourceCaches[p].reload()}},this.map=n,this.dispatcher=new Ae(Ot(),n._getMapId()),this.dispatcher.registerMessageHandler("getGlyphs",(p,f)=>this.getGlyphs(p,f)),this.dispatcher.registerMessageHandler("getImages",(p,f)=>this.getImages(p,f)),this.imageManager=new lt,this.imageManager.setEventedParent(this),this.glyphManager=new ie(n._requestManager,c.localIdeographFontFamily),this.lineAtlas=new Ut(256,512),this.crossTileSymbolIndex=new Nr,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new o.aw,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",o.ax()),Oi().on(Ei,this._rtlPluginLoaded),this.on("data",p=>{if(p.dataType!=="source"||p.sourceDataType!=="metadata")return;let f=this.sourceCaches[p.sourceId];if(!f)return;let b=f.getSource();if(b&&b.vectorLayerIds)for(let L in this._layers){let E=this._layers[L];E.source===b.id&&this._validateLayer(E)}})}loadURL(n,c={},p){this.fire(new o.k("dataloading",{dataType:"style"})),c.validate=typeof c.validate!="boolean"||c.validate;let f=this.map._requestManager.transformRequest(n,tt.Style);this._loadStyleRequest=new AbortController,o.h(f,this._loadStyleRequest).then(b=>{this._loadStyleRequest=null,this._load(b.data,c,p)}).catch(b=>{this._loadStyleRequest=null,b&&this.fire(new o.j(b))})}loadJSON(n,c={},p){this.fire(new o.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,c.validate=c.validate!==!1,this._load(n,c,p)}).catch(()=>{})}loadEmpty(){this.fire(new o.k("dataloading",{dataType:"style"})),this._load(Kn,{validate:!1})}_load(n,c,p){var f;let b=c.transformStyle?c.transformStyle(p,n):n;if(!c.validate||!Gs(this,o.x(b))){this._loaded=!0,this.stylesheet=b;for(let L in b.sources)this.addSource(L,b.sources[L],{validate:!1});b.sprite?this._loadSprite(b.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(b.glyphs),this._createLayers(),this.light=new wt(this.stylesheet.light),this.map.setTerrain((f=this.stylesheet.terrain)!==null&&f!==void 0?f:null),this.fire(new o.k("data",{dataType:"style"})),this.fire(new o.k("style.load"))}}_createLayers(){let n=o.ay(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",n),this._order=n.map(c=>c.id),this._layers={},this._serializedLayers=null;for(let c of n){let p=o.az(c);p.setEventedParent(this,{layer:{id:c.id}}),this._layers[c.id]=p}}_loadSprite(n,c=!1,p=void 0){let f;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(b,L,E,H){return o._(this,void 0,void 0,function*(){let h=Jt(b),I=E>1?"@2x":"",_={},F={};for(let{id:R,url:Z}of h){let N=L.transformRequest(L.normalizeSpriteURL(Z,I,".json"),tt.SpriteJSON);_[R]=o.h(N,H);let P=L.transformRequest(L.normalizeSpriteURL(Z,I,".png"),tt.SpriteImage);F[R]=O.getImage(P,H)}return yield Promise.all([...Object.values(_),...Object.values(F)]),function(R,Z){return o._(this,void 0,void 0,function*(){let N={};for(let P in R){N[P]={};let V=v.getImageCanvasContext((yield Z[P]).data),X=(yield R[P]).data;for(let J in X){let{width:ot,height:dt,x:ut,y:Gt,sdf:Pt,pixelRatio:gt,stretchX:Ct,stretchY:ee,content:ge}=X[J];N[P][J]={data:null,pixelRatio:gt,sdf:Pt,stretchX:Ct,stretchY:ee,content:ge,spriteData:{width:ot,height:dt,x:ut,y:Gt,context:V}}}}return N})}(_,F)})}(n,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(b=>{if(this._spriteRequest=null,b)for(let L in b){this._spritesImagesIds[L]=[];let E=this._spritesImagesIds[L]?this._spritesImagesIds[L].filter(H=>!(H in b)):[];for(let H of E)this.imageManager.removeImage(H),this._changedImages[H]=!0;for(let H in b[L]){let h=L==="default"?H:`${L}:${H}`;this._spritesImagesIds[L].push(h),h in this.imageManager.images?this.imageManager.updateImage(h,b[L][H],!1):this.imageManager.addImage(h,b[L][H]),c&&(this._changedImages[h]=!0)}}}).catch(b=>{this._spriteRequest=null,f=b,this.fire(new o.j(f))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),c&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"})),p&&p(f)})}_unloadSprite(){for(let n of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(n),this._changedImages[n]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}_validateLayer(n){let c=this.sourceCaches[n.source];if(!c)return;let p=n.sourceLayer;if(!p)return;let f=c.getSource();(f.type==="geojson"||f.vectorLayerIds&&f.vectorLayerIds.indexOf(p)===-1)&&this.fire(new o.j(new Error(`Source layer "${p}" does not exist on source "${f.id}" as specified by style layer "${n.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let n in this.sourceCaches)if(!this.sourceCaches[n].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(n){let c=this._serializedAllLayers();if(!n||n.length===0)return Object.values(c);let p=[];for(let f of n)c[f]&&p.push(c[f]);return p}_serializedAllLayers(){let n=this._serializedLayers;if(n)return n;n=this._serializedLayers={};let c=Object.keys(this._layers);for(let p of c){let f=this._layers[p];f.type!=="custom"&&(n[p]=f.serialize())}return n}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(let n in this.sourceCaches)if(this.sourceCaches[n].hasTransition())return!0;for(let n in this._layers)if(this._layers[n].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(n){if(!this._loaded)return;let c=this._changed;if(this._changed){let f=Object.keys(this._updatedLayers),b=Object.keys(this._removedLayers);(f.length||b.length)&&this._updateWorkerLayers(f,b);for(let L in this._updatedSources){let E=this._updatedSources[L];if(E==="reload")this._reloadSource(L);else{if(E!=="clear")throw new Error(`Invalid action ${E}`);this._clearSource(L)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let L in this._updatedPaintProps)this._layers[L].updateTransitions(n);this.light.updateTransitions(n),this._resetUpdates()}let p={};for(let f in this.sourceCaches){let b=this.sourceCaches[f];p[f]=b.used,b.used=!1}for(let f of this._order){let b=this._layers[f];b.recalculate(n,this._availableImages),!b.isHidden(n.zoom)&&b.source&&(this.sourceCaches[b.source].used=!0)}for(let f in p){let b=this.sourceCaches[f];p[f]!==b.used&&b.fire(new o.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:f}))}this.light.recalculate(n),this.z=n.zoom,c&&this.fire(new o.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){let n=Object.keys(this._changedImages);if(n.length){for(let c in this.sourceCaches)this.sourceCaches[c].reloadTilesForDependencies(["icons","patterns"],n);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(n,c){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(n),removedIds:c})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(n,c={}){var p;this._checkLoaded();let f=this.serialize();if(n=c.transformStyle?c.transformStyle(f,n):n,((p=c.validate)===null||p===void 0||p)&&Gs(this,o.x(n)))return!1;(n=o.aA(n)).layers=o.ay(n.layers);let b=o.aB(f,n),L=this._getOperationsToPerform(b);if(L.unimplemented.length>0)throw new Error(`Unimplemented: ${L.unimplemented.join(", ")}.`);if(L.operations.length===0)return!1;for(let E of L.operations)E();return this.stylesheet=n,this._serializedLayers=null,!0}_getOperationsToPerform(n){let c=[],p=[];for(let f of n)switch(f.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":c.push(()=>this.addLayer.apply(this,f.args));break;case"removeLayer":c.push(()=>this.removeLayer.apply(this,f.args));break;case"setPaintProperty":c.push(()=>this.setPaintProperty.apply(this,f.args));break;case"setLayoutProperty":c.push(()=>this.setLayoutProperty.apply(this,f.args));break;case"setFilter":c.push(()=>this.setFilter.apply(this,f.args));break;case"addSource":c.push(()=>this.addSource.apply(this,f.args));break;case"removeSource":c.push(()=>this.removeSource.apply(this,f.args));break;case"setLayerZoomRange":c.push(()=>this.setLayerZoomRange.apply(this,f.args));break;case"setLight":c.push(()=>this.setLight.apply(this,f.args));break;case"setGeoJSONSourceData":c.push(()=>this.setGeoJSONSourceData.apply(this,f.args));break;case"setGlyphs":c.push(()=>this.setGlyphs.apply(this,f.args));break;case"setSprite":c.push(()=>this.setSprite.apply(this,f.args));break;case"setTerrain":c.push(()=>this.map.setTerrain.apply(this,f.args));break;case"setTransition":c.push(()=>{});break;default:p.push(f.command)}return{operations:c,unimplemented:p}}addImage(n,c){if(this.getImage(n))return this.fire(new o.j(new Error(`An image named "${n}" already exists.`)));this.imageManager.addImage(n,c),this._afterImageUpdated(n)}updateImage(n,c){this.imageManager.updateImage(n,c)}getImage(n){return this.imageManager.getImage(n)}removeImage(n){if(!this.getImage(n))return this.fire(new o.j(new Error(`An image named "${n}" does not exist.`)));this.imageManager.removeImage(n),this._afterImageUpdated(n)}_afterImageUpdated(n){this._availableImages=this.imageManager.listImages(),this._changedImages[n]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(n,c,p={}){if(this._checkLoaded(),this.sourceCaches[n]!==void 0)throw new Error(`Source "${n}" already exists.`);if(!c.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(c).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(c.type)>=0&&this._validate(o.x.source,`sources.${n}`,c,null,p))return;this.map&&this.map._collectResourceTiming&&(c.collectResourceTiming=!0);let f=this.sourceCaches[n]=new Se(n,c,this.dispatcher);f.style=this,f.setEventedParent(this,()=>({isSourceLoaded:f.loaded(),source:f.serialize(),sourceId:n})),f.onAdd(this.map),this._changed=!0}removeSource(n){if(this._checkLoaded(),this.sourceCaches[n]===void 0)throw new Error("There is no source with this ID");for(let p in this._layers)if(this._layers[p].source===n)return this.fire(new o.j(new Error(`Source "${n}" cannot be removed while layer "${p}" is using it.`)));let c=this.sourceCaches[n];delete this.sourceCaches[n],delete this._updatedSources[n],c.fire(new o.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:n})),c.setEventedParent(null),c.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(n,c){if(this._checkLoaded(),this.sourceCaches[n]===void 0)throw new Error(`There is no source with this ID=${n}`);let p=this.sourceCaches[n].getSource();if(p.type!=="geojson")throw new Error(`geojsonSource.type is ${p.type}, which is !== 'geojson`);p.setData(c),this._changed=!0}getSource(n){return this.sourceCaches[n]&&this.sourceCaches[n].getSource()}addLayer(n,c,p={}){this._checkLoaded();let f=n.id;if(this.getLayer(f))return void this.fire(new o.j(new Error(`Layer "${f}" already exists on this map.`)));let b;if(n.type==="custom"){if(Gs(this,o.aC(n)))return;b=o.az(n)}else{if("source"in n&&typeof n.source=="object"&&(this.addSource(f,n.source),n=o.aA(n),n=o.e(n,{source:f})),this._validate(o.x.layer,`layers.${f}`,n,{arrayIndex:-1},p))return;b=o.az(n),this._validateLayer(b),b.setEventedParent(this,{layer:{id:f}})}let L=c?this._order.indexOf(c):this._order.length;if(c&&L===-1)this.fire(new o.j(new Error(`Cannot add layer "${f}" before non-existing layer "${c}".`)));else{if(this._order.splice(L,0,f),this._layerOrderChanged=!0,this._layers[f]=b,this._removedLayers[f]&&b.source&&b.type!=="custom"){let E=this._removedLayers[f];delete this._removedLayers[f],E.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",this.sourceCaches[b.source].pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map)}}moveLayer(n,c){if(this._checkLoaded(),this._changed=!0,!this._layers[n])return void this.fire(new o.j(new Error(`The layer '${n}' does not exist in the map's style and cannot be moved.`)));if(n===c)return;let p=this._order.indexOf(n);this._order.splice(p,1);let f=c?this._order.indexOf(c):this._order.length;c&&f===-1?this.fire(new o.j(new Error(`Cannot move layer "${n}" before non-existing layer "${c}".`))):(this._order.splice(f,0,n),this._layerOrderChanged=!0)}removeLayer(n){this._checkLoaded();let c=this._layers[n];if(!c)return void this.fire(new o.j(new Error(`Cannot remove non-existing layer "${n}".`)));c.setEventedParent(null);let p=this._order.indexOf(n);this._order.splice(p,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[n]=c,delete this._layers[n],this._serializedLayers&&delete this._serializedLayers[n],delete this._updatedLayers[n],delete this._updatedPaintProps[n],c.onRemove&&c.onRemove(this.map)}getLayer(n){return this._layers[n]}getLayersOrder(){return[...this._order]}hasLayer(n){return n in this._layers}setLayerZoomRange(n,c,p){this._checkLoaded();let f=this.getLayer(n);f?f.minzoom===c&&f.maxzoom===p||(c!=null&&(f.minzoom=c),p!=null&&(f.maxzoom=p),this._updateLayer(f)):this.fire(new o.j(new Error(`Cannot set the zoom range of non-existing layer "${n}".`)))}setFilter(n,c,p={}){this._checkLoaded();let f=this.getLayer(n);if(f){if(!o.aD(f.filter,c))return c==null?(f.filter=void 0,void this._updateLayer(f)):void(this._validate(o.x.filter,`layers.${f.id}.filter`,c,null,p)||(f.filter=o.aA(c),this._updateLayer(f)))}else this.fire(new o.j(new Error(`Cannot filter non-existing layer "${n}".`)))}getFilter(n){return o.aA(this.getLayer(n).filter)}setLayoutProperty(n,c,p,f={}){this._checkLoaded();let b=this.getLayer(n);b?o.aD(b.getLayoutProperty(c),p)||(b.setLayoutProperty(c,p,f),this._updateLayer(b)):this.fire(new o.j(new Error(`Cannot style non-existing layer "${n}".`)))}getLayoutProperty(n,c){let p=this.getLayer(n);if(p)return p.getLayoutProperty(c);this.fire(new o.j(new Error(`Cannot get style of non-existing layer "${n}".`)))}setPaintProperty(n,c,p,f={}){this._checkLoaded();let b=this.getLayer(n);b?o.aD(b.getPaintProperty(c),p)||(b.setPaintProperty(c,p,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new o.j(new Error(`Cannot style non-existing layer "${n}".`)))}getPaintProperty(n,c){return this.getLayer(n).getPaintProperty(c)}setFeatureState(n,c){this._checkLoaded();let p=n.source,f=n.sourceLayer,b=this.sourceCaches[p];if(b===void 0)return void this.fire(new o.j(new Error(`The source '${p}' does not exist in the map's style.`)));let L=b.getSource().type;L==="geojson"&&f?this.fire(new o.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):L!=="vector"||f?(n.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),b.setFeatureState(f,n.id,c)):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(n,c){this._checkLoaded();let p=n.source,f=this.sourceCaches[p];if(f===void 0)return void this.fire(new o.j(new Error(`The source '${p}' does not exist in the map's style.`)));let b=f.getSource().type,L=b==="vector"?n.sourceLayer:void 0;b!=="vector"||L?c&&typeof n.id!="string"&&typeof n.id!="number"?this.fire(new o.j(new Error("A feature id is required to remove its specific state property."))):f.removeFeatureState(L,n.id,c):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(n){this._checkLoaded();let c=n.source,p=n.sourceLayer,f=this.sourceCaches[c];if(f!==void 0)return f.getSource().type!=="vector"||p?(n.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),f.getFeatureState(p,n.id)):void this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new o.j(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return o.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let n=o.aE(this.sourceCaches,b=>b.serialize()),c=this._serializeByIds(this._order),p=this.map.getTerrain()||void 0,f=this.stylesheet;return o.aF({version:f.version,name:f.name,metadata:f.metadata,light:f.light,center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,sprite:f.sprite,glyphs:f.glyphs,transition:f.transition,sources:n,layers:c,terrain:p},b=>b!==void 0)}_updateLayer(n){this._updatedLayers[n.id]=!0,n.source&&!this._updatedSources[n.source]&&this.sourceCaches[n.source].getSource().type!=="raster"&&(this._updatedSources[n.source]="reload",this.sourceCaches[n.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(n){let c=L=>this._layers[L].type==="fill-extrusion",p={},f=[];for(let L=this._order.length-1;L>=0;L--){let E=this._order[L];if(c(E)){p[E]=L;for(let H of n){let h=H[E];if(h)for(let I of h)f.push(I)}}}f.sort((L,E)=>E.intersectionZ-L.intersectionZ);let b=[];for(let L=this._order.length-1;L>=0;L--){let E=this._order[L];if(c(E))for(let H=f.length-1;H>=0;H--){let h=f[H].feature;if(p[h.layer.id]{let Pt=V.featureSortOrder;if(Pt){let gt=Pt.indexOf(ut.featureIndex);return Pt.indexOf(Gt.featureIndex)-gt}return Gt.featureIndex-ut.featureIndex});for(let ut of dt)ot.push(ut)}}for(let V in Z)Z[V].forEach(X=>{let J=X.feature,ot=h[E[V].source].getFeatureState(J.layer["source-layer"],J.id);J.source=J.layer.source,J.layer["source-layer"]&&(J.sourceLayer=J.layer["source-layer"]),J.state=ot});return Z}(this._layers,L,this.sourceCaches,n,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(b)}querySourceFeatures(n,c){c&&c.filter&&this._validate(o.x.filter,"querySourceFeatures.filter",c.filter,null,c);let p=this.sourceCaches[n];return p?function(f,b){let L=f.getRenderableIds().map(h=>f.getTileByID(h)),E=[],H={};for(let h=0;hF.getTileByID(R)).sort((R,Z)=>Z.tileID.overscaledZ-R.tileID.overscaledZ||(R.tileID.isLessThan(Z.tileID)?-1:1))}let _=this.crossTileSymbolIndex.addLayer(I,H[I.source],n.center.lng);L=L||_}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((b=b||this._layerOrderChanged||p===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(v.now(),n.zoom))&&(this.pauseablePlacement=new Oo(n,this.map.terrain,this._order,b,c,p,f,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,H),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(v.now()),E=!0),L&&this.pauseablePlacement.placement.setStale()),E||L)for(let h of this._order){let I=this._layers[h];I.type==="symbol"&&this.placement.updateLayerOpacities(I,H[I.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(v.now())}_releaseSymbolFadeTiles(){for(let n in this.sourceCaches)this.sourceCaches[n].releaseSymbolFadeTiles()}getImages(n,c){return o._(this,void 0,void 0,function*(){let p=yield this.imageManager.getImages(c.icons);this._updateTilesForChangedImages();let f=this.sourceCaches[c.source];return f&&f.setDependencies(c.tileID.key,c.type,c.icons),p})}getGlyphs(n,c){return o._(this,void 0,void 0,function*(){let p=yield this.glyphManager.getGlyphs(c.stacks),f=this.sourceCaches[c.source];return f&&f.setDependencies(c.tileID.key,c.type,[""]),p})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(n,c={}){this._checkLoaded(),n&&this._validate(o.x.glyphs,"glyphs",n,null,c)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=n,this.glyphManager.entries={},this.glyphManager.setURL(n))}addSprite(n,c,p={},f){this._checkLoaded();let b=[{id:n,url:c}],L=[...Jt(this.stylesheet.sprite),...b];this._validate(o.x.sprite,"sprite",L,null,p)||(this.stylesheet.sprite=L,this._loadSprite(b,!0,f))}removeSprite(n){this._checkLoaded();let c=Jt(this.stylesheet.sprite);if(c.find(p=>p.id===n)){if(this._spritesImagesIds[n])for(let p of this._spritesImagesIds[n])this.imageManager.removeImage(p),this._changedImages[p]=!0;c.splice(c.findIndex(p=>p.id===n),1),this.stylesheet.sprite=c.length>0?c:void 0,delete this._spritesImagesIds[n],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}else this.fire(new o.j(new Error(`Sprite "${n}" doesn't exists on this map.`)))}getSprite(){return Jt(this.stylesheet.sprite)}setSprite(n,c={},p){this._checkLoaded(),n&&this._validate(o.x.sprite,"sprite",n,null,c)||(this.stylesheet.sprite=n,n?this._loadSprite(n,!0,p):(this._unloadSprite(),p&&p(null)))}}var pt=o.X([{name:"a_pos",type:"Int16",components:2}]),yt="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";let ct={prelude:Bt(`#ifdef GL_ES +var f3=Object.create;var Wm=Object.defineProperty;var m3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var I3=Object.getPrototypeOf,y3=Object.prototype.hasOwnProperty;var gd=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var dd=(r,t)=>()=>(r&&(t=r(r=0)),t);var la=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Om=(r,t)=>{for(var i in t)Wm(r,i,{get:t[i],enumerable:!0})},b3=(r,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let A of C3(t))!y3.call(r,A)&&A!==i&&Wm(r,A,{get:()=>t[A],enumerable:!(s=m3(t,A))||s.enumerable});return r};var pd=(r,t,i)=>(i=r!=null?f3(I3(r)):{},b3(t||!r||!r.__esModule?Wm(i,"default",{value:r,enumerable:!0}):i,r));var Xm=la((zm,Jm)=>{(function(r,t){typeof zm=="object"&&typeof Jm<"u"?Jm.exports=t():typeof define=="function"&&define.amd?define(t):(r=typeof globalThis<"u"?globalThis:r||self,r.maplibregl=t())})(zm,function(){"use strict";var r={},t={};function i(A,o,g){if(t[A]=g,A==="index"){var d="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",C={};return t.shared(C),t.index(r,C),typeof window<"u"&&r.setWorkerUrl(window.URL.createObjectURL(new Blob([d],{type:"text/javascript"}))),r}}i("shared",["exports"],function(A){"use strict";function o(a,e,l,u){return new(l||(l=Promise))(function(m,w){function B(M){try{U(u.next(M))}catch(D){w(D)}}function S(M){try{U(u.throw(M))}catch(D){w(D)}}function U(M){var D;M.done?m(M.value):(D=M.value,D instanceof l?D:new l(function(z){z(D)})).then(B,S)}U((u=u.apply(a,e||[])).next())})}function g(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}typeof SuppressedError=="function"&&SuppressedError;var d=C;function C(a,e){this.x=a,this.y=e}C.prototype={clone:function(){return new C(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,e){return this.clone()._rotateAround(a,e)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var e=a.x-this.x,l=a.y-this.y;return e*e+l*l},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,e){return Math.atan2(this.x*e-this.y*a,this.x*a+this.y*e)},_matMult:function(a){var e=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=e,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var e=Math.cos(a),l=Math.sin(a),u=l*this.x+e*this.y;return this.x=e*this.x-l*this.y,this.y=u,this},_rotateAround:function(a,e){var l=Math.cos(a),u=Math.sin(a),m=e.y+u*(this.x-e.x)+l*(this.y-e.y);return this.x=e.x+l*(this.x-e.x)-u*(this.y-e.y),this.y=m,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},C.convert=function(a){return a instanceof C?a:Array.isArray(a)?new C(a[0],a[1]):a};var v=g(d),x=T;function T(a,e,l,u){this.cx=3*a,this.bx=3*(l-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=e,this.p2x=l,this.p2y=u}T.prototype={sampleCurveX:function(a){return((this.ax*a+this.bx)*a+this.cx)*a},sampleCurveY:function(a){return((this.ay*a+this.by)*a+this.cy)*a},sampleCurveDerivativeX:function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},solveCurveX:function(a,e){if(e===void 0&&(e=1e-6),a<0)return 0;if(a>1)return 1;for(var l=a,u=0;u<8;u++){var m=this.sampleCurveX(l)-a;if(Math.abs(m)m?B=l:S=l,l=.5*(S-B)+B;return l},solve:function(a,e){return this.sampleCurveY(this.solveCurveX(a,e))}};var G=g(x);let k,W;function K(){return k==null&&(k=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),k}function $(){if(W==null&&(W=!1,K())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let u=0;u<5*5;u++){let m=4*u;e.fillStyle=`rgb(${m},${m+1},${m+2})`,e.fillRect(u%5,Math.floor(u/5),1,1)}let l=e.getImageData(0,0,5,5).data;for(let u=0;u<5*5*4;u++)if(u%4!=3&&l[u]!==u){W=!0;break}}}return W||!1}function O(a,e,l,u){let m=new G(a,e,l,u);return function(w){return m.solve(w)}}let tt=O(.25,.1,.25,1);function at(a,e,l){return Math.min(l,Math.max(e,a))}function Lt(a,e,l){let u=l-e,m=((a-e)%u+u)%u+e;return m===e?l:m}function Tt(a,...e){for(let l of e)for(let u in l)a[u]=l[u];return a}let Ut=1;function Ft(a,e,l){let u={};for(let m in a)u[m]=e.call(l||this,a[m],m,a);return u}function vt(a,e,l){let u={};for(let m in a)e.call(l||this,a[m],m,a)&&(u[m]=a[m]);return u}function Jt(a){return Array.isArray(a)?a.map(Jt):typeof a=="object"&&a?Ft(a,Jt):a}let qt={};function At(a){qt[a]||(typeof console<"u"&&console.warn(a),qt[a]=!0)}function lt(a,e,l){return(l.y-a.y)*(e.x-a.x)>(e.y-a.y)*(l.x-a.x)}function kt(a){let e=0;for(let l,u,m=0,w=a.length,B=w-1;m"u")throw new Error("VideoFrame not supported");let w=new VideoFrame(a,{timestamp:0});try{let B=w?.format;if(!B||!B.startsWith("BGR")&&!B.startsWith("RGB"))throw new Error(`Unrecognized format ${B}`);let S=B.startsWith("BGR"),U=new Uint8ClampedArray(u*m*4);if(yield w.copyTo(U,function(M,D,z,et,nt){let st=4*Math.max(-D,0),mt=(Math.max(0,z)-z)*et*4+st,St=4*et,Vt=Math.max(0,D),se=Math.max(0,z);return{rect:{x:Vt,y:se,width:Math.min(M.width,D+et)-Vt,height:Math.min(M.height,z+nt)-se},layout:[{offset:mt,stride:St}]}}(a,e,l,u,m)),S)for(let M=0;M_t(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,he=function(a,e){if(/:\/\//.test(a.url)&&!/^https?:|^file:/.test(a.url)){let u=It(a.url);if(u)return u(a,e);if(_t(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"getResource",data:a,targetMapId:Ht},e)}if(!(/^file:/.test(l=a.url)||/^file:/.test(Ae())&&!/^\w+:/.test(l))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(u,m){return o(this,void 0,void 0,function*(){let w=new Request(u.url,{method:u.method||"GET",body:u.body,credentials:u.credentials,headers:u.headers,cache:u.cache,referrer:Ae(),signal:m.signal});u.type==="json"&&w.headers.set("Accept","application/json");let B=yield fetch(w);if(!B.ok){let M=yield B.blob();throw new Ot(B.status,B.statusText,u.url,M)}let S;S=u.type==="arrayBuffer"||u.type==="image"?B.arrayBuffer():u.type==="json"?B.json():B.text();let U=yield S;if(m.signal.aborted)throw j();return{data:U,cacheControl:B.headers.get("Cache-Control"),expires:B.headers.get("Expires")}})}(a,e);if(_t(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"getResource",data:a,mustQueue:!0,targetMapId:Ht},e)}var l;return function(u,m){return new Promise((w,B)=>{let S=new XMLHttpRequest;S.open(u.method||"GET",u.url,!0),u.type!=="arrayBuffer"&&u.type!=="image"||(S.responseType="arraybuffer");for(let U in u.headers)S.setRequestHeader(U,u.headers[U]);u.type==="json"&&(S.responseType="text",S.setRequestHeader("Accept","application/json")),S.withCredentials=u.credentials==="include",S.onerror=()=>{B(new Error(S.statusText))},S.onload=()=>{if(!m.signal.aborted)if((S.status>=200&&S.status<300||S.status===0)&&S.response!==null){let U=S.response;if(u.type==="json")try{U=JSON.parse(S.response)}catch(M){return void B(M)}w({data:U,cacheControl:S.getResponseHeader("Cache-Control"),expires:S.getResponseHeader("Expires")})}else{let U=new Blob([S.response],{type:S.getResponseHeader("Content-Type")});B(new Ot(S.status,S.statusText,u.url,U))}},m.signal.addEventListener("abort",()=>{S.abort(),B(j())}),S.send(u.body)})}(a,e)};function de(a){if(!a||a.indexOf("://")<=0||a.indexOf("data:image/")===0||a.indexOf("blob:")===0)return!0;let e=new URL(a),l=window.location;return e.protocol===l.protocol&&e.host===l.host}function He(a,e,l){l[a]&&l[a].indexOf(e)!==-1||(l[a]=l[a]||[],l[a].push(e))}function Ge(a,e,l){if(l&&l[a]){let u=l[a].indexOf(e);u!==-1&&l[a].splice(u,1)}}class je{constructor(e,l={}){Tt(this,l),this.type=e}}class Me extends je{constructor(e,l={}){super("error",Tt({error:e},l))}}class gi{on(e,l){return this._listeners=this._listeners||{},He(e,l,this._listeners),this}off(e,l){return Ge(e,l,this._listeners),Ge(e,l,this._oneTimeListeners),this}once(e,l){return l?(this._oneTimeListeners=this._oneTimeListeners||{},He(e,l,this._oneTimeListeners),this):new Promise(u=>this.once(e,u))}fire(e,l){typeof e=="string"&&(e=new je(e,l||{}));let u=e.type;if(this.listens(u)){e.target=this;let m=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(let S of m)S.call(this,e);let w=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(let S of w)Ge(u,S,this._oneTimeListeners),S.call(this,e);let B=this._eventedParent;B&&(Tt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),B.fire(e))}else e instanceof Me&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,l){return this._eventedParent=e,this._eventedParentData=l,this}}var xt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},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}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},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"}}};let Rt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Li(a,e){let l={};for(let u in a)u!=="ref"&&(l[u]=a[u]);return Rt.forEach(u=>{u in e&&(l[u]=e[u])}),l}function Qe(a,e){if(Array.isArray(a)){if(!Array.isArray(e)||a.length!==e.length)return!1;for(let l=0;l`:a.itemType.kind==="value"?"array":`array<${e}>`}return a.kind}let Zt=[We,Se,$e,di,Zi,kr,qi,rt(vi),ft,Y,q];function zt(a,e){if(e.kind==="error")return null;if(a.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!zt(a.itemType,e.itemType))&&(typeof a.N!="number"||a.N===e.N))return null}else{if(a.kind===e.kind)return null;if(a.kind==="value"){for(let l of Zt)if(!zt(l,e))return null}}return`Expected ${ht(a)} but found ${ht(e)} instead.`}function Xt(a,e){return e.some(l=>l.kind===a.kind)}function Mt(a,e){return e.some(l=>l==="null"?a===null:l==="array"?Array.isArray(a):l==="object"?a&&!Array.isArray(a)&&typeof a=="object":l===typeof a)}function re(a,e){return a.kind==="array"&&e.kind==="array"?a.itemType.kind===e.itemType.kind&&typeof a.N=="number":a.kind===e.kind}let ce=.96422,pe=.82521,me=4/29,Xe=6/29,oi=3*Xe*Xe,ii=Xe*Xe*Xe,Ni=Math.PI/180,Ui=180/Math.PI;function rr(a){return(a%=360)<0&&(a+=360),a}function zi([a,e,l,u]){let m,w,B=ki((.2225045*(a=Cr(a))+.7168786*(e=Cr(e))+.0606169*(l=Cr(l)))/1);a===e&&e===l?m=w=B:(m=ki((.4360747*a+.3850649*e+.1430804*l)/ce),w=ki((.0139322*a+.0971045*e+.7141733*l)/pe));let S=116*B-16;return[S<0?0:S,500*(m-B),200*(B-w),u]}function Cr(a){return a<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function ki(a){return a>ii?Math.pow(a,1/3):a/oi+me}function fr([a,e,l,u]){let m=(a+16)/116,w=isNaN(e)?m:m+e/500,B=isNaN(l)?m:m-l/200;return m=1*Er(m),w=ce*Er(w),B=pe*Er(B),[br(3.1338561*w-1.6168667*m-.4906146*B),br(-.9787684*w+1.9161415*m+.033454*B),br(.0719453*w-.2289914*m+1.4052427*B),u]}function br(a){return(a=a<=.00304?12.92*a:1.055*Math.pow(a,1/2.4)-.055)<0?0:a>1?1:a}function Er(a){return a>Xe?a*a*a:oi*(a-me)}function Dt(a){return parseInt(a.padEnd(2,a),16)/255}function Ke(a,e){return Te(e?a/100:a,0,1)}function Te(a,e,l){return Math.min(Math.max(e,a),l)}function or(a){return!a.some(Number.isNaN)}let Lr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Ji{constructor(e,l,u,m=1,w=!0){this.r=e,this.g=l,this.b=u,this.a=m,w||(this.r*=m,this.g*=m,this.b*=m,m||this.overwriteGetter("rgb",[e,l,u,m]))}static parse(e){if(e instanceof Ji)return e;if(typeof e!="string")return;let l=function(u){if((u=u.toLowerCase().trim())==="transparent")return[0,0,0,0];let m=Lr[u];if(m){let[B,S,U]=m;return[B/255,S/255,U/255,1]}if(u.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(u)){let B=u.length<6?1:2,S=1;return[Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+=B)),Dt(u.slice(S,S+B)||"ff")]}if(u.startsWith("rgb")){let B=u.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(B){let[S,U,M,D,z,et,nt,st,mt,St,Vt,se]=B,Wt=[D||" ",nt||" ",St].join("");if(Wt===" "||Wt===" /"||Wt===",,"||Wt===",,,"){let $t=[M,et,mt].join(""),be=$t==="%%%"?100:$t===""?255:0;if(be){let Le=[Te(+U/be,0,1),Te(+z/be,0,1),Te(+st/be,0,1),Vt?Ke(+Vt,se):1];if(or(Le))return Le}}return}}let w=u.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(w){let[B,S,U,M,D,z,et,nt,st]=w,mt=[U||" ",D||" ",et].join("");if(mt===" "||mt===" /"||mt===",,"||mt===",,,"){let St=[+S,Te(+M,0,100),Te(+z,0,100),nt?Ke(+nt,st):1];if(or(St))return function([Vt,se,Wt,$t]){function be(Le){let ni=(Le+Vt/30)%12,bi=se*Math.min(Wt,1-Wt);return Wt-bi*Math.max(-1,Math.min(ni-3,9-ni,1))}return Vt=rr(Vt),se/=100,Wt/=100,[be(0),be(8),be(4),$t]}(St)}}}(e);return l?new Ji(...l,!1):void 0}get rgb(){let{r:e,g:l,b:u,a:m}=this,w=m||1/0;return this.overwriteGetter("rgb",[e/w,l/w,u/w,m])}get hcl(){return this.overwriteGetter("hcl",function(e){let[l,u,m,w]=zi(e),B=Math.sqrt(u*u+m*m);return[Math.round(1e4*B)?rr(Math.atan2(m,u)*Ui):NaN,B,l,w]}(this.rgb))}get lab(){return this.overwriteGetter("lab",zi(this.rgb))}overwriteGetter(e,l){return Object.defineProperty(this,e,{value:l}),l}toString(){let[e,l,u,m]=this.rgb;return`rgba(${[e,l,u].map(w=>Math.round(255*w)).join(",")},${m})`}}Ji.black=new Ji(0,0,0,1),Ji.white=new Ji(1,1,1,1),Ji.transparent=new Ji(0,0,0,0),Ji.red=new Ji(1,0,0,1);class Zr{constructor(e,l,u){this.sensitivity=e?l?"variant":"case":l?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,l){return this.collator.compare(e,l)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class bs{constructor(e,l,u,m,w){this.text=e,this.image=l,this.scale=u,this.fontStack=m,this.textColor=w}}class Sr{constructor(e){this.sections=e}static fromString(e){return new Sr([new bs(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Sr?e:Sr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class xr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof xr)return e;if(typeof e=="number")return new xr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let l of e)if(typeof l!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new xr(e)}}toString(){return JSON.stringify(this.values)}}let Wo=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class an{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof an)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let l=0;l=0&&a<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof l=="number"&&l>=0&&l<=255?u===void 0||typeof u=="number"&&u>=0&&u<=1?null:`Invalid rgba value [${[a,e,l,u].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof u=="number"?[a,e,l,u]:[a,e,l]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Gs(a){if(a===null||typeof a=="string"||typeof a=="boolean"||typeof a=="number"||a instanceof Ji||a instanceof Zr||a instanceof Sr||a instanceof xr||a instanceof an||a instanceof Kn)return!0;if(Array.isArray(a)){for(let e of a)if(!Gs(e))return!1;return!0}if(typeof a=="object"){for(let e in a)if(!Gs(a[e]))return!1;return!0}return!1}function Tr(a){if(a===null)return We;if(typeof a=="string")return $e;if(typeof a=="boolean")return di;if(typeof a=="number")return Se;if(a instanceof Ji)return Zi;if(a instanceof Zr)return tr;if(a instanceof Sr)return kr;if(a instanceof xr)return ft;if(a instanceof an)return q;if(a instanceof Kn)return Y;if(Array.isArray(a)){let e=a.length,l;for(let u of a){let m=Tr(u);if(l){if(l===m)continue;l=vi;break}l=m}return rt(l||vi,e)}return qi}function zo(a){let e=typeof a;return a===null?"":e==="string"||e==="number"||e==="boolean"?String(a):a instanceof Ji||a instanceof Sr||a instanceof xr||a instanceof an||a instanceof Kn?a.toString():JSON.stringify(a)}class Ur{constructor(e,l){this.type=e,this.value=l}static parse(e,l){if(e.length!==2)return l.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Gs(e[1]))return l.error("invalid value");let u=e[1],m=Tr(u),w=l.expectedType;return m.kind!=="array"||m.N!==0||!w||w.kind!=="array"||typeof w.N=="number"&&w.N!==0||(m=w),new Ur(m,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Qr{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let vs={string:$e,number:Se,boolean:di,object:qi};class _n{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u,m=1,w=e[0];if(w==="array"){let S,U;if(e.length>2){let M=e[1];if(typeof M!="string"||!(M in vs)||M==="object")return l.error('The item type argument of "array" must be one of string, number, boolean',1);S=vs[M],m++}else S=vi;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return l.error('The length argument to "array" must be a positive integer literal',2);U=e[2],m++}u=rt(S,U)}else{if(!vs[w])throw new Error(`Types doesn't contain name = ${w}`);u=vs[w]}let B=[];for(;me.outputDefined())}}let Bo={"to-boolean":di,"to-color":Zi,"to-number":Se,"to-string":$e};class gt{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u=e[0];if(!Bo[u])throw new Error(`Can't parse ${u} as it is not part of the known types`);if((u==="to-boolean"||u==="to-string")&&e.length!==2)return l.error("Expected one argument.");let m=Bo[u],w=[];for(let B=1;B4?`Invalid rbga value ${JSON.stringify(l)}: expected an array containing either three or four numeric values.`:Oo(l[0],l[1],l[2],l[3]),!u))return new Ji(l[0]/255,l[1]/255,l[2]/255,l[3])}throw new Qr(u||`Could not parse color from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"padding":{let l;for(let u of this.args){l=u.evaluate(e);let m=xr.parse(l);if(m)return m}throw new Qr(`Could not parse padding from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"variableAnchorOffsetCollection":{let l;for(let u of this.args){l=u.evaluate(e);let m=an.parse(l);if(m)return m}throw new Qr(`Could not parse variableAnchorOffsetCollection from value '${typeof l=="string"?l:JSON.stringify(l)}'`)}case"number":{let l=null;for(let u of this.args){if(l=u.evaluate(e),l===null)return 0;let m=Number(l);if(!isNaN(m))return m}throw new Qr(`Could not convert ${JSON.stringify(l)} to number.`)}case"formatted":return Sr.fromString(zo(this.args[0].evaluate(e)));case"resolvedImage":return Kn.fromString(zo(this.args[0].evaluate(e)));default:return zo(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}let bt=["Unknown","Point","LineString","Polygon"];class ct{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?typeof this.feature.type=="number"?bt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let l=this._parseColorCache[e];return l||(l=this._parseColorCache[e]=Ji.parse(e)),l}}class Bt{constructor(e,l,u=[],m,w=new Vi,B=[]){this.registry=e,this.path=u,this.key=u.map(S=>`[${S}]`).join(""),this.scope=w,this.errors=B,this.expectedType=m,this._isConstant=l}parse(e,l,u,m,w={}){return l?this.concat(l,u,m)._parse(e,w):this._parse(e,w)}_parse(e,l){function u(m,w,B){return B==="assert"?new _n(w,[m]):B==="coerce"?new gt(w,[m]):m}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let m=e[0];if(typeof m!="string")return this.error(`Expression name must be a string, but found ${typeof m} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let w=this.registry[m];if(w){let B=w.parse(e,this);if(!B)return null;if(this.expectedType){let S=this.expectedType,U=B.type;if(S.kind!=="string"&&S.kind!=="number"&&S.kind!=="boolean"&&S.kind!=="object"&&S.kind!=="array"||U.kind!=="value")if(S.kind!=="color"&&S.kind!=="formatted"&&S.kind!=="resolvedImage"||U.kind!=="value"&&U.kind!=="string")if(S.kind!=="padding"||U.kind!=="value"&&U.kind!=="number"&&U.kind!=="array")if(S.kind!=="variableAnchorOffsetCollection"||U.kind!=="value"&&U.kind!=="array"){if(this.checkSubtype(S,U))return null}else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"coerce");else B=u(B,S,l.typeAnnotation||"assert")}if(!(B instanceof Ur)&&B.type.kind!=="resolvedImage"&&this._isConstant(B)){let S=new ct;try{B=new Ur(B.type,B.evaluate(S))}catch(U){return this.error(U.message),null}}return B}return this.error(`Unknown expression "${m}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,l,u){let m=typeof e=="number"?this.path.concat(e):this.path,w=u?this.scope.concat(u):this.scope;return new Bt(this.registry,this._isConstant,m,l||null,w,this.errors)}error(e,...l){let u=`${this.key}${l.map(m=>`[${m}]`).join("")}`;this.errors.push(new mi(u,e))}checkSubtype(e,l){let u=zt(e,l);return u&&this.error(u),u}}class Kt{constructor(e,l,u){this.type=tr,this.locale=u,this.caseSensitive=e,this.diacriticSensitive=l}static parse(e,l){if(e.length!==2)return l.error("Expected one argument.");let u=e[1];if(typeof u!="object"||Array.isArray(u))return l.error("Collator options argument must be an object.");let m=l.parse(u["case-sensitive"]!==void 0&&u["case-sensitive"],1,di);if(!m)return null;let w=l.parse(u["diacritic-sensitive"]!==void 0&&u["diacritic-sensitive"],1,di);if(!w)return null;let B=null;return u.locale&&(B=l.parse(u.locale,1,$e),!B)?null:new Kt(m,w,B)}evaluate(e){return new Zr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}let Yt=8192;function ae(a,e){a[0]=Math.min(a[0],e[0]),a[1]=Math.min(a[1],e[1]),a[2]=Math.max(a[2],e[0]),a[3]=Math.max(a[3],e[1])}function we(a,e){return!(a[0]<=e[0]||a[2]>=e[2]||a[1]<=e[1]||a[3]>=e[3])}function ve(a,e){let l=(180+a[0])/360,u=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,m=Math.pow(2,e.z);return[Math.round(l*m*Yt),Math.round(u*m*Yt)]}function Ie(a,e,l){let u=a[0]-e[0],m=a[1]-e[1],w=a[0]-l[0],B=a[1]-l[1];return u*B-w*m==0&&u*w<=0&&m*B<=0}function oe(a,e){let l=!1;for(let B=0,S=e.length;B(u=a)[1]!=(w=U[M+1])[1]>u[1]&&u[0]<(w[0]-m[0])*(u[1]-m[1])/(w[1]-m[1])+m[0]&&(l=!l)}}var u,m,w;return l}function ye(a,e){for(let l=0;l0&&S<0||B<0&&S>0}function Re(a,e,l){for(let M of l)for(let D=0;Dl[2]){let m=.5*u,w=a[0]-l[0]>m?-u:l[0]-a[0]>m?u:0;w===0&&(w=a[0]-l[2]>m?-u:l[2]-a[0]>m?u:0),a[0]+=w}ae(e,a)}function Fi(a,e,l,u){let m=Math.pow(2,u.z)*Yt,w=[u.x*Yt,u.y*Yt],B=[];for(let S of a)for(let U of S){let M=[U.x+w[0],U.y+w[1]];Ai(M,e,l,m),B.push(M)}return B}function Wi(a,e,l,u){let m=Math.pow(2,u.z)*Yt,w=[u.x*Yt,u.y*Yt],B=[];for(let U of a){let M=[];for(let D of U){let z=[D.x+w[0],D.y+w[1]];ae(e,z),M.push(z)}B.push(M)}if(e[2]-e[0]<=m/2){(S=e)[0]=S[1]=1/0,S[2]=S[3]=-1/0;for(let U of B)for(let M of U)Ai(M,e,l,m)}var S;return B}class nr{constructor(e,l){this.type=di,this.geojson=e,this.geometries=l}static parse(e,l){if(e.length!==2)return l.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Gs(e[1])){let u=e[1];if(u.type==="FeatureCollection"){let m=[];for(let w of u.features){let{type:B,coordinates:S}=w.geometry;B==="Polygon"&&m.push(S),B==="MultiPolygon"&&m.push(...S)}if(m.length)return new nr(u,{type:"MultiPolygon",coordinates:m})}else if(u.type==="Feature"){let m=u.geometry.type;if(m==="Polygon"||m==="MultiPolygon")return new nr(u,u.geometry)}else if(u.type==="Polygon"||u.type==="MultiPolygon")return new nr(u,u)}return l.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(l,u){let m=[1/0,1/0,-1/0,-1/0],w=[1/0,1/0,-1/0,-1/0],B=l.canonicalID();if(u.type==="Polygon"){let S=Pe(u.coordinates,w,B),U=Fi(l.geometry(),m,w,B);if(!we(m,w))return!1;for(let M of U)if(!oe(M,S))return!1}if(u.type==="MultiPolygon"){let S=Ue(u.coordinates,w,B),U=Fi(l.geometry(),m,w,B);if(!we(m,w))return!1;for(let M of U)if(!ye(M,S))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(l,u){let m=[1/0,1/0,-1/0,-1/0],w=[1/0,1/0,-1/0,-1/0],B=l.canonicalID();if(u.type==="Polygon"){let S=Pe(u.coordinates,w,B),U=Wi(l.geometry(),m,w,B);if(!we(m,w))return!1;for(let M of U)if(!Qi(M,S))return!1}if(u.type==="MultiPolygon"){let S=Ue(u.coordinates,w,B),U=Wi(l.geometry(),m,w,B);if(!we(m,w))return!1;for(let M of U)if(!Ri(M,S))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class ai{constructor(e,l){this.type=l.type,this.name=e,this.boundExpression=l}static parse(e,l){if(e.length!==2||typeof e[1]!="string")return l.error("'var' expression requires exactly one string literal argument.");let u=e[1];return l.scope.has(u)?new ai(u,l.scope.get(u)):l.error(`Unknown variable "${u}". Make sure "${u}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class dr{constructor(e,l,u,m){this.name=e,this.type=l,this._evaluate=u,this.args=m}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,l){let u=e[0],m=dr.definitions[u];if(!m)return l.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);let w=Array.isArray(m)?m[0]:m.type,B=Array.isArray(m)?[[m[1],m[2]]]:m.overloads,S=B.filter(([M])=>!Array.isArray(M)||M.length===e.length-1),U=null;for(let[M,D]of S){U=new Bt(l.registry,Or,l.path,null,l.scope);let z=[],et=!1;for(let nt=1;nt{return et=z,Array.isArray(et)?`(${et.map(ht).join(", ")})`:`(${ht(et.type)}...)`;var et}).join(" | "),D=[];for(let z=1;z{l=e?l&&Or(u):l&&u instanceof Ur}),!!l&&Gr(a)&&vn(a,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Gr(a){if(a instanceof dr&&(a.name==="get"&&a.args.length===1||a.name==="feature-state"||a.name==="has"&&a.args.length===1||a.name==="properties"||a.name==="geometry-type"||a.name==="id"||/^filter-/.test(a.name))||a instanceof nr)return!1;let e=!0;return a.eachChild(l=>{e&&!Gr(l)&&(e=!1)}),e}function xn(a){if(a instanceof dr&&a.name==="feature-state")return!1;let e=!0;return a.eachChild(l=>{e&&!xn(l)&&(e=!1)}),e}function vn(a,e){if(a instanceof dr&&e.indexOf(a.name)>=0)return!1;let l=!0;return a.eachChild(u=>{l&&!vn(u,e)&&(l=!1)}),l}function ws(a,e){let l=a.length-1,u,m,w=0,B=l,S=0;for(;w<=B;)if(S=Math.floor((w+B)/2),u=a[S],m=a[S+1],u<=e){if(S===l||ee))throw new Qr("Input is not a number.");B=S-1}return 0}class _o{constructor(e,l,u){this.type=e,this.input=l,this.labels=[],this.outputs=[];for(let[m,w]of u)this.labels.push(m),this.outputs.push(w)}static parse(e,l){if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");let u=l.parse(e[1],1,Se);if(!u)return null;let m=[],w=null;l.expectedType&&l.expectedType.kind!=="value"&&(w=l.expectedType);for(let B=1;B=S)return l.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',M);let z=l.parse(U,D,w);if(!z)return null;w=w||z.type,m.push([S,z])}return new _o(w,u,m)}evaluate(e){let l=this.labels,u=this.outputs;if(l.length===1)return u[0].evaluate(e);let m=this.input.evaluate(e);if(m<=l[0])return u[0].evaluate(e);let w=l.length;return m>=l[w-1]?u[w-1].evaluate(e):u[ws(l,m)].evaluate(e)}eachChild(e){e(this.input);for(let l of this.outputs)e(l)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Ic(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var yc=El;function El(a,e,l,u){this.cx=3*a,this.bx=3*(l-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=e,this.p2x=l,this.p2y=u}El.prototype={sampleCurveX:function(a){return((this.ax*a+this.bx)*a+this.cx)*a},sampleCurveY:function(a){return((this.ay*a+this.by)*a+this.cy)*a},sampleCurveDerivativeX:function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},solveCurveX:function(a,e){if(e===void 0&&(e=1e-6),a<0)return 0;if(a>1)return 1;for(var l=a,u=0;u<8;u++){var m=this.sampleCurveX(l)-a;if(Math.abs(m)m?B=l:S=l,l=.5*(S-B)+B;return l},solve:function(a,e){return this.sampleCurveY(this.solveCurveX(a,e))}};var el=Ic(yc);function Bs(a,e,l){return a+l*(e-a)}function to(a,e,l){return a.map((u,m)=>Bs(u,e[m],l))}let qn={number:Bs,color:function(a,e,l,u="rgb"){switch(u){case"rgb":{let[m,w,B,S]=to(a.rgb,e.rgb,l);return new Ji(m,w,B,S,!1)}case"hcl":{let[m,w,B,S]=a.hcl,[U,M,D,z]=e.hcl,et,nt;if(isNaN(m)||isNaN(U))isNaN(m)?isNaN(U)?et=NaN:(et=U,B!==1&&B!==0||(nt=M)):(et=m,D!==1&&D!==0||(nt=w));else{let se=U-m;U>m&&se>180?se-=360:U180&&(se+=360),et=m+l*se}let[st,mt,St,Vt]=function([se,Wt,$t,be]){return se=isNaN(se)?0:se*Ni,fr([$t,Math.cos(se)*Wt,Math.sin(se)*Wt,be])}([et,nt??Bs(w,M,l),Bs(B,D,l),Bs(S,z,l)]);return new Ji(st,mt,St,Vt,!1)}case"lab":{let[m,w,B,S]=fr(to(a.lab,e.lab,l));return new Ji(m,w,B,S,!1)}}},array:to,padding:function(a,e,l){return new xr(to(a.values,e.values,l))},variableAnchorOffsetCollection:function(a,e,l){let u=a.values,m=e.values;if(u.length!==m.length)throw new Qr(`Cannot interpolate values of different length. from: ${a.toString()}, to: ${e.toString()}`);let w=[];for(let B=0;Btypeof D!="number"||D<0||D>1))return l.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);m={name:"cubic-bezier",controlPoints:M}}}if(e.length-1<4)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return l.error("Expected an even number of arguments.");if(w=l.parse(w,2,Se),!w)return null;let S=[],U=null;u==="interpolate-hcl"||u==="interpolate-lab"?U=Zi:l.expectedType&&l.expectedType.kind!=="value"&&(U=l.expectedType);for(let M=0;M=D)return l.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',et);let st=l.parse(z,nt,U);if(!st)return null;U=U||st.type,S.push([D,st])}return re(U,Se)||re(U,Zi)||re(U,ft)||re(U,q)||re(U,rt(Se))?new cn(U,u,m,w,S):l.error(`Type ${ht(U)} is not interpolatable.`)}evaluate(e){let l=this.labels,u=this.outputs;if(l.length===1)return u[0].evaluate(e);let m=this.input.evaluate(e);if(m<=l[0])return u[0].evaluate(e);let w=l.length;if(m>=l[w-1])return u[w-1].evaluate(e);let B=ws(l,m),S=cn.interpolationFactor(this.interpolation,m,l[B],l[B+1]),U=u[B].evaluate(e),M=u[B+1].evaluate(e);switch(this.operator){case"interpolate":return qn[this.type.kind](U,M,S);case"interpolate-hcl":return qn.color(U,M,S,"hcl");case"interpolate-lab":return qn.color(U,M,S,"lab")}}eachChild(e){e(this.input);for(let l of this.outputs)e(l)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function xo(a,e,l,u){let m=u-l,w=a-l;return m===0?0:e===1?w/m:(Math.pow(e,w)-1)/(Math.pow(e,m)-1)}class lr{constructor(e,l){this.type=e,this.args=l}static parse(e,l){if(e.length<2)return l.error("Expectected at least one argument.");let u=null,m=l.expectedType;m&&m.kind!=="value"&&(u=m);let w=[];for(let S of e.slice(1)){let U=l.parse(S,1+w.length,u,void 0,{typeAnnotation:"omit"});if(!U)return null;u=u||U.type,w.push(U)}if(!u)throw new Error("No output type");let B=m&&w.some(S=>zt(m,S.type));return new lr(B?vi:u,w)}evaluate(e){let l,u=null,m=0;for(let w of this.args)if(m++,u=w.evaluate(e),u&&u instanceof Kn&&!u.available&&(l||(l=u.name),u=null,m===this.args.length&&(u=l)),u!==null)break;return u}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class Sa{constructor(e,l){this.type=l.type,this.bindings=[].concat(e),this.result=l}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let l of this.bindings)e(l[1]);e(this.result)}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let u=[];for(let w=1;w=u.length)throw new Qr(`Array index out of bounds: ${l} > ${u.length-1}.`);if(l!==Math.floor(l))throw new Qr(`Array index must be an integer, but found ${l} instead.`);return u[l]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class fA{constructor(e,l){this.type=di,this.needle=e,this.haystack=l}static parse(e,l){if(e.length!==3)return l.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,vi);return u&&m?Xt(u.type,[di,$e,Se,We,vi])?new fA(u,m):l.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(u.type)} instead`):null}evaluate(e){let l=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!u)return!1;if(!Mt(l,["boolean","string","number","null"]))throw new Qr(`Expected first argument to be of type boolean, string, number or null, but found ${ht(Tr(l))} instead.`);if(!Mt(u,["string","array"]))throw new Qr(`Expected second argument to be of type array or string, but found ${ht(Tr(u))} instead.`);return u.indexOf(l)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Fa{constructor(e,l,u){this.type=Se,this.needle=e,this.haystack=l,this.fromIndex=u}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,vi);if(!u||!m)return null;if(!Xt(u.type,[di,$e,Se,We,vi]))return l.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(u.type)} instead`);if(e.length===4){let w=l.parse(e[3],3,Se);return w?new Fa(u,m,w):null}return new Fa(u,m)}evaluate(e){let l=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!Mt(l,["boolean","string","number","null"]))throw new Qr(`Expected first argument to be of type boolean, string, number or null, but found ${ht(Tr(l))} instead.`);if(!Mt(u,["string","array"]))throw new Qr(`Expected second argument to be of type array or string, but found ${ht(Tr(u))} instead.`);if(this.fromIndex){let m=this.fromIndex.evaluate(e);return u.indexOf(l,m)}return u.indexOf(l)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class eo{constructor(e,l,u,m,w,B){this.inputType=e,this.type=l,this.input=u,this.cases=m,this.outputs=w,this.otherwise=B}static parse(e,l){if(e.length<5)return l.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return l.error("Expected an even number of arguments.");let u,m;l.expectedType&&l.expectedType.kind!=="value"&&(m=l.expectedType);let w={},B=[];for(let M=2;MNumber.MAX_SAFE_INTEGER)return et.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof st=="number"&&Math.floor(st)!==st)return et.error("Numeric branch labels must be integer values.");if(u){if(et.checkSubtype(u,Tr(st)))return null}else u=Tr(st);if(w[String(st)]!==void 0)return et.error("Branch labels must be unique.");w[String(st)]=B.length}let nt=l.parse(z,M,m);if(!nt)return null;m=m||nt.type,B.push(nt)}let S=l.parse(e[1],1,vi);if(!S)return null;let U=l.parse(e[e.length-1],e.length-1,m);return U?S.type.kind!=="value"&&l.concat(1).checkSubtype(u,S.type)?null:new eo(u,m,S,w,B,U):null}evaluate(e){let l=this.input.evaluate(e);return(Tr(l)===this.inputType&&this.outputs[this.cases[l]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class So{constructor(e,l,u){this.type=e,this.branches=l,this.otherwise=u}static parse(e,l){if(e.length<4)return l.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return l.error("Expected an odd number of arguments.");let u;l.expectedType&&l.expectedType.kind!=="value"&&(u=l.expectedType);let m=[];for(let B=1;Bl.outputDefined())&&this.otherwise.outputDefined()}}class mA{constructor(e,l,u,m){this.type=e,this.input=l,this.beginIndex=u,this.endIndex=m}static parse(e,l){if(e.length<=2||e.length>=5)return l.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let u=l.parse(e[1],1,vi),m=l.parse(e[2],2,Se);if(!u||!m)return null;if(!Xt(u.type,[rt(vi),$e,vi]))return l.error(`Expected first argument to be of type array or string, but found ${ht(u.type)} instead`);if(e.length===4){let w=l.parse(e[3],3,Se);return w?new mA(u.type,u,m,w):null}return new mA(u.type,u,m)}evaluate(e){let l=this.input.evaluate(e),u=this.beginIndex.evaluate(e);if(!Mt(l,["string","array"]))throw new Qr(`Expected first argument to be of type array or string, but found ${ht(Tr(l))} instead.`);if(this.endIndex){let m=this.endIndex.evaluate(e);return l.slice(u,m)}return l.slice(u)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Jo(a,e){return a==="=="||a==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Rs(a,e,l,u){return u.compare(e,l)===0}function Fo(a,e,l){let u=a!=="=="&&a!=="!=";return class Ab{constructor(w,B,S){this.type=di,this.lhs=w,this.rhs=B,this.collator=S,this.hasUntypedArgument=w.type.kind==="value"||B.type.kind==="value"}static parse(w,B){if(w.length!==3&&w.length!==4)return B.error("Expected two or three arguments.");let S=w[0],U=B.parse(w[1],1,vi);if(!U)return null;if(!Jo(S,U.type))return B.concat(1).error(`"${S}" comparisons are not supported for type '${ht(U.type)}'.`);let M=B.parse(w[2],2,vi);if(!M)return null;if(!Jo(S,M.type))return B.concat(2).error(`"${S}" comparisons are not supported for type '${ht(M.type)}'.`);if(U.type.kind!==M.type.kind&&U.type.kind!=="value"&&M.type.kind!=="value")return B.error(`Cannot compare types '${ht(U.type)}' and '${ht(M.type)}'.`);u&&(U.type.kind==="value"&&M.type.kind!=="value"?U=new _n(M.type,[U]):U.type.kind!=="value"&&M.type.kind==="value"&&(M=new _n(U.type,[M])));let D=null;if(w.length===4){if(U.type.kind!=="string"&&M.type.kind!=="string"&&U.type.kind!=="value"&&M.type.kind!=="value")return B.error("Cannot use collator to compare non-string types.");if(D=B.parse(w[3],3,tr),!D)return null}return new Ab(U,M,D)}evaluate(w){let B=this.lhs.evaluate(w),S=this.rhs.evaluate(w);if(u&&this.hasUntypedArgument){let U=Tr(B),M=Tr(S);if(U.kind!==M.kind||U.kind!=="string"&&U.kind!=="number")throw new Qr(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${U.kind}, ${M.kind}) instead.`)}if(this.collator&&!u&&this.hasUntypedArgument){let U=Tr(B),M=Tr(S);if(U.kind!=="string"||M.kind!=="string")return e(w,B,S)}return this.collator?l(w,B,S,this.collator.evaluate(w)):e(w,B,S)}eachChild(w){w(this.lhs),w(this.rhs),this.collator&&w(this.collator)}outputDefined(){return!0}}}let ka=Fo("==",function(a,e,l){return e===l},Rs),bc=Fo("!=",function(a,e,l){return e!==l},function(a,e,l,u){return!Rs(0,e,l,u)}),CA=Fo("<",function(a,e,l){return e",function(a,e,l){return e>l},function(a,e,l,u){return u.compare(e,l)>0}),il=Fo("<=",function(a,e,l){return e<=l},function(a,e,l,u){return u.compare(e,l)<=0}),rl=Fo(">=",function(a,e,l){return e>=l},function(a,e,l,u){return u.compare(e,l)>=0});class IA{constructor(e,l,u,m,w){this.type=$e,this.number=e,this.locale=l,this.currency=u,this.minFractionDigits=m,this.maxFractionDigits=w}static parse(e,l){if(e.length!==3)return l.error("Expected two arguments.");let u=l.parse(e[1],1,Se);if(!u)return null;let m=e[2];if(typeof m!="object"||Array.isArray(m))return l.error("NumberFormat options argument must be an object.");let w=null;if(m.locale&&(w=l.parse(m.locale,1,$e),!w))return null;let B=null;if(m.currency&&(B=l.parse(m.currency,1,$e),!B))return null;let S=null;if(m["min-fraction-digits"]&&(S=l.parse(m["min-fraction-digits"],1,Se),!S))return null;let U=null;return m["max-fraction-digits"]&&(U=l.parse(m["max-fraction-digits"],1,Se),!U)?null:new IA(u,w,B,S,U)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Xo{constructor(e){this.type=kr,this.sections=e}static parse(e,l){if(e.length<2)return l.error("Expected at least one argument.");let u=e[1];if(!Array.isArray(u)&&typeof u=="object")return l.error("First argument must be an image or text section.");let m=[],w=!1;for(let B=1;B<=e.length-1;++B){let S=e[B];if(w&&typeof S=="object"&&!Array.isArray(S)){w=!1;let U=null;if(S["font-scale"]&&(U=l.parse(S["font-scale"],1,Se),!U))return null;let M=null;if(S["text-font"]&&(M=l.parse(S["text-font"],1,rt($e)),!M))return null;let D=null;if(S["text-color"]&&(D=l.parse(S["text-color"],1,Zi),!D))return null;let z=m[m.length-1];z.scale=U,z.font=M,z.textColor=D}else{let U=l.parse(e[B],1,vi);if(!U)return null;let M=U.type.kind;if(M!=="string"&&M!=="value"&&M!=="null"&&M!=="resolvedImage")return l.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");w=!0,m.push({content:U,scale:null,font:null,textColor:null})}}return new Xo(m)}evaluate(e){return new Sr(this.sections.map(l=>{let u=l.content.evaluate(e);return Tr(u)===Y?new bs("",u,null,null,null):new bs(zo(u),null,l.scale?l.scale.evaluate(e):null,l.font?l.font.evaluate(e).join(","):null,l.textColor?l.textColor.evaluate(e):null)}))}eachChild(e){for(let l of this.sections)e(l.content),l.scale&&e(l.scale),l.font&&e(l.font),l.textColor&&e(l.textColor)}outputDefined(){return!1}}class La{constructor(e){this.type=Y,this.input=e}static parse(e,l){if(e.length!==2)return l.error("Expected two arguments.");let u=l.parse(e[1],1,$e);return u?new La(u):l.error("No image name provided.")}evaluate(e){let l=this.input.evaluate(e),u=Kn.fromString(l);return u&&e.availableImages&&(u.available=e.availableImages.indexOf(l)>-1),u}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ea{constructor(e){this.type=Se,this.input=e}static parse(e,l){if(e.length!==2)return l.error(`Expected 1 argument, but found ${e.length-1} instead.`);let u=l.parse(e[1],1);return u?u.type.kind!=="array"&&u.type.kind!=="string"&&u.type.kind!=="value"?l.error(`Expected argument of type string or array, but found ${ht(u.type)} instead.`):new Ea(u):null}evaluate(e){let l=this.input.evaluate(e);if(typeof l=="string"||Array.isArray(l))return l.length;throw new Qr(`Expected value to be of type string or array, but found ${ht(Tr(l))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Yo={"==":ka,"!=":bc,">":vc,"<":CA,">=":rl,"<=":il,array:_n,at:pA,boolean:_n,case:So,coalesce:lr,collator:Kt,format:Xo,image:La,in:fA,"index-of":Fa,interpolate:cn,"interpolate-hcl":cn,"interpolate-lab":cn,length:Ea,let:Sa,literal:Ur,match:eo,number:_n,"number-format":IA,object:_n,slice:mA,step:_o,string:_n,"to-boolean":gt,"to-color":gt,"to-number":gt,"to-string":gt,var:ai,within:nr};function Tl(a,[e,l,u,m]){e=e.evaluate(a),l=l.evaluate(a),u=u.evaluate(a);let w=m?m.evaluate(a):1,B=Oo(e,l,u,w);if(B)throw new Qr(B);return new Ji(e/255,l/255,u/255,w,!1)}function Ta(a,e){return a in e}function jo(a,e){let l=e[a];return l===void 0?null:l}function io(a){return{type:a}}function qo(a){return{result:"success",value:a}}function ko(a){return{result:"error",value:a}}function Q(a){return a["property-type"]==="data-driven"||a["property-type"]==="cross-faded-data-driven"}function it(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")>-1}function Et(a){return!!a.expression&&a.expression.interpolated}function Nt(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":a===null?"null":typeof a}function ue(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function _e(a){return a}function Ve(a,e){let l=e.type==="color",u=a.stops&&typeof a.stops[0][0]=="object",m=u||!(u||a.property!==void 0),w=a.type||(Et(e)?"exponential":"interval");if(l||e.type==="padding"){let D=l?Ji.parse:xr.parse;(a=Oi({},a)).stops&&(a.stops=a.stops.map(z=>[z[0],D(z[1])])),a.default=D(a.default?a.default:e.default)}if(a.colorSpace&&(B=a.colorSpace)!=="rgb"&&B!=="hcl"&&B!=="lab")throw new Error(`Unknown color space: "${a.colorSpace}"`);var B;let S,U,M;if(w==="exponential")S=ar;else if(w==="interval")S=xi;else if(w==="categorical"){S=Di,U=Object.create(null);for(let D of a.stops)U[D[0]]=D[1];M=typeof a.stops[0][0]}else{if(w!=="identity")throw new Error(`Unknown function type "${w}"`);S=Ci}if(u){let D={},z=[];for(let st=0;stst[0]),evaluate:({zoom:st},mt)=>ar({stops:et,base:a.base},e,st).evaluate(st,mt)}}if(m){let D=w==="exponential"?{name:"exponential",base:a.base!==void 0?a.base:1}:null;return{kind:"camera",interpolationType:D,interpolationFactor:cn.interpolationFactor.bind(void 0,D),zoomStops:a.stops.map(z=>z[0]),evaluate:({zoom:z})=>S(a,e,z,U,M)}}return{kind:"source",evaluate(D,z){let et=z&&z.properties?z.properties[a.property]:void 0;return et===void 0?li(a.default,e.default):S(a,e,et,U,M)}}}function li(a,e,l){return a!==void 0?a:e!==void 0?e:l!==void 0?l:void 0}function Di(a,e,l,u,m){return li(typeof l===m?u[l]:void 0,a.default,e.default)}function xi(a,e,l){if(Nt(l)!=="number")return li(a.default,e.default);let u=a.stops.length;if(u===1||l<=a.stops[0][0])return a.stops[0][1];if(l>=a.stops[u-1][0])return a.stops[u-1][1];let m=ws(a.stops.map(w=>w[0]),l);return a.stops[m][1]}function ar(a,e,l){let u=a.base!==void 0?a.base:1;if(Nt(l)!=="number")return li(a.default,e.default);let m=a.stops.length;if(m===1||l<=a.stops[0][0])return a.stops[0][1];if(l>=a.stops[m-1][0])return a.stops[m-1][1];let w=ws(a.stops.map(D=>D[0]),l),B=function(D,z,et,nt){let st=nt-et,mt=D-et;return st===0?0:z===1?mt/st:(Math.pow(z,mt)-1)/(Math.pow(z,st)-1)}(l,u,a.stops[w][0],a.stops[w+1][0]),S=a.stops[w][1],U=a.stops[w+1][1],M=qn[e.type]||_e;return typeof S.evaluate=="function"?{evaluate(...D){let z=S.evaluate.apply(void 0,D),et=U.evaluate.apply(void 0,D);if(z!==void 0&&et!==void 0)return M(z,et,B,a.colorSpace)}}:M(S,U,B,a.colorSpace)}function Ci(a,e,l){switch(e.type){case"color":l=Ji.parse(l);break;case"formatted":l=Sr.fromString(l.toString());break;case"resolvedImage":l=Kn.fromString(l.toString());break;case"padding":l=xr.parse(l);break;default:Nt(l)===e.type||e.type==="enum"&&e.values[l]||(l=void 0)}return li(l,a.default,e.default)}dr.register(Yo,{error:[{kind:"error"},[$e],(a,[e])=>{throw new Qr(e.evaluate(a))}],typeof:[$e,[vi],(a,[e])=>ht(Tr(e.evaluate(a)))],"to-rgba":[rt(Se,4),[Zi],(a,[e])=>{let[l,u,m,w]=e.evaluate(a).rgb;return[255*l,255*u,255*m,w]}],rgb:[Zi,[Se,Se,Se],Tl],rgba:[Zi,[Se,Se,Se,Se],Tl],has:{type:di,overloads:[[[$e],(a,[e])=>Ta(e.evaluate(a),a.properties())],[[$e,qi],(a,[e,l])=>Ta(e.evaluate(a),l.evaluate(a))]]},get:{type:vi,overloads:[[[$e],(a,[e])=>jo(e.evaluate(a),a.properties())],[[$e,qi],(a,[e,l])=>jo(e.evaluate(a),l.evaluate(a))]]},"feature-state":[vi,[$e],(a,[e])=>jo(e.evaluate(a),a.featureState||{})],properties:[qi,[],a=>a.properties()],"geometry-type":[$e,[],a=>a.geometryType()],id:[vi,[],a=>a.id()],zoom:[Se,[],a=>a.globals.zoom],"heatmap-density":[Se,[],a=>a.globals.heatmapDensity||0],"line-progress":[Se,[],a=>a.globals.lineProgress||0],accumulated:[vi,[],a=>a.globals.accumulated===void 0?null:a.globals.accumulated],"+":[Se,io(Se),(a,e)=>{let l=0;for(let u of e)l+=u.evaluate(a);return l}],"*":[Se,io(Se),(a,e)=>{let l=1;for(let u of e)l*=u.evaluate(a);return l}],"-":{type:Se,overloads:[[[Se,Se],(a,[e,l])=>e.evaluate(a)-l.evaluate(a)],[[Se],(a,[e])=>-e.evaluate(a)]]},"/":[Se,[Se,Se],(a,[e,l])=>e.evaluate(a)/l.evaluate(a)],"%":[Se,[Se,Se],(a,[e,l])=>e.evaluate(a)%l.evaluate(a)],ln2:[Se,[],()=>Math.LN2],pi:[Se,[],()=>Math.PI],e:[Se,[],()=>Math.E],"^":[Se,[Se,Se],(a,[e,l])=>Math.pow(e.evaluate(a),l.evaluate(a))],sqrt:[Se,[Se],(a,[e])=>Math.sqrt(e.evaluate(a))],log10:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))/Math.LN10],ln:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))],log2:[Se,[Se],(a,[e])=>Math.log(e.evaluate(a))/Math.LN2],sin:[Se,[Se],(a,[e])=>Math.sin(e.evaluate(a))],cos:[Se,[Se],(a,[e])=>Math.cos(e.evaluate(a))],tan:[Se,[Se],(a,[e])=>Math.tan(e.evaluate(a))],asin:[Se,[Se],(a,[e])=>Math.asin(e.evaluate(a))],acos:[Se,[Se],(a,[e])=>Math.acos(e.evaluate(a))],atan:[Se,[Se],(a,[e])=>Math.atan(e.evaluate(a))],min:[Se,io(Se),(a,e)=>Math.min(...e.map(l=>l.evaluate(a)))],max:[Se,io(Se),(a,e)=>Math.max(...e.map(l=>l.evaluate(a)))],abs:[Se,[Se],(a,[e])=>Math.abs(e.evaluate(a))],round:[Se,[Se],(a,[e])=>{let l=e.evaluate(a);return l<0?-Math.round(-l):Math.round(l)}],floor:[Se,[Se],(a,[e])=>Math.floor(e.evaluate(a))],ceil:[Se,[Se],(a,[e])=>Math.ceil(e.evaluate(a))],"filter-==":[di,[$e,vi],(a,[e,l])=>a.properties()[e.value]===l.value],"filter-id-==":[di,[vi],(a,[e])=>a.id()===e.value],"filter-type-==":[di,[$e],(a,[e])=>a.geometryType()===e.value],"filter-<":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u{let l=a.id(),u=e.value;return typeof l==typeof u&&l":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u>m}],"filter-id->":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l>u}],"filter-<=":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u<=m}],"filter-id-<=":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l<=u}],"filter->=":[di,[$e,vi],(a,[e,l])=>{let u=a.properties()[e.value],m=l.value;return typeof u==typeof m&&u>=m}],"filter-id->=":[di,[vi],(a,[e])=>{let l=a.id(),u=e.value;return typeof l==typeof u&&l>=u}],"filter-has":[di,[vi],(a,[e])=>e.value in a.properties()],"filter-has-id":[di,[],a=>a.id()!==null&&a.id()!==void 0],"filter-type-in":[di,[rt($e)],(a,[e])=>e.value.indexOf(a.geometryType())>=0],"filter-id-in":[di,[rt(vi)],(a,[e])=>e.value.indexOf(a.id())>=0],"filter-in-small":[di,[$e,rt(vi)],(a,[e,l])=>l.value.indexOf(a.properties()[e.value])>=0],"filter-in-large":[di,[$e,rt(vi)],(a,[e,l])=>function(u,m,w,B){for(;w<=B;){let S=w+B>>1;if(m[S]===u)return!0;m[S]>u?B=S-1:w=S+1}return!1}(a.properties()[e.value],l.value,0,l.value.length-1)],all:{type:di,overloads:[[[di,di],(a,[e,l])=>e.evaluate(a)&&l.evaluate(a)],[io(di),(a,e)=>{for(let l of e)if(!l.evaluate(a))return!1;return!0}]]},any:{type:di,overloads:[[[di,di],(a,[e,l])=>e.evaluate(a)||l.evaluate(a)],[io(di),(a,e)=>{for(let l of e)if(l.evaluate(a))return!0;return!1}]]},"!":[di,[di],(a,[e])=>!e.evaluate(a)],"is-supported-script":[di,[$e],(a,[e])=>{let l=a.globals&&a.globals.isSupportedScript;return!l||l(e.evaluate(a))}],upcase:[$e,[$e],(a,[e])=>e.evaluate(a).toUpperCase()],downcase:[$e,[$e],(a,[e])=>e.evaluate(a).toLowerCase()],concat:[$e,io(vi),(a,e)=>e.map(l=>zo(l.evaluate(a))).join("")],"resolved-locale":[$e,[tr],(a,[e])=>e.evaluate(a).resolvedLocale()]});class Vr{constructor(e,l){var u;this.expression=e,this._warningHistory={},this._evaluator=new ct,this._defaultValue=l?(u=l).type==="color"&&ue(u.default)?new Ji(0,0,0,0):u.type==="color"?Ji.parse(u.default)||null:u.type==="padding"?xr.parse(u.default)||null:u.type==="variableAnchorOffsetCollection"?an.parse(u.default)||null:u.default===void 0?null:u.default:null,this._enumValues=l&&l.type==="enum"?l.values:null}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._evaluator.globals=e,this._evaluator.feature=l,this._evaluator.featureState=u,this._evaluator.canonical=m,this._evaluator.availableImages=w||null,this._evaluator.formattedSection=B,this.expression.evaluate(this._evaluator)}evaluate(e,l,u,m,w,B){this._evaluator.globals=e,this._evaluator.feature=l||null,this._evaluator.featureState=u||null,this._evaluator.canonical=m,this._evaluator.availableImages=w||null,this._evaluator.formattedSection=B||null;try{let S=this.expression.evaluate(this._evaluator);if(S==null||typeof S=="number"&&S!=S)return this._defaultValue;if(this._enumValues&&!(S in this._enumValues))throw new Qr(`Expected value to be one of ${Object.keys(this._enumValues).map(U=>JSON.stringify(U)).join(", ")}, but found ${JSON.stringify(S)} instead.`);return S}catch(S){return this._warningHistory[S.message]||(this._warningHistory[S.message]=!0,typeof console<"u"&&console.warn(S.message)),this._defaultValue}}}function Xi(a){return Array.isArray(a)&&a.length>0&&typeof a[0]=="string"&&a[0]in Yo}function Yi(a,e){let l=new Bt(Yo,Or,[],e?function(m){let w={color:Zi,string:$e,number:Se,enum:$e,boolean:di,formatted:kr,padding:ft,resolvedImage:Y,variableAnchorOffsetCollection:q};return m.type==="array"?rt(w[m.value]||vi,m.length):w[m.type]}(e):void 0),u=l.parse(a,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?qo(new Vr(u,e)):ko(l.errors)}class un{constructor(e,l){this.kind=e,this._styleExpression=l,this.isStateDependent=e!=="constant"&&!xn(l.expression)}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._styleExpression.evaluateWithoutErrorHandling(e,l,u,m,w,B)}evaluate(e,l,u,m,w,B){return this._styleExpression.evaluate(e,l,u,m,w,B)}}class hn{constructor(e,l,u,m){this.kind=e,this.zoomStops=u,this._styleExpression=l,this.isStateDependent=e!=="camera"&&!xn(l.expression),this.interpolationType=m}evaluateWithoutErrorHandling(e,l,u,m,w,B){return this._styleExpression.evaluateWithoutErrorHandling(e,l,u,m,w,B)}evaluate(e,l,u,m,w,B){return this._styleExpression.evaluate(e,l,u,m,w,B)}interpolationFactor(e,l,u){return this.interpolationType?cn.interpolationFactor(this.interpolationType,e,l,u):0}}function Hs(a,e){let l=Yi(a,e);if(l.result==="error")return l;let u=l.value.expression,m=Gr(u);if(!m&&!Q(e))return ko([new mi("","data expressions not supported")]);let w=vn(u,["zoom"]);if(!w&&!it(e))return ko([new mi("","zoom expressions not supported")]);let B=Zs(u);return B||w?B instanceof mi?ko([B]):B instanceof cn&&!Et(e)?ko([new mi("",'"interpolate" expressions cannot be used with this property')]):qo(B?new hn(m?"camera":"composite",l.value,B.labels,B instanceof cn?B.interpolation:void 0):new un(m?"constant":"source",l.value)):ko([new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class $n{constructor(e,l){this._parameters=e,this._specification=l,Oi(this,Ve(this._parameters,this._specification))}static deserialize(e){return new $n(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Zs(a){let e=null;if(a instanceof Sa)e=Zs(a.result);else if(a instanceof lr){for(let l of a.args)if(e=Zs(l),e)break}else(a instanceof _o||a instanceof cn)&&a.input instanceof dr&&a.input.name==="zoom"&&(e=a);return e instanceof mi||a.eachChild(l=>{let u=Zs(l);u instanceof mi?e=u:!e&&u?e=new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&u&&e!==u&&(e=new mi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function yA(a){if(a===!0||a===!1)return!0;if(!Array.isArray(a)||a.length===0)return!1;switch(a[0]){case"has":return a.length>=2&&a[1]!=="$id"&&a[1]!=="$type";case"in":return a.length>=3&&(typeof a[1]!="string"||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return a.length!==3||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(let e of a.slice(1))if(!yA(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}let bA={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ga(a){if(a==null)return{filter:()=>!0,needGeometry:!1};yA(a)||(a=Lo(a));let e=Yi(a,bA);if(e.result==="error")throw new Error(e.value.map(l=>`${l.key}: ${l.message}`).join(", "));return{filter:(l,u,m)=>e.value.evaluate(l,u,{},m),needGeometry:Qa(a)}}function Ua(a,e){return ae?1:0}function Qa(a){if(!Array.isArray(a))return!1;if(a[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?da(a[1],a[2],e):e==="any"?(l=a.slice(1),["any"].concat(l.map(Lo))):e==="all"?["all"].concat(a.slice(1).map(Lo)):e==="none"?["all"].concat(a.slice(1).map(Lo).map($o)):e==="in"?ts(a[1],a.slice(2)):e==="!in"?$o(ts(a[1],a.slice(2))):e==="has"?Ga(a[1]):e==="!has"?$o(Ga(a[1])):e!=="within"||a;var l}function da(a,e,l){switch(a){case"$type":return[`filter-type-${l}`,e];case"$id":return[`filter-id-${l}`,e];default:return[`filter-${l}`,a,e]}}function ts(a,e){if(e.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(l=>typeof l!=typeof e[0])?["filter-in-large",a,["literal",e.sort(Ua)]]:["filter-in-small",a,["literal",e]]}}function Ga(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function $o(a){return["!",a]}function pa(a){let e=typeof a;if(e==="number"||e==="boolean"||e==="string"||a==null)return JSON.stringify(a);if(Array.isArray(a)){let m="[";for(let w of a)m+=`${pa(w)},`;return`${m}]`}let l=Object.keys(a).sort(),u="{";for(let m=0;mu.maximum?[new Ce(e,l,`${l} is greater than the maximum value ${u.maximum}`)]:[]}function sl(a){let e=a.valueSpec,l=zr(a.value.type),u,m,w,B={},S=l!=="categorical"&&a.value.property===void 0,U=!S,M=Nt(a.value.stops)==="array"&&Nt(a.value.stops[0])==="array"&&Nt(a.value.stops[0][0])==="object",D=Wn({key:a.key,value:a.value,valueSpec:a.styleSpec.function,validateSpec:a.validateSpec,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(nt){if(l==="identity")return[new Ce(nt.key,nt.value,'identity function may not have a "stops" property')];let st=[],mt=nt.value;return st=st.concat(On({key:nt.key,value:mt,valueSpec:nt.valueSpec,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec,arrayElementValidator:z})),Nt(mt)==="array"&&mt.length===0&&st.push(new Ce(nt.key,mt,"array must have at least one stop")),st},default:function(nt){return nt.validateSpec({key:nt.key,value:nt.value,valueSpec:e,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec})}}});return l==="identity"&&S&&D.push(new Ce(a.key,a.value,'missing required property "property"')),l==="identity"||a.value.stops||D.push(new Ce(a.key,a.value,'missing required property "stops"')),l==="exponential"&&a.valueSpec.expression&&!Et(a.valueSpec)&&D.push(new Ce(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(U&&!Q(a.valueSpec)?D.push(new Ce(a.key,a.value,"property functions not supported")):S&&!it(a.valueSpec)&&D.push(new Ce(a.key,a.value,"zoom functions not supported"))),l!=="categorical"&&!M||a.value.property!==void 0||D.push(new Ce(a.key,a.value,'"property" property is required')),D;function z(nt){let st=[],mt=nt.value,St=nt.key;if(Nt(mt)!=="array")return[new Ce(St,mt,`array expected, ${Nt(mt)} found`)];if(mt.length!==2)return[new Ce(St,mt,`array length 2 expected, length ${mt.length} found`)];if(M){if(Nt(mt[0])!=="object")return[new Ce(St,mt,`object expected, ${Nt(mt[0])} found`)];if(mt[0].zoom===void 0)return[new Ce(St,mt,"object stop key must have zoom")];if(mt[0].value===void 0)return[new Ce(St,mt,"object stop key must have value")];if(w&&w>zr(mt[0].zoom))return[new Ce(St,mt[0].zoom,"stop zoom values must appear in ascending order")];zr(mt[0].zoom)!==w&&(w=zr(mt[0].zoom),m=void 0,B={}),st=st.concat(Wn({key:`${St}[0]`,value:mt[0],valueSpec:{zoom:{}},validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec,objectElementValidators:{zoom:Ra,value:et}}))}else st=st.concat(et({key:`${St}[0]`,value:mt[0],valueSpec:{},validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec},mt));return Xi(Ps(mt[1]))?st.concat([new Ce(`${St}[1]`,mt[1],"expressions are not allowed in function stops.")]):st.concat(nt.validateSpec({key:`${St}[1]`,value:mt[1],valueSpec:e,validateSpec:nt.validateSpec,style:nt.style,styleSpec:nt.styleSpec}))}function et(nt,st){let mt=Nt(nt.value),St=zr(nt.value),Vt=nt.value!==null?nt.value:st;if(u){if(mt!==u)return[new Ce(nt.key,Vt,`${mt} stop domain type must match previous stop domain type ${u}`)]}else u=mt;if(mt!=="number"&&mt!=="string"&&mt!=="boolean")return[new Ce(nt.key,Vt,"stop domain value must be a number, string, or boolean")];if(mt!=="number"&&l!=="categorical"){let se=`number expected, ${mt} found`;return Q(e)&&l===void 0&&(se+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ce(nt.key,Vt,se)]}return l!=="categorical"||mt!=="number"||isFinite(St)&&Math.floor(St)===St?l!=="categorical"&&mt==="number"&&m!==void 0&&Stnew Ce(`${a.key}${u.key}`,a.value,u.message));let l=e.value.expression||e.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!l.outputDefined())return[new Ce(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!xn(l))return[new Ce(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter"&&!xn(l))return[new Ce(a.key,a.value,'"feature-state" data expressions are not supported with filters.')];if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!vn(l,["zoom","feature-state"]))return[new Ce(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!Gr(l))return[new Ce(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function As(a){let e=a.key,l=a.value,u=a.valueSpec,m=[];return Array.isArray(u.values)?u.values.indexOf(zr(l))===-1&&m.push(new Ce(e,l,`expected one of [${u.values.join(", ")}], ${JSON.stringify(l)} found`)):Object.keys(u.values).indexOf(zr(l))===-1&&m.push(new Ce(e,l,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(l)} found`)),m}function Sn(a){return yA(Ps(a.value))?fa(Oi({},a,{expressionContext:"filter",valueSpec:{value:"boolean"}})):is(a)}function is(a){let e=a.value,l=a.key;if(Nt(e)!=="array")return[new Ce(l,e,`array expected, ${Nt(e)} found`)];let u=a.styleSpec,m,w=[];if(e.length<1)return[new Ce(l,e,"filter array must have at least 1 element")];switch(w=w.concat(As({key:`${l}[0]`,value:e[0],valueSpec:u.filter_operator,style:a.style,styleSpec:a.styleSpec})),zr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&zr(e[1])==="$type"&&w.push(new Ce(l,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&w.push(new Ce(l,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(m=Nt(e[1]),m!=="string"&&w.push(new Ce(`${l}[1]`,e[1],`string expected, ${m} found`)));for(let B=2;B{M in l&&e.push(new Ce(u,l[M],`"${M}" is prohibited for ref layers`))}),m.layers.forEach(M=>{zr(M.id)===S&&(U=M)}),U?U.ref?e.push(new Ce(u,l.ref,"ref cannot reference another ref layer")):B=zr(U.type):e.push(new Ce(u,l.ref,`ref layer "${S}" not found`))}else if(B!=="background")if(l.source){let U=m.sources&&m.sources[l.source],M=U&&zr(U.type);U?M==="vector"&&B==="raster"?e.push(new Ce(u,l.source,`layer "${l.id}" requires a raster source`)):M!=="raster-dem"&&B==="hillshade"?e.push(new Ce(u,l.source,`layer "${l.id}" requires a raster-dem source`)):M==="raster"&&B!=="raster"?e.push(new Ce(u,l.source,`layer "${l.id}" requires a vector source`)):M!=="vector"||l["source-layer"]?M==="raster-dem"&&B!=="hillshade"?e.push(new Ce(u,l.source,"raster-dem source can only be used with layer type 'hillshade'.")):B!=="line"||!l.paint||!l.paint["line-gradient"]||M==="geojson"&&U.lineMetrics||e.push(new Ce(u,l,`layer "${l.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ce(u,l,`layer "${l.id}" must specify a "source-layer"`)):e.push(new Ce(u,l.source,`source "${l.source}" not found`))}else e.push(new Ce(u,l,'missing required property "source"'));return e=e.concat(Wn({key:u,value:l,valueSpec:w.layer,style:a.style,styleSpec:a.styleSpec,validateSpec:a.validateSpec,objectElementValidators:{"*":()=>[],type:()=>a.validateSpec({key:`${u}.type`,value:l.type,valueSpec:w.layer.type,style:a.style,styleSpec:a.styleSpec,validateSpec:a.validateSpec,object:l,objectKey:"type"}),filter:Sn,layout:U=>Wn({layer:l,key:U.key,value:U.value,style:U.style,styleSpec:U.styleSpec,validateSpec:U.validateSpec,objectElementValidators:{"*":M=>ro(Oi({layerType:B},M))}}),paint:U=>Wn({layer:l,key:U.key,value:U.value,style:U.style,styleSpec:U.styleSpec,validateSpec:U.validateSpec,objectElementValidators:{"*":M=>_s(Oi({layerType:B},M))}})}})),e}function fn(a){let e=a.value,l=a.key,u=Nt(e);return u!=="string"?[new Ce(l,e,`string expected, ${u} found`)]:[]}let Ha={promoteId:function({key:a,value:e}){if(Nt(e)==="string")return fn({key:a,value:e});{let l=[];for(let u in e)l.push(...fn({key:`${a}.${u}`,value:e[u]}));return l}}};function vA(a){let e=a.value,l=a.key,u=a.styleSpec,m=a.style,w=a.validateSpec;if(!e.type)return[new Ce(l,e,'"type" is required')];let B=zr(e.type),S;switch(B){case"vector":case"raster":return S=Wn({key:l,value:e,valueSpec:u[`source_${B.replace("-","_")}`],style:a.style,styleSpec:u,objectElementValidators:Ha,validateSpec:w}),S;case"raster-dem":return S=function(U){var M;let D=(M=U.sourceName)!==null&&M!==void 0?M:"",z=U.value,et=U.styleSpec,nt=et.source_raster_dem,st=U.style,mt=[],St=Nt(z);if(z===void 0)return mt;if(St!=="object")return mt.push(new Ce("source_raster_dem",z,`object expected, ${St} found`)),mt;let Vt=zr(z.encoding)==="custom",se=["redFactor","greenFactor","blueFactor","baseShift"],Wt=U.value.encoding?`"${U.value.encoding}"`:"Default";for(let $t in z)!Vt&&se.includes($t)?mt.push(new Ce($t,z[$t],`In "${D}": "${$t}" is only valid when "encoding" is set to "custom". ${Wt} encoding found`)):nt[$t]?mt=mt.concat(U.validateSpec({key:$t,value:z[$t],valueSpec:nt[$t],validateSpec:U.validateSpec,style:st,styleSpec:et})):mt.push(new Ce($t,z[$t],`unknown property "${$t}"`));return mt}({sourceName:l,value:e,style:a.style,styleSpec:u,validateSpec:w}),S;case"geojson":if(S=Wn({key:l,value:e,valueSpec:u.source_geojson,style:m,styleSpec:u,validateSpec:w,objectElementValidators:Ha}),e.cluster)for(let U in e.clusterProperties){let[M,D]=e.clusterProperties[U],z=typeof M=="string"?[M,["accumulated"],["get",U]]:M;S.push(...fa({key:`${l}.${U}.map`,value:D,validateSpec:w,expressionContext:"cluster-map"})),S.push(...fa({key:`${l}.${U}.reduce`,value:z,validateSpec:w,expressionContext:"cluster-reduce"}))}return S;case"video":return Wn({key:l,value:e,valueSpec:u.source_video,style:m,validateSpec:w,styleSpec:u});case"image":return Wn({key:l,value:e,valueSpec:u.source_image,style:m,validateSpec:w,styleSpec:u});case"canvas":return[new Ce(l,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return As({key:`${l}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:m,validateSpec:w,styleSpec:u})}}function ta(a){let e=a.value,l=a.styleSpec,u=l.light,m=a.style,w=[],B=Nt(e);if(e===void 0)return w;if(B!=="object")return w=w.concat([new Ce("light",e,`object expected, ${B} found`)]),w;for(let S in e){let U=S.match(/^(.*)-transition$/);w=w.concat(U&&u[U[1]]&&u[U[1]].transition?a.validateSpec({key:S,value:e[S],valueSpec:l.transition,validateSpec:a.validateSpec,style:m,styleSpec:l}):u[S]?a.validateSpec({key:S,value:e[S],valueSpec:u[S],validateSpec:a.validateSpec,style:m,styleSpec:l}):[new Ce(S,e[S],`unknown property "${S}"`)])}return w}function Ms(a){let e=a.value,l=a.styleSpec,u=l.sky,m=a.style,w=Nt(e);if(e===void 0)return[];if(w!=="object")return[new Ce("sky",e,`object expected, ${w} found`)];let B=[];for(let S in e)B=B.concat(u[S]?Jr({key:S,value:e[S],valueSpec:u[S],style:m,styleSpec:l}):[new Ce(S,e[S],`unknown property "${S}"`)]);return B}function To(a){let e=a.value,l=a.styleSpec,u=l.terrain,m=a.style,w=[],B=Nt(e);if(e===void 0)return w;if(B!=="object")return w=w.concat([new Ce("terrain",e,`object expected, ${B} found`)]),w;for(let S in e)w=w.concat(u[S]?a.validateSpec({key:S,value:e[S],valueSpec:u[S],validateSpec:a.validateSpec,style:m,styleSpec:l}):[new Ce(S,e[S],`unknown property "${S}"`)]);return w}function no(a){let e=[],l=a.value,u=a.key;if(Array.isArray(l)){let m=[],w=[];for(let B in l)l[B].id&&m.includes(l[B].id)&&e.push(new Ce(u,l,`all the sprites' ids must be unique, but ${l[B].id} is duplicated`)),m.push(l[B].id),l[B].url&&w.includes(l[B].url)&&e.push(new Ce(u,l,`all the sprites' URLs must be unique, but ${l[B].url} is duplicated`)),w.push(l[B].url),e=e.concat(Wn({key:`${u}[${B}]`,value:l[B],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:a.validateSpec}));return e}return fn({key:u,value:l})}let Uo={"*":()=>[],array:On,boolean:function(a){let e=a.value,l=a.key,u=Nt(e);return u!=="boolean"?[new Ce(l,e,`boolean expected, ${u} found`)]:[]},number:Ra,color:function(a){let e=a.key,l=a.value,u=Nt(l);return u!=="string"?[new Ce(e,l,`color expected, ${u} found`)]:Ji.parse(String(l))?[]:[new Ce(e,l,`color expected, "${l}" found`)]},constants:es,enum:As,filter:Sn,function:sl,layer:ma,object:Wn,source:vA,light:ta,sky:Ms,terrain:To,string:fn,formatted:function(a){return fn(a).length===0?[]:fa(a)},resolvedImage:function(a){return fn(a).length===0?[]:fa(a)},padding:function(a){let e=a.key,l=a.value;if(Nt(l)==="array"){if(l.length<1||l.length>4)return[new Ce(e,l,`padding requires 1 to 4 values; ${l.length} values found`)];let u={type:"number"},m=[];for(let w=0;w[]}})),a.constants&&(l=l.concat(es({key:"constants",value:a.constants,style:a,styleSpec:e,validateSpec:Jr}))),Qo(l)}function gn(a){return function(e){return a({...e,validateSpec:Jr})}}function Qo(a){return[].concat(a).sort((e,l)=>e.line-l.line)}function pr(a){return function(...e){return Qo(a.apply(this,e))}}zn.source=pr(gn(vA)),zn.sprite=pr(gn(no)),zn.glyphs=pr(gn(xs)),zn.light=pr(gn(ta)),zn.sky=pr(gn(Ms)),zn.terrain=pr(gn(To)),zn.layer=pr(gn(ma)),zn.filter=pr(gn(Sn)),zn.paintProperty=pr(gn(_s)),zn.layoutProperty=pr(gn(ro));let Fr=zn,en=Fr.light,yn=Fr.paintProperty,so=Fr.layoutProperty;function ea(a,e){let l=!1;if(e&&e.length)for(let u of e)a.fire(new Me(new Error(u.message))),l=!0;return l}class ls{constructor(e,l,u){let m=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let B=new Int32Array(this.arrayBuffer);e=B[0],this.d=(l=B[1])+2*(u=B[2]);for(let U=0;U=z[st+0]&&m>=z[st+1])?(S[nt]=!0,B.push(D[nt])):S[nt]=!1}}}}_forEachCell(e,l,u,m,w,B,S,U){let M=this._convertToCellCoord(e),D=this._convertToCellCoord(l),z=this._convertToCellCoord(u),et=this._convertToCellCoord(m);for(let nt=M;nt<=z;nt++)for(let st=D;st<=et;st++){let mt=this.d*st+nt;if((!U||U(this._convertFromCellCoord(nt),this._convertFromCellCoord(st),this._convertFromCellCoord(nt+1),this._convertFromCellCoord(st+1)))&&w.call(this,e,l,u,m,mt,B,S,U))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,l=3+this.cells.length+1+1,u=0;for(let B=0;B=0)continue;let B=a[w];m[w]=oo[u].shallow.indexOf(w)>=0?B:Ca(B,e)}a instanceof Error&&(m.message=a.message)}if(m.$name)throw new Error("$name property is reserved for worker serialization logic.");return u!=="Object"&&(m.$name=u),m}throw new Error("can't serialize object of type "+typeof a)}function Za(a){if(a==null||typeof a=="boolean"||typeof a=="number"||typeof a=="string"||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||a instanceof Blob||a instanceof Error||Ul(a)||ie(a)||ArrayBuffer.isView(a)||a instanceof ImageData)return a;if(Array.isArray(a))return a.map(Za);if(typeof a=="object"){let e=a.$name||"Object";if(!oo[e])throw new Error(`can't deserialize unregistered class ${e}`);let{klass:l}=oo[e];if(!l)throw new Error(`can't deserialize unregistered class ${e}`);if(l.deserialize)return l.deserialize(a);let u=Object.create(l.prototype);for(let m of Object.keys(a)){if(m==="$name")continue;let w=a[m];u[m]=oo[e].shallow.indexOf(m)>=0?w:Za(w)}return u}throw new Error("can't deserialize object of type "+typeof a)}class Ql{constructor(){this.first=!0}update(e,l){let u=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=u,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=u,!0):(this.lastFloorZoom>u?(this.lastIntegerZoom=u+1,this.lastIntegerZoomTime=l):this.lastFloorZooma>=128&&a<=255,Arabic:a=>a>=1536&&a<=1791,"Arabic Supplement":a=>a>=1872&&a<=1919,"Arabic Extended-A":a=>a>=2208&&a<=2303,"Hangul Jamo":a=>a>=4352&&a<=4607,"Unified Canadian Aboriginal Syllabics":a=>a>=5120&&a<=5759,Khmer:a=>a>=6016&&a<=6143,"Unified Canadian Aboriginal Syllabics Extended":a=>a>=6320&&a<=6399,"General Punctuation":a=>a>=8192&&a<=8303,"Letterlike Symbols":a=>a>=8448&&a<=8527,"Number Forms":a=>a>=8528&&a<=8591,"Miscellaneous Technical":a=>a>=8960&&a<=9215,"Control Pictures":a=>a>=9216&&a<=9279,"Optical Character Recognition":a=>a>=9280&&a<=9311,"Enclosed Alphanumerics":a=>a>=9312&&a<=9471,"Geometric Shapes":a=>a>=9632&&a<=9727,"Miscellaneous Symbols":a=>a>=9728&&a<=9983,"Miscellaneous Symbols and Arrows":a=>a>=11008&&a<=11263,"CJK Radicals Supplement":a=>a>=11904&&a<=12031,"Kangxi Radicals":a=>a>=12032&&a<=12255,"Ideographic Description Characters":a=>a>=12272&&a<=12287,"CJK Symbols and Punctuation":a=>a>=12288&&a<=12351,Hiragana:a=>a>=12352&&a<=12447,Katakana:a=>a>=12448&&a<=12543,Bopomofo:a=>a>=12544&&a<=12591,"Hangul Compatibility Jamo":a=>a>=12592&&a<=12687,Kanbun:a=>a>=12688&&a<=12703,"Bopomofo Extended":a=>a>=12704&&a<=12735,"CJK Strokes":a=>a>=12736&&a<=12783,"Katakana Phonetic Extensions":a=>a>=12784&&a<=12799,"Enclosed CJK Letters and Months":a=>a>=12800&&a<=13055,"CJK Compatibility":a=>a>=13056&&a<=13311,"CJK Unified Ideographs Extension A":a=>a>=13312&&a<=19903,"Yijing Hexagram Symbols":a=>a>=19904&&a<=19967,"CJK Unified Ideographs":a=>a>=19968&&a<=40959,"Yi Syllables":a=>a>=40960&&a<=42127,"Yi Radicals":a=>a>=42128&&a<=42191,"Hangul Jamo Extended-A":a=>a>=43360&&a<=43391,"Hangul Syllables":a=>a>=44032&&a<=55215,"Hangul Jamo Extended-B":a=>a>=55216&&a<=55295,"Private Use Area":a=>a>=57344&&a<=63743,"CJK Compatibility Ideographs":a=>a>=63744&&a<=64255,"Arabic Presentation Forms-A":a=>a>=64336&&a<=65023,"Vertical Forms":a=>a>=65040&&a<=65055,"CJK Compatibility Forms":a=>a>=65072&&a<=65103,"Small Form Variants":a=>a>=65104&&a<=65135,"Arabic Presentation Forms-B":a=>a>=65136&&a<=65279,"Halfwidth and Fullwidth Forms":a=>a>=65280&&a<=65519};function Pa(a){for(let e of a)if(rs(e.charCodeAt(0)))return!0;return!1}function Ma(a){for(let e of a)if(!cs(e.charCodeAt(0)))return!1;return!0}function cs(a){return!(ei.Arabic(a)||ei["Arabic Supplement"](a)||ei["Arabic Extended-A"](a)||ei["Arabic Presentation Forms-A"](a)||ei["Arabic Presentation Forms-B"](a))}function rs(a){return!(a!==746&&a!==747&&(a<4352||!(ei["Bopomofo Extended"](a)||ei.Bopomofo(a)||ei["CJK Compatibility Forms"](a)&&!(a>=65097&&a<=65103)||ei["CJK Compatibility Ideographs"](a)||ei["CJK Compatibility"](a)||ei["CJK Radicals Supplement"](a)||ei["CJK Strokes"](a)||!(!ei["CJK Symbols and Punctuation"](a)||a>=12296&&a<=12305||a>=12308&&a<=12319||a===12336)||ei["CJK Unified Ideographs Extension A"](a)||ei["CJK Unified Ideographs"](a)||ei["Enclosed CJK Letters and Months"](a)||ei["Hangul Compatibility Jamo"](a)||ei["Hangul Jamo Extended-A"](a)||ei["Hangul Jamo Extended-B"](a)||ei["Hangul Jamo"](a)||ei["Hangul Syllables"](a)||ei.Hiragana(a)||ei["Ideographic Description Characters"](a)||ei.Kanbun(a)||ei["Kangxi Radicals"](a)||ei["Katakana Phonetic Extensions"](a)||ei.Katakana(a)&&a!==12540||!(!ei["Halfwidth and Fullwidth Forms"](a)||a===65288||a===65289||a===65293||a>=65306&&a<=65310||a===65339||a===65341||a===65343||a>=65371&&a<=65503||a===65507||a>=65512&&a<=65519)||!(!ei["Small Form Variants"](a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||ei["Unified Canadian Aboriginal Syllabics"](a)||ei["Unified Canadian Aboriginal Syllabics Extended"](a)||ei["Vertical Forms"](a)||ei["Yijing Hexagram Symbols"](a)||ei["Yi Syllables"](a)||ei["Yi Radicals"](a))))}function wA(a){return!(rs(a)||function(e){return!!(ei["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||ei["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||ei["Letterlike Symbols"](e)||ei["Number Forms"](e)||ei["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||ei["Control Pictures"](e)&&e!==9251||ei["Optical Character Recognition"](e)||ei["Enclosed Alphanumerics"](e)||ei["Geometric Shapes"](e)||ei["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||ei["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||ei["CJK Symbols and Punctuation"](e)||ei.Katakana(e)||ei["Private Use Area"](e)||ei["CJK Compatibility Forms"](e)||ei["Small Form Variants"](e)||ei["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(a))}function BA(a){return a>=1424&&a<=2303||ei["Arabic Presentation Forms-A"](a)||ei["Arabic Presentation Forms-B"](a)}function Gl(a,e){return!(!e&&BA(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||ei.Khmer(a))}function ol(a){for(let e of a)if(BA(e.charCodeAt(0)))return!0;return!1}let Go=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(a){this.pluginStatus=a.pluginStatus,this.pluginURL=a.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(a){this.applyArabicShaping=a.applyArabicShaping,this.processBidirectionalText=a.processBidirectionalText,this.processStyledBidirectionalText=a.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class Pr{constructor(e,l){this.zoom=e,l?(this.now=l.now,this.fadeDuration=l.fadeDuration,this.zoomHistory=l.zoomHistory,this.transition=l.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ql,this.transition={})}isSupportedScript(e){return function(l,u){for(let m of l)if(!Gl(m.charCodeAt(0),u))return!1;return!0}(e,Go.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,l=e-Math.floor(e),u=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:l+(1-l)*u}:{fromScale:.5,toScale:1,t:1-(1-u)*l}}}class al{constructor(e,l){this.property=e,this.value=l,this.expression=function(u,m){if(ue(u))return new $n(u,m);if(Xi(u)){let w=Hs(u,m);if(w.result==="error")throw new Error(w.value.map(B=>`${B.key}: ${B.message}`).join(", "));return w.value}{let w=u;return m.type==="color"&&typeof u=="string"?w=Ji.parse(u):m.type!=="padding"||typeof u!="number"&&!Array.isArray(u)?m.type==="variableAnchorOffsetCollection"&&Array.isArray(u)&&(w=an.parse(u)):w=xr.parse(u),{kind:"constant",evaluate:()=>w}}}(l===void 0?e.specification.default:l,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,l,u){return this.property.possiblyEvaluate(this,e,l,u)}}class _A{constructor(e){this.property=e,this.value=new al(e,void 0)}transitioned(e,l){return new xA(this.property,this.value,l,Tt({},e.transition,this.transition),e.now)}untransitioned(){return new xA(this.property,this.value,null,{},0)}}class Al{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Jt(this._values[e].value.value)}setValue(e,l){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new _A(this._values[e].property)),this._values[e].value=new al(this._values[e].property,l===null?void 0:Jt(l))}getTransition(e){return Jt(this._values[e].transition)}setTransition(e,l){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new _A(this._values[e].property)),this._values[e].transition=Jt(l)||void 0}serialize(){let e={};for(let l of Object.keys(this._values)){let u=this.getValue(l);u!==void 0&&(e[l]=u);let m=this.getTransition(l);m!==void 0&&(e[`${l}-transition`]=m)}return e}transitioned(e,l){let u=new Rl(this._properties);for(let m of Object.keys(this._values))u._values[m]=this._values[m].transitioned(e,l._values[m]);return u}untransitioned(){let e=new Rl(this._properties);for(let l of Object.keys(this._values))e._values[l]=this._values[l].untransitioned();return e}}class xA{constructor(e,l,u,m,w){this.property=e,this.value=l,this.begin=w+m.delay||0,this.end=this.begin+m.duration||0,e.specification.transition&&(m.delay||m.duration)&&(this.prior=u)}possiblyEvaluate(e,l,u){let m=e.now||0,w=this.value.possiblyEvaluate(e,l,u),B=this.prior;if(B){if(m>this.end)return this.prior=null,w;if(this.value.isDataDriven())return this.prior=null,w;if(m=1)return 1;let M=U*U,D=M*U;return 4*(U<.5?D:3*(U-M)+D-.75)}(S))}}return w}}class Rl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,l,u){let m=new SA(this._properties);for(let w of Object.keys(this._values))m._values[w]=this._values[w].possiblyEvaluate(e,l,u);return m}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class dh{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Jt(this._values[e].value)}setValue(e,l){this._values[e]=new al(this._values[e].property,l===null?void 0:Jt(l))}serialize(){let e={};for(let l of Object.keys(this._values)){let u=this.getValue(l);u!==void 0&&(e[l]=u)}return e}possiblyEvaluate(e,l,u){let m=new SA(this._properties);for(let w of Object.keys(this._values))m._values[w]=this._values[w].possiblyEvaluate(e,l,u);return m}}class ao{constructor(e,l,u){this.property=e,this.value=l,this.parameters=u}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,l,u,m){return this.property.evaluate(this.value,this.parameters,e,l,u,m)}}class SA{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class wi{constructor(e){this.specification=e}possiblyEvaluate(e,l){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(l)}interpolate(e,l,u){let m=qn[this.specification.type];return m?m(e,l,u):e}}class Hi{constructor(e,l){this.specification=e,this.overrides=l}possiblyEvaluate(e,l,u,m){return new ao(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(l,null,{},u,m)}:e.expression,l)}interpolate(e,l,u){if(e.value.kind!=="constant"||l.value.kind!=="constant")return e;if(e.value.value===void 0||l.value.value===void 0)return new ao(this,{kind:"constant",value:void 0},e.parameters);let m=qn[this.specification.type];if(m){let w=m(e.value.value,l.value.value,u);return new ao(this,{kind:"constant",value:w},e.parameters)}return e}evaluate(e,l,u,m,w,B){return e.kind==="constant"?e.value:e.evaluate(l,u,m,w,B)}}class Na extends Hi{possiblyEvaluate(e,l,u,m){if(e.value===void 0)return new ao(this,{kind:"constant",value:void 0},l);if(e.expression.kind==="constant"){let w=e.expression.evaluate(l,null,{},u,m),B=e.property.specification.type==="resolvedImage"&&typeof w!="string"?w.name:w,S=this._calculate(B,B,B,l);return new ao(this,{kind:"constant",value:S},l)}if(e.expression.kind==="camera"){let w=this._calculate(e.expression.evaluate({zoom:l.zoom-1}),e.expression.evaluate({zoom:l.zoom}),e.expression.evaluate({zoom:l.zoom+1}),l);return new ao(this,{kind:"constant",value:w},l)}return new ao(this,e.expression,l)}evaluate(e,l,u,m,w,B){if(e.kind==="source"){let S=e.evaluate(l,u,m,w,B);return this._calculate(S,S,S,l)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(l.zoom)-1},u,m),e.evaluate({zoom:Math.floor(l.zoom)},u,m),e.evaluate({zoom:Math.floor(l.zoom)+1},u,m),l):e.value}_calculate(e,l,u,m){return m.zoom>m.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:u,to:l}}interpolate(e){return e}}class wc{constructor(e){this.specification=e}possiblyEvaluate(e,l,u,m){if(e.value!==void 0){if(e.expression.kind==="constant"){let w=e.expression.evaluate(l,null,{},u,m);return this._calculate(w,w,w,l)}return this._calculate(e.expression.evaluate(new Pr(Math.floor(l.zoom-1),l)),e.expression.evaluate(new Pr(Math.floor(l.zoom),l)),e.expression.evaluate(new Pr(Math.floor(l.zoom+1),l)),l)}}_calculate(e,l,u,m){return m.zoom>m.zoomHistory.lastIntegerZoom?{from:e,to:l}:{from:u,to:l}}interpolate(e){return e}}class ll{constructor(e){this.specification=e}possiblyEvaluate(e,l,u,m){return!!e.expression.evaluate(l,null,{},u,m)}interpolate(){return!1}}class Jn{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let l in e){let u=e[l];u.specification.overridable&&this.overridableProperties.push(l);let m=this.defaultPropertyValues[l]=new al(u,void 0),w=this.defaultTransitionablePropertyValues[l]=new _A(u);this.defaultTransitioningPropertyValues[l]=w.untransitioned(),this.defaultPossiblyEvaluatedValues[l]=m.possiblyEvaluate({})}}}si("DataDrivenProperty",Hi),si("DataConstantProperty",wi),si("CrossFadedDataDrivenProperty",Na),si("CrossFadedProperty",wc),si("ColorRampProperty",ll);let Hl="-transition";class ns extends gi{constructor(e,l){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),l.layout&&(this._unevaluatedLayout=new dh(l.layout)),l.paint)){this._transitionablePaint=new Al(l.paint);for(let u in e.paint)this.setPaintProperty(u,e.paint[u],{validate:!1});for(let u in e.layout)this.setLayoutProperty(u,e.layout[u],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new SA(l.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,l,u={}){l!=null&&this._validate(so,`layers.${this.id}.layout.${e}`,e,l,u)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,l):this.visibility=l)}getPaintProperty(e){return e.endsWith(Hl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,l,u={}){if(l!=null&&this._validate(yn,`layers.${this.id}.paint.${e}`,e,l,u))return!1;if(e.endsWith(Hl))return this._transitionablePaint.setTransition(e.slice(0,-11),l||void 0),!1;{let m=this._transitionablePaint._values[e],w=m.property.specification["property-type"]==="cross-faded-data-driven",B=m.value.isDataDriven(),S=m.value;this._transitionablePaint.setValue(e,l),this._handleSpecialPaintPropertyUpdate(e);let U=this._transitionablePaint._values[e].value;return U.isDataDriven()||B||w||this._handleOverridablePaintPropertyUpdate(e,S,U)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,l,u){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,l){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,l)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,l)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),vt(e,(l,u)=>!(l===void 0||u==="layout"&&!Object.keys(l).length||u==="paint"&&!Object.keys(l).length))}_validate(e,l,u,m,w={}){return(!w||w.validate!==!1)&&ea(this,e.call(Fr,{key:l,layerType:this.type,objectKey:u,value:m,styleSpec:xt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let l=this.paint.get(e);if(l instanceof ao&&Q(l.property.specification)&&(l.value.kind==="source"||l.value.kind==="composite")&&l.value.isStateDependent)return!0}return!1}}let ou={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class FA{constructor(e,l){this._structArray=e,this._pos1=l*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,l){return e._trim(),l&&(e.isTransferred=!0,l.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let l=Object.create(this.prototype);return l.arrayBuffer=e.arrayBuffer,l.length=e.length,l.capacity=e.arrayBuffer.byteLength/l.bytesPerElement,l._refreshViews(),l}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let l=this.uint8;this._refreshViews(),l&&this.uint8.set(l)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function dn(a,e=1){let l=0,u=0;return{members:a.map(m=>{let w=ou[m.type].BYTES_PER_ELEMENT,B=l=au(l,Math.max(e,w)),S=m.components||1;return u=Math.max(u,w),l+=w*S,{name:m.name,type:m.type,components:S,offset:B}}),size:au(l,Math.max(u,e)),alignment:e}}function au(a,e){return Math.ceil(a/e)*e}class cl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.int16[m+0]=l,this.int16[m+1]=u,e}}cl.prototype.bytesPerElement=4,si("StructArrayLayout2i4",cl);class Zl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.int16[w+0]=l,this.int16[w+1]=u,this.int16[w+2]=m,e}}Zl.prototype.bytesPerElement=6,si("StructArrayLayout3i6",Zl);class ss extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=4*e;return this.int16[B+0]=l,this.int16[B+1]=u,this.int16[B+2]=m,this.int16[B+3]=w,e}}ss.prototype.bytesPerElement=8,si("StructArrayLayout4i8",ss);class Ss extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let U=6*e;return this.int16[U+0]=l,this.int16[U+1]=u,this.int16[U+2]=m,this.int16[U+3]=w,this.int16[U+4]=B,this.int16[U+5]=S,e}}Ss.prototype.bytesPerElement=12,si("StructArrayLayout2i4i12",Ss);class Ao extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let U=4*e,M=8*e;return this.int16[U+0]=l,this.int16[U+1]=u,this.uint8[M+4]=m,this.uint8[M+5]=w,this.uint8[M+6]=B,this.uint8[M+7]=S,e}}Ao.prototype.bytesPerElement=8,si("StructArrayLayout2i4ub8",Ao);class ul extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.float32[m+0]=l,this.float32[m+1]=u,e}}ul.prototype.bytesPerElement=8,si("StructArrayLayout2f8",ul);class Pl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,U,M,D){let z=this.length;return this.resize(z+1),this.emplace(z,e,l,u,m,w,B,S,U,M,D)}emplace(e,l,u,m,w,B,S,U,M,D,z){let et=10*e;return this.uint16[et+0]=l,this.uint16[et+1]=u,this.uint16[et+2]=m,this.uint16[et+3]=w,this.uint16[et+4]=B,this.uint16[et+5]=S,this.uint16[et+6]=U,this.uint16[et+7]=M,this.uint16[et+8]=D,this.uint16[et+9]=z,e}}Pl.prototype.bytesPerElement=20,si("StructArrayLayout10ui20",Pl);class lo extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,U,M,D,z,et){let nt=this.length;return this.resize(nt+1),this.emplace(nt,e,l,u,m,w,B,S,U,M,D,z,et)}emplace(e,l,u,m,w,B,S,U,M,D,z,et,nt){let st=12*e;return this.int16[st+0]=l,this.int16[st+1]=u,this.int16[st+2]=m,this.int16[st+3]=w,this.uint16[st+4]=B,this.uint16[st+5]=S,this.uint16[st+6]=U,this.uint16[st+7]=M,this.int16[st+8]=D,this.int16[st+9]=z,this.int16[st+10]=et,this.int16[st+11]=nt,e}}lo.prototype.bytesPerElement=24,si("StructArrayLayout4i4ui4i24",lo);class us extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.float32[w+0]=l,this.float32[w+1]=u,this.float32[w+2]=m,e}}us.prototype.bytesPerElement=12,si("StructArrayLayout3f12",us);class Bc extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint32[1*e+0]=l,e}}Bc.prototype.bytesPerElement=4,si("StructArrayLayout1ul4",Bc);class ia extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,U,M){let D=this.length;return this.resize(D+1),this.emplace(D,e,l,u,m,w,B,S,U,M)}emplace(e,l,u,m,w,B,S,U,M,D){let z=10*e,et=5*e;return this.int16[z+0]=l,this.int16[z+1]=u,this.int16[z+2]=m,this.int16[z+3]=w,this.int16[z+4]=B,this.int16[z+5]=S,this.uint32[et+3]=U,this.uint16[z+8]=M,this.uint16[z+9]=D,e}}ia.prototype.bytesPerElement=20,si("StructArrayLayout6i1ul2ui20",ia);class hl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B){let S=this.length;return this.resize(S+1),this.emplace(S,e,l,u,m,w,B)}emplace(e,l,u,m,w,B,S){let U=6*e;return this.int16[U+0]=l,this.int16[U+1]=u,this.int16[U+2]=m,this.int16[U+3]=w,this.int16[U+4]=B,this.int16[U+5]=S,e}}hl.prototype.bytesPerElement=12,si("StructArrayLayout2i2i2i12",hl);class kA extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w){let B=this.length;return this.resize(B+1),this.emplace(B,e,l,u,m,w)}emplace(e,l,u,m,w,B){let S=4*e,U=8*e;return this.float32[S+0]=l,this.float32[S+1]=u,this.float32[S+2]=m,this.int16[U+6]=w,this.int16[U+7]=B,e}}kA.prototype.bytesPerElement=16,si("StructArrayLayout2f1f2i16",kA);class gl extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=12*e,S=3*e;return this.uint8[B+0]=l,this.uint8[B+1]=u,this.float32[S+1]=m,this.float32[S+2]=w,e}}gl.prototype.bytesPerElement=12,si("StructArrayLayout2ub2f12",gl);class Va extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.uint16[w+0]=l,this.uint16[w+1]=u,this.uint16[w+2]=m,e}}Va.prototype.bytesPerElement=6,si("StructArrayLayout3ui6",Va);class _c extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt){let se=this.length;return this.resize(se+1),this.emplace(se,e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt)}emplace(e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt,se){let Wt=24*e,$t=12*e,be=48*e;return this.int16[Wt+0]=l,this.int16[Wt+1]=u,this.uint16[Wt+2]=m,this.uint16[Wt+3]=w,this.uint32[$t+2]=B,this.uint32[$t+3]=S,this.uint32[$t+4]=U,this.uint16[Wt+10]=M,this.uint16[Wt+11]=D,this.uint16[Wt+12]=z,this.float32[$t+7]=et,this.float32[$t+8]=nt,this.uint8[be+36]=st,this.uint8[be+37]=mt,this.uint8[be+38]=St,this.uint32[$t+10]=Vt,this.int16[Wt+22]=se,e}}_c.prototype.bytesPerElement=48,si("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",_c);class ra extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt,se,Wt,$t,be,Le,ni,bi,ri,ti,Oe,fi){let qe=this.length;return this.resize(qe+1),this.emplace(qe,e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt,se,Wt,$t,be,Le,ni,bi,ri,ti,Oe,fi)}emplace(e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt,St,Vt,se,Wt,$t,be,Le,ni,bi,ri,ti,Oe,fi,qe){let Ze=32*e,Gi=16*e;return this.int16[Ze+0]=l,this.int16[Ze+1]=u,this.int16[Ze+2]=m,this.int16[Ze+3]=w,this.int16[Ze+4]=B,this.int16[Ze+5]=S,this.int16[Ze+6]=U,this.int16[Ze+7]=M,this.uint16[Ze+8]=D,this.uint16[Ze+9]=z,this.uint16[Ze+10]=et,this.uint16[Ze+11]=nt,this.uint16[Ze+12]=st,this.uint16[Ze+13]=mt,this.uint16[Ze+14]=St,this.uint16[Ze+15]=Vt,this.uint16[Ze+16]=se,this.uint16[Ze+17]=Wt,this.uint16[Ze+18]=$t,this.uint16[Ze+19]=be,this.uint16[Ze+20]=Le,this.uint16[Ze+21]=ni,this.uint16[Ze+22]=bi,this.uint32[Gi+12]=ri,this.float32[Gi+13]=ti,this.float32[Gi+14]=Oe,this.uint16[Ze+30]=fi,this.uint16[Ze+31]=qe,e}}ra.prototype.bytesPerElement=64,si("StructArrayLayout8i15ui1ul2f2ui64",ra);class co extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.float32[1*e+0]=l,e}}co.prototype.bytesPerElement=4,si("StructArrayLayout1f4",co);class Da extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=3*e;return this.uint16[6*e+0]=l,this.float32[w+1]=u,this.float32[w+2]=m,e}}Da.prototype.bytesPerElement=12,si("StructArrayLayout1ui2f12",Da);class LA extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l,u){let m=this.length;return this.resize(m+1),this.emplace(m,e,l,u)}emplace(e,l,u,m){let w=4*e;return this.uint32[2*e+0]=l,this.uint16[w+2]=u,this.uint16[w+3]=m,e}}LA.prototype.bytesPerElement=8,si("StructArrayLayout1ul2ui8",LA);class Ia extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,l)}emplace(e,l,u){let m=2*e;return this.uint16[m+0]=l,this.uint16[m+1]=u,e}}Ia.prototype.bytesPerElement=4,si("StructArrayLayout2ui4",Ia);class xc extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let l=this.length;return this.resize(l+1),this.emplace(l,e)}emplace(e,l){return this.uint16[1*e+0]=l,e}}xc.prototype.bytesPerElement=2,si("StructArrayLayout1ui2",xc);class Ml extends Xr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,l,u,m){let w=this.length;return this.resize(w+1),this.emplace(w,e,l,u,m)}emplace(e,l,u,m,w){let B=4*e;return this.float32[B+0]=l,this.float32[B+1]=u,this.float32[B+2]=m,this.float32[B+3]=w,e}}Ml.prototype.bytesPerElement=16,si("StructArrayLayout4f16",Ml);class Sc extends FA{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 v(this.anchorPointX,this.anchorPointY)}}Sc.prototype.size=20;class Au extends ia{get(e){return new Sc(this,e)}}si("CollisionBoxArray",Au);class y extends FA{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}y.prototype.size=48;class n extends _c{get(e){return new y(this,e)}}si("PlacedSymbolArray",n);class c extends FA{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}c.prototype.size=64;class p extends ra{get(e){return new c(this,e)}}si("SymbolInstanceArray",p);class f extends co{getoffsetX(e){return this.float32[1*e+0]}}si("GlyphOffsetArray",f);class b extends Zl{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}si("SymbolLineVertexArray",b);class L extends FA{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}L.prototype.size=12;class E extends Da{get(e){return new L(this,e)}}si("TextAnchorOffsetArray",E);class H extends FA{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]}}H.prototype.size=8;class h extends LA{get(e){return new H(this,e)}}si("FeatureIndexArray",h);class I extends cl{}class _ extends cl{}class F extends cl{}class R extends Ss{}class Z extends Ao{}class N extends ul{}class P extends Pl{}class V extends lo{}class X extends us{}class J extends Bc{}class ot extends hl{}class pt extends gl{}class ut extends Va{}class Gt extends Ia{}let Pt=dn([{name:"a_pos",components:2,type:"Int16"}],4),{members:dt}=Pt;class Ct{constructor(e=[]){this.segments=e}prepareSegment(e,l,u,m){let w=this.segments[this.segments.length-1];return e>Ct.MAX_VERTEX_ARRAY_LENGTH&&At(`Max vertices per segment is ${Ct.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!w||w.vertexLength+e>Ct.MAX_VERTEX_ARRAY_LENGTH||w.sortKey!==m)&&(w={vertexOffset:l.length,primitiveOffset:u.length,vertexLength:0,primitiveLength:0},m!==void 0&&(w.sortKey=m),this.segments.push(w)),w}get(){return this.segments}destroy(){for(let e of this.segments)for(let l in e.vaos)e.vaos[l].destroy()}static simpleSegment(e,l,u,m){return new Ct([{vertexOffset:e,primitiveOffset:l,vertexLength:u,primitiveLength:m,vaos:{},sortKey:0}])}}function ee(a,e){return 256*(a=at(Math.floor(a),0,255))+at(Math.floor(e),0,255)}Ct.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,si("SegmentVector",Ct);let ge=dn([{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 jt={exports:{}},Fe={exports:{}};Fe.exports=function(a,e){var l,u,m,w,B,S,U,M;for(u=a.length-(l=3&a.length),m=e,B=3432918353,S=461845907,M=0;M>>16)*B&65535)<<16)&4294967295)<<15|U>>>17))*S+(((U>>>16)*S&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(w>>>16)&65535)<<16);switch(U=0,l){case 3:U^=(255&a.charCodeAt(M+2))<<16;case 2:U^=(255&a.charCodeAt(M+1))<<8;case 1:m^=U=(65535&(U=(U=(65535&(U^=255&a.charCodeAt(M)))*B+(((U>>>16)*B&65535)<<16)&4294967295)<<15|U>>>17))*S+(((U>>>16)*S&65535)<<16)&4294967295}return m^=a.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0};var ke=Fe.exports,Ye={exports:{}};Ye.exports=function(a,e){for(var l,u=a.length,m=e^u,w=0;u>=4;)l=1540483477*(65535&(l=255&a.charCodeAt(w)|(255&a.charCodeAt(++w))<<8|(255&a.charCodeAt(++w))<<16|(255&a.charCodeAt(++w))<<24))+((1540483477*(l>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),u-=4,++w;switch(u){case 3:m^=(255&a.charCodeAt(w+2))<<16;case 2:m^=(255&a.charCodeAt(w+1))<<8;case 1:m=1540483477*(65535&(m^=255&a.charCodeAt(w)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0};var xe=ke,ci=Ye.exports;jt.exports=xe,jt.exports.murmur3=xe,jt.exports.murmur2=ci;var pi=g(jt.exports);class Mi{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,l,u,m){this.ids.push(Si(e)),this.positions.push(l,u,m)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");let l=Si(e),u=0,m=this.ids.length-1;for(;u>1;this.ids[B]>=l?m=B:u=B+1}let w=[];for(;this.ids[u]===l;)w.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return w}static serialize(e,l){let u=new Float64Array(e.ids),m=new Uint32Array(e.positions);return cr(u,m,0,u.length-1),l&&l.push(u.buffer,m.buffer),{ids:u,positions:m}}static deserialize(e){let l=new Mi;return l.ids=e.ids,l.positions=e.positions,l.indexed=!0,l}}function Si(a){let e=+a;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:pi(String(a))}function cr(a,e,l,u){for(;l>1],w=l-1,B=u+1;for(;;){do w++;while(a[w]m);if(w>=B)break;ji(a,w,B),ji(e,3*w,3*B),ji(e,3*w+1,3*B+1),ji(e,3*w+2,3*B+2)}B-l`u_${m}`),this.type=u}setUniform(e,l,u){e.set(u.constantOr(this.value))}getBinding(e,l,u){return this.type==="color"?new Rr(e,l):new vr(e,l)}}class rn{constructor(e,l){this.uniformNames=l.map(u=>`u_${u}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,l){this.pixelRatioFrom=l.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=l.tlbr,this.patternTo=e.tlbr}setUniform(e,l,u,m){let w=m==="u_pattern_to"?this.patternTo:m==="u_pattern_from"?this.patternFrom:m==="u_pixel_ratio_to"?this.pixelRatioTo:m==="u_pixel_ratio_from"?this.pixelRatioFrom:null;w&&e.set(w)}getBinding(e,l,u){return u.substr(0,9)==="u_pattern"?new Yr(e,l):new vr(e,l)}}class ur{constructor(e,l,u,m){this.expression=e,this.type=u,this.maxValue=0,this.paintVertexAttributes=l.map(w=>({name:`a_${w}`,type:"Float32",components:u==="color"?2:1,offset:0})),this.paintVertexArray=new m}populatePaintArray(e,l,u,m,w){let B=this.paintVertexArray.length,S=this.expression.evaluate(new Pr(0),l,{},m,[],w);this.paintVertexArray.resize(e),this._setPaintValue(B,e,S)}updatePaintArray(e,l,u,m){let w=this.expression.evaluate({zoom:0},u,m);this._setPaintValue(e,l,w)}_setPaintValue(e,l,u){if(this.type==="color"){let m=wr(u);for(let w=e;w`u_${S}_t`),this.type=u,this.useIntegerZoom=m,this.zoom=w,this.maxValue=0,this.paintVertexAttributes=l.map(S=>({name:`a_${S}`,type:"Float32",components:u==="color"?4:2,offset:0})),this.paintVertexArray=new B}populatePaintArray(e,l,u,m,w){let B=this.expression.evaluate(new Pr(this.zoom),l,{},m,[],w),S=this.expression.evaluate(new Pr(this.zoom+1),l,{},m,[],w),U=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(U,e,B,S)}updatePaintArray(e,l,u,m){let w=this.expression.evaluate({zoom:this.zoom},u,m),B=this.expression.evaluate({zoom:this.zoom+1},u,m);this._setPaintValue(e,l,w,B)}_setPaintValue(e,l,u,m){if(this.type==="color"){let w=wr(u),B=wr(m);for(let S=e;S`#define HAS_UNIFORM_${m}`))}return e}getBinderAttributes(){let e=[];for(let l in this.binders){let u=this.binders[l];if(u instanceof ur||u instanceof sr)for(let m=0;m!0){this.programConfigurations={};for(let m of e)this.programConfigurations[m.id]=new Fn(m,l,u);this.needsUpload=!1,this._featureMap=new Mi,this._bufferOffset=0}populatePaintArrays(e,l,u,m,w,B){for(let S in this.programConfigurations)this.programConfigurations[S].populatePaintArrays(e,l,m,w,B);l.id!==void 0&&this._featureMap.add(l.id,u,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,l,u,m){for(let w of u)this.needsUpload=this.programConfigurations[w.id].updatePaintArrays(e,this._featureMap,l,w,m)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let l in this.programConfigurations)this.programConfigurations[l].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Br(a,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"]}[a]||[a.replace(`${e}-`,"").replace(/-/g,"_")]}function pn(a,e,l){let u={color:{source:ul,composite:Ml},number:{source:co,composite:ul}},m=function(w){return{"line-pattern":{source:P,composite:P},"fill-pattern":{source:P,composite:P},"fill-extrusion-pattern":{source:P,composite:P}}[w]}(a);return m&&m[l]||u[e][l]}si("ConstantBinder",An),si("CrossFadedConstantBinder",rn),si("SourceExpressionBinder",ur),si("CrossFadedCompositeBinder",Ir),si("CompositeExpressionBinder",sr),si("ProgramConfiguration",Fn,{omit:["_buffers"]}),si("ProgramConfigurationSet",_r);let $i=8192,ya=Math.pow(2,14)-1,na=-ya-1;function Mr(a){let e=$i/a.extent,l=a.loadGeometry();for(let u=0;uB.x+1||UB.y+1)&&At("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return l}function sa(a,e){return{type:a.type,id:a.id,properties:a.properties,geometry:e?Mr(a):[]}}function dl(a,e,l,u,m){a.emplaceBack(2*e+(u+1)/2,2*l+(m+1)/2)}class Nl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(l=>l.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new _,this.indexArray=new ut,this.segments=new Ct,this.programConfigurations=new _r(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){let m=this.layers[0],w=[],B=null,S=!1;m.type==="circle"&&(B=m.layout.get("circle-sort-key"),S=!B.isConstant());for(let{feature:U,id:M,index:D,sourceLayerIndex:z}of e){let et=this.layers[0]._featureFilter.needGeometry,nt=sa(U,et);if(!this.layers[0]._featureFilter.filter(new Pr(this.zoom),nt,u))continue;let st=S?B.evaluate(nt,{},u):void 0,mt={id:M,properties:U.properties,type:U.type,sourceLayerIndex:z,index:D,geometry:et?nt.geometry:Mr(U),patterns:{},sortKey:st};w.push(mt)}S&&w.sort((U,M)=>U.sortKey-M.sortKey);for(let U of w){let{geometry:M,index:D,sourceLayerIndex:z}=U,et=e[D].feature;this.addFeature(U,M,D,u),l.featureIndex.insert(et,M,D,z,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dt),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,l,u,m){for(let w of l)for(let B of w){let S=B.x,U=B.y;if(S<0||S>=$i||U<0||U>=$i)continue;let M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),D=M.vertexLength;dl(this.layoutVertexArray,S,U,-1,-1),dl(this.layoutVertexArray,S,U,1,-1),dl(this.layoutVertexArray,S,U,1,1),dl(this.layoutVertexArray,S,U,-1,1),this.indexArray.emplaceBack(D,D+1,D+2),this.indexArray.emplaceBack(D,D+3,D+2),M.vertexLength+=4,M.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{},m)}}function Ro(a,e){for(let l=0;l1){if(Ho(a,e))return!0;for(let u=0;u1?l:l.sub(e)._mult(m)._add(e))}function ph(a,e){let l,u,m,w=!1;for(let B=0;Be.y!=m.y>e.y&&e.x<(m.x-u.x)*(e.y-u.y)/(m.y-u.y)+u.x&&(w=!w)}return w}function Wa(a,e){let l=!1;for(let u=0,m=a.length-1;ue.y!=B.y>e.y&&e.x<(B.x-w.x)*(e.y-w.y)/(B.y-w.y)+w.x&&(l=!l)}return l}function fh(a,e,l){let u=l[0],m=l[2];if(a.xm.x&&e.x>m.x||a.ym.y&&e.y>m.y)return!1;let w=lt(a,e,l[0]);return w!==lt(a,e,l[1])||w!==lt(a,e,l[2])||w!==lt(a,e,l[3])}function QA(a,e,l){let u=e.paint.get(a).value;return u.kind==="constant"?u.value:l.programConfigurations.get(e.id).getMaxValue(a)}function GA(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function lu(a,e,l,u,m){if(!e[0]&&!e[1])return a;let w=v.convert(e)._mult(m);l==="viewport"&&w._rotate(-u);let B=[];for(let S=0;Shu(St,mt))}(M,U),nt=z?D*S:D;for(let st of m)for(let mt of st){let St=z?mt:hu(mt,U),Vt=nt,se=kc([],[mt.x,mt.y,0,1],U);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?Vt*=se[3]/B.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(Vt*=B.cameraToCenterDistance/se[3]),EA(et,St,Vt))return!0}return!1}}function hu(a,e){let l=kc([],[a.x,a.y,0,1],e);return new v(l[0]/l[3],l[1]/l[3])}class Dl extends Nl{}let Ih;si("HeatmapBucket",Dl,{omit:["layers"]});var om={get paint(){return Ih=Ih||new Jn({"heatmap-radius":new Hi(xt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Hi(xt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new wi(xt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ll(xt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new wi(xt.paint_heatmap["heatmap-opacity"])})}};function Kl(a,{width:e,height:l},u,m){if(m){if(m instanceof Uint8ClampedArray)m=new Uint8Array(m.buffer);else if(m.length!==e*l*u)throw new RangeError(`mismatched image size. expected: ${m.length} but got: ${e*l*u}`)}else m=new Uint8Array(e*l*u);return a.width=e,a.height=l,a.data=m,a}function yh(a,{width:e,height:l},u){if(e===a.width&&l===a.height)return;let m=Kl({},{width:e,height:l},u);Lc(a,m,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,e),height:Math.min(a.height,l)},u),a.width=e,a.height=l,a.data=m.data}function Lc(a,e,l,u,m,w){if(m.width===0||m.height===0)return e;if(m.width>a.width||m.height>a.height||l.x>a.width-m.width||l.y>a.height-m.height)throw new RangeError("out of range source coordinates for image copy");if(m.width>e.width||m.height>e.height||u.x>e.width-m.width||u.y>e.height-m.height)throw new RangeError("out of range destination coordinates for image copy");let B=a.data,S=e.data;if(B===S)throw new Error("srcData equals dstData, so image is already copied");for(let U=0;U{e[a.evaluationKey]=U;let M=a.expression.evaluate(e);m.data[B+S+0]=Math.floor(255*M.r/M.a),m.data[B+S+1]=Math.floor(255*M.g/M.a),m.data[B+S+2]=Math.floor(255*M.b/M.a),m.data[B+S+3]=Math.floor(255*M.a)};if(a.clips)for(let B=0,S=0;B80*l){u=w=a[0],m=B=a[1];for(var st=l;stw&&(w=S),U>B&&(B=U);M=(M=Math.max(w-u,B-m))!==0?32767/M:0}return ZA(et,nt,l,u,m,M,0),nt}function Ol(a,e,l,u,m){var w,B;if(m===hm(a,e,l,u)>0)for(w=e;w=e;w-=u)B=zy(w,a[w],a[w+1],B);return B&&jg(B,B.next)&&(xh(B),B=B.next),B}function Oa(a,e){if(!a)return a;e||(e=a);var l,u=a;do if(l=!1,u.steiner||!jg(u,u.next)&&bn(u.prev,u,u.next)!==0)u=u.next;else{if(xh(u),(u=e=u.prev)===u.next)break;l=!0}while(l||u!==e);return e}function ZA(a,e,l,u,m,w,B){if(a){!B&&w&&function(D,z,et,nt){var st=D;do st.z===0&&(st.z=Ec(st.x,st.y,z,et,nt)),st.prevZ=st.prev,st.nextZ=st.next,st=st.next;while(st!==D);st.prevZ.nextZ=null,st.prevZ=null,function(mt){var St,Vt,se,Wt,$t,be,Le,ni,bi=1;do{for(Vt=mt,mt=null,$t=null,be=0;Vt;){for(be++,se=Vt,Le=0,St=0;St0||ni>0&&se;)Le!==0&&(ni===0||!se||Vt.z<=se.z)?(Wt=Vt,Vt=Vt.nextZ,Le--):(Wt=se,se=se.nextZ,ni--),$t?$t.nextZ=Wt:mt=Wt,Wt.prevZ=$t,$t=Wt;Vt=se}$t.nextZ=null,bi*=2}while(be>1)}(st)}(a,u,m,w);for(var S,U,M=a;a.prev!==a.next;)if(S=a.prev,U=a.next,w?PA(a,u,m,w):za(a))e.push(S.i/l|0),e.push(a.i/l|0),e.push(U.i/l|0),xh(a),a=U.next,M=U.next;else if((a=U)===M){B?B===1?ZA(a=MA(Oa(a),e,l),e,l,u,m,w,2):B===2&&pu(a,e,l,u,m,w):ZA(Oa(a),e,l,u,m,w,1);break}}}function za(a){var e=a.prev,l=a,u=a.next;if(bn(e,l,u)>=0)return!1;for(var m=e.x,w=l.x,B=u.x,S=e.y,U=l.y,M=u.y,D=mw?m>B?m:B:w>B?w:B,nt=S>U?S>M?S:M:U>M?U:M,st=u.next;st!==e;){if(st.x>=D&&st.x<=et&&st.y>=z&&st.y<=nt&&fu(m,S,w,U,B,M,st.x,st.y)&&bn(st.prev,st,st.next)>=0)return!1;st=st.next}return!0}function PA(a,e,l,u){var m=a.prev,w=a,B=a.next;if(bn(m,w,B)>=0)return!1;for(var S=m.x,U=w.x,M=B.x,D=m.y,z=w.y,et=B.y,nt=SU?S>M?S:M:U>M?U:M,St=D>z?D>et?D:et:z>et?z:et,Vt=Ec(nt,st,e,l,u),se=Ec(mt,St,e,l,u),Wt=a.prevZ,$t=a.nextZ;Wt&&Wt.z>=Vt&&$t&&$t.z<=se;){if(Wt.x>=nt&&Wt.x<=mt&&Wt.y>=st&&Wt.y<=St&&Wt!==m&&Wt!==B&&fu(S,D,U,z,M,et,Wt.x,Wt.y)&&bn(Wt.prev,Wt,Wt.next)>=0||(Wt=Wt.prevZ,$t.x>=nt&&$t.x<=mt&&$t.y>=st&&$t.y<=St&&$t!==m&&$t!==B&&fu(S,D,U,z,M,et,$t.x,$t.y)&&bn($t.prev,$t,$t.next)>=0))return!1;$t=$t.nextZ}for(;Wt&&Wt.z>=Vt;){if(Wt.x>=nt&&Wt.x<=mt&&Wt.y>=st&&Wt.y<=St&&Wt!==m&&Wt!==B&&fu(S,D,U,z,M,et,Wt.x,Wt.y)&&bn(Wt.prev,Wt,Wt.next)>=0)return!1;Wt=Wt.prevZ}for(;$t&&$t.z<=se;){if($t.x>=nt&&$t.x<=mt&&$t.y>=st&&$t.y<=St&&$t!==m&&$t!==B&&fu(S,D,U,z,M,et,$t.x,$t.y)&&bn($t.prev,$t,$t.next)>=0)return!1;$t=$t.nextZ}return!0}function MA(a,e,l){var u=a;do{var m=u.prev,w=u.next.next;!jg(m,w)&&Wy(m,u,u.next,w)&&_h(m,w)&&_h(w,m)&&(e.push(m.i/l|0),e.push(u.i/l|0),e.push(w.i/l|0),xh(u),xh(u.next),u=a=w),u=u.next}while(u!==a);return Oa(u)}function pu(a,e,l,u,m,w){var B=a;do{for(var S=B.next.next;S!==B.prev;){if(B.i!==S.i&&K5(B,S)){var U=Oy(B,S);return B=Oa(B,B.next),U=Oa(U,U.next),ZA(B,e,l,u,m,w,0),void ZA(U,e,l,u,m,w,0)}S=S.next}B=B.next}while(B!==a)}function wh(a,e){return a.x-e.x}function Yg(a,e){var l=function(m,w){var B,S=w,U=m.x,M=m.y,D=-1/0;do{if(M<=S.y&&M>=S.next.y&&S.next.y!==S.y){var z=S.x+(M-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(z<=U&&z>D&&(D=z,B=S.x=S.x&&S.x>=st&&U!==S.x&&fu(MB.x||S.x===B.x&&cm(B,S)))&&(B=S,St=et)),S=S.next;while(S!==nt);return B}(a,e);if(!l)return e;var u=Oy(l,a);return Oa(u,u.next),Oa(l,l.next)}function cm(a,e){return bn(a.prev,a,e.prev)<0&&bn(e.next,a,a.next)<0}function Ec(a,e,l,u,m){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=(a-l)*m|0)|a<<8))|a<<4))|a<<2))|a<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-u)*m|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Bh(a){var e=a,l=a;do(e.x=(a-B)*(w-S)&&(a-B)*(u-S)>=(l-B)*(e-S)&&(l-B)*(w-S)>=(m-B)*(u-S)}function K5(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!function(l,u){var m=l;do{if(m.i!==l.i&&m.next.i!==l.i&&m.i!==u.i&&m.next.i!==u.i&&Wy(m,m.next,l,u))return!0;m=m.next}while(m!==l);return!1}(a,e)&&(_h(a,e)&&_h(e,a)&&function(l,u){var m=l,w=!1,B=(l.x+u.x)/2,S=(l.y+u.y)/2;do m.y>S!=m.next.y>S&&m.next.y!==m.y&&B<(m.next.x-m.x)*(S-m.y)/(m.next.y-m.y)+m.x&&(w=!w),m=m.next;while(m!==l);return w}(a,e)&&(bn(a.prev,a,e.prev)||bn(a,e.prev,e))||jg(a,e)&&bn(a.prev,a,a.next)>0&&bn(e.prev,e,e.next)>0)}function bn(a,e,l){return(e.y-a.y)*(l.x-e.x)-(e.x-a.x)*(l.y-e.y)}function jg(a,e){return a.x===e.x&&a.y===e.y}function Wy(a,e,l,u){var m=$g(bn(a,e,l)),w=$g(bn(a,e,u)),B=$g(bn(l,u,a)),S=$g(bn(l,u,e));return m!==w&&B!==S||!(m!==0||!qg(a,l,e))||!(w!==0||!qg(a,u,e))||!(B!==0||!qg(l,a,u))||!(S!==0||!qg(l,e,u))}function qg(a,e,l){return e.x<=Math.max(a.x,l.x)&&e.x>=Math.min(a.x,l.x)&&e.y<=Math.max(a.y,l.y)&&e.y>=Math.min(a.y,l.y)}function $g(a){return a>0?1:a<0?-1:0}function _h(a,e){return bn(a.prev,a,a.next)<0?bn(a,e,a.next)>=0&&bn(a,a.prev,e)>=0:bn(a,e,a.prev)<0||bn(a,a.next,e)<0}function Oy(a,e){var l=new um(a.i,a.x,a.y),u=new um(e.i,e.x,e.y),m=a.next,w=e.prev;return a.next=e,e.prev=a,l.next=m,m.prev=l,u.next=l,l.prev=u,w.next=u,u.prev=w,u}function zy(a,e,l,u){var m=new um(a,e,l);return u?(m.next=u.next,m.prev=u,u.next.prev=m,u.next=m):(m.prev=m,m.next=m),m}function xh(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function um(a,e,l){this.i=a,this.x=e,this.y=l,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hm(a,e,l,u){for(var m=0,w=e,B=l-u;w0&&l.holes.push(u+=a[m-1].length)}return l};var Jy=g(gu.exports);function W5(a,e,l,u,m){Xy(a,e,l||0,u||a.length-1,m||O5)}function Xy(a,e,l,u,m){for(;u>l;){if(u-l>600){var w=u-l+1,B=e-l+1,S=Math.log(w),U=.5*Math.exp(2*S/3),M=.5*Math.sqrt(S*U*(w-U)/w)*(B-w/2<0?-1:1);Xy(a,e,Math.max(l,Math.floor(e-B*U/w+M)),Math.min(u,Math.floor(e+(w-B)*U/w+M)),m)}var D=a[e],z=l,et=u;for(Sh(a,l,e),m(a[u],D)>0&&Sh(a,l,u);z0;)et--}m(a[l],D)===0?Sh(a,l,et):Sh(a,++et,u),et<=e&&(l=et+1),e<=et&&(u=et-1)}}function Sh(a,e,l){var u=a[e];a[e]=a[l],a[l]=u}function O5(a,e){return ae?1:0}function gm(a,e){let l=a.length;if(l<=1)return[a];let u=[],m,w;for(let B=0;B1)for(let B=0;Bl.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new F,this.indexArray=new ut,this.indexArray2=new Gt,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.segments2=new Ct,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.hasPattern=dm("fill",this.layers,l);let m=this.layers[0].layout.get("fill-sort-key"),w=!m.isConstant(),B=[];for(let{feature:S,id:U,index:M,sourceLayerIndex:D}of e){let z=this.layers[0]._featureFilter.needGeometry,et=sa(S,z);if(!this.layers[0]._featureFilter.filter(new Pr(this.zoom),et,u))continue;let nt=w?m.evaluate(et,{},u,l.availableImages):void 0,st={id:U,properties:S.properties,type:S.type,sourceLayerIndex:D,index:M,geometry:z?et.geometry:Mr(S),patterns:{},sortKey:nt};B.push(st)}w&&B.sort((S,U)=>S.sortKey-U.sortKey);for(let S of B){let{geometry:U,index:M,sourceLayerIndex:D}=S;if(this.hasPattern){let z=pm("fill",this.layers,S,this.zoom,l);this.patternFeatures.push(z)}else this.addFeature(S,U,M,u,{});l.featureIndex.insert(e[M].feature,U,M,D,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}addFeatures(e,l,u){for(let m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,l,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lm),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,l,u,m,w){for(let B of gm(l,500)){let S=0;for(let nt of B)S+=nt.length;let U=this.segments.prepareSegment(S,this.layoutVertexArray,this.indexArray),M=U.vertexLength,D=[],z=[];for(let nt of B){if(nt.length===0)continue;nt!==B[0]&&z.push(D.length/2);let st=this.segments2.prepareSegment(nt.length,this.layoutVertexArray,this.indexArray2),mt=st.vertexLength;this.layoutVertexArray.emplaceBack(nt[0].x,nt[0].y),this.indexArray2.emplaceBack(mt+nt.length-1,mt),D.push(nt[0].x),D.push(nt[0].y);for(let St=1;St>3}if(m--,u===1||u===2)w+=a.readSVarint(),B+=a.readSVarint(),u===1&&(e&&S.push(e),e=[]),e.push(new $5(w,B));else{if(u!==7)throw new Error("unknown command "+u);e&&e.push(e[0].clone())}}return e&&S.push(e),S},mu.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var e=a.readVarint()+a.pos,l=1,u=0,m=0,w=0,B=1/0,S=-1/0,U=1/0,M=-1/0;a.pos>3}if(u--,l===1||l===2)(m+=a.readSVarint())S&&(S=m),(w+=a.readSVarint())M&&(M=w);else if(l!==7)throw new Error("unknown command "+l)}return[B,U,S,M]},mu.prototype.toGeoJSON=function(a,e,l){var u,m,w=this.extent*Math.pow(2,l),B=this.extent*a,S=this.extent*e,U=this.loadGeometry(),M=mu.types[this.type];function D(nt){for(var st=0;st>3;m=B===1?u.readString():B===2?u.readFloat():B===3?u.readDouble():B===4?u.readVarint64():B===5?u.readVarint():B===6?u.readSVarint():B===7?u.readBoolean():null}return m}(l))}t1.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var e=this._pbf.readVarint()+this._pbf.pos;return new iS(this._pbf,e,this.extent,this._keys,this._values)};var nS=$y;function sS(a,e,l){if(a===3){var u=new nS(l,l.readVarint()+l.pos);u.length&&(e[u.name]=u)}}zl.VectorTile=function(a,e){this.layers=a.readFields(sS,{},e)},zl.VectorTileFeature=qy,zl.VectorTileLayer=$y;let oS=zl.VectorTileFeature.types,mm=Math.pow(2,13);function Fh(a,e,l,u,m,w,B,S){a.emplaceBack(e,l,2*Math.floor(u*mm)+B,m*mm*2,w*mm*2,Math.round(S))}class Cm{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(l=>l.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new R,this.centroidVertexArray=new I,this.indexArray=new ut,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.features=[],this.hasPattern=dm("fill-extrusion",this.layers,l);for(let{feature:m,id:w,index:B,sourceLayerIndex:S}of e){let U=this.layers[0]._featureFilter.needGeometry,M=sa(m,U);if(!this.layers[0]._featureFilter.filter(new Pr(this.zoom),M,u))continue;let D={id:w,sourceLayerIndex:S,index:B,geometry:U?M.geometry:Mr(m),properties:m.properties,type:m.type,patterns:{}};this.hasPattern?this.features.push(pm("fill-extrusion",this.layers,D,this.zoom,l)):this.addFeature(D,D.geometry,B,u,{}),l.featureIndex.insert(m,D.geometry,B,S,this.index,!0)}}addFeatures(e,l,u){for(let m of this.features){let{geometry:w}=m;this.addFeature(m,w,m.index,l,u)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,q5),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,j5.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,l,u,m,w){let B={x:0,y:0,vertexCount:0};for(let S of gm(l,500)){let U=0;for(let st of S)U+=st.length;let M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let st of S){if(st.length===0||AS(st))continue;let mt=0;for(let St=0;St=1){let se=st[St-1];if(!aS(Vt,se)){M.vertexLength+4>Ct.MAX_VERTEX_ARRAY_LENGTH&&(M=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let Wt=Vt.sub(se)._perp()._unit(),$t=se.dist(Vt);mt+$t>32768&&(mt=0),Fh(this.layoutVertexArray,Vt.x,Vt.y,Wt.x,Wt.y,0,0,mt),Fh(this.layoutVertexArray,Vt.x,Vt.y,Wt.x,Wt.y,0,1,mt),B.x+=2*Vt.x,B.y+=2*Vt.y,B.vertexCount+=2,mt+=$t,Fh(this.layoutVertexArray,se.x,se.y,Wt.x,Wt.y,0,0,mt),Fh(this.layoutVertexArray,se.x,se.y,Wt.x,Wt.y,0,1,mt),B.x+=2*se.x,B.y+=2*se.y,B.vertexCount+=2;let be=M.vertexLength;this.indexArray.emplaceBack(be,be+2,be+1),this.indexArray.emplaceBack(be+1,be+2,be+3),M.vertexLength+=4,M.primitiveLength+=2}}}}if(M.vertexLength+U>Ct.MAX_VERTEX_ARRAY_LENGTH&&(M=this.segments.prepareSegment(U,this.layoutVertexArray,this.indexArray)),oS[e.type]!=="Polygon")continue;let D=[],z=[],et=M.vertexLength;for(let st of S)if(st.length!==0){st!==S[0]&&z.push(D.length/2);for(let mt=0;mt$i)||a.y===e.y&&(a.y<0||a.y>$i)}function AS(a){return a.every(e=>e.x<0)||a.every(e=>e.x>$i)||a.every(e=>e.y<0)||a.every(e=>e.y>$i)}let e1;si("FillExtrusionBucket",Cm,{omit:["layers","features"]});var lS={get paint(){return e1=e1||new Jn({"fill-extrusion-opacity":new wi(xt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new wi(xt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new wi(xt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Na(xt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Hi(xt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new wi(xt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class cS extends ns{constructor(e){super(e,lS)}createBucket(e){return new Cm(e)}queryRadius(){return GA(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,l,u,m,w,B,S,U){let M=lu(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),B.angle,S),D=this.paint.get("fill-extrusion-height").evaluate(l,u),z=this.paint.get("fill-extrusion-base").evaluate(l,u),et=function(st,mt,St,Vt){let se=[];for(let Wt of st){let $t=[Wt.x,Wt.y,0,1];kc($t,$t,mt),se.push(new v($t[0]/$t[3],$t[1]/$t[3]))}return se}(M,U),nt=function(st,mt,St,Vt){let se=[],Wt=[],$t=Vt[8]*mt,be=Vt[9]*mt,Le=Vt[10]*mt,ni=Vt[11]*mt,bi=Vt[8]*St,ri=Vt[9]*St,ti=Vt[10]*St,Oe=Vt[11]*St;for(let fi of st){let qe=[],Ze=[];for(let Gi of fi){let Bi=Gi.x,hr=Gi.y,jr=Vt[0]*Bi+Vt[4]*hr+Vt[12],nn=Vt[1]*Bi+Vt[5]*hr+Vt[13],Ln=Vt[2]*Bi+Vt[6]*hr+Vt[14],Po=Vt[3]*Bi+Vt[7]*hr+Vt[15],Ds=Ln+Le,wn=Po+ni,os=jr+bi,ds=nn+ri,Ks=Ln+ti,Ws=Po+Oe,En=new v((jr+$t)/wn,(nn+be)/wn);En.z=Ds/wn,qe.push(En);let Tn=new v(os/Ws,ds/Ws);Tn.z=Ks/Ws,Ze.push(Tn)}se.push(qe),Wt.push(Ze)}return[se,Wt]}(m,z,D,U);return function(st,mt,St){let Vt=1/0;TA(St,mt)&&(Vt=i1(St,mt[0]));for(let se=0;sel.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(l=>{this.gradients[l.id]={}}),this.layoutVertexArray=new Z,this.layoutVertexArray2=new N,this.indexArray=new ut,this.programConfigurations=new _r(e.layers,e.zoom),this.segments=new Ct,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(l=>l.isStateDependent()).map(l=>l.id)}populate(e,l,u){this.hasPattern=dm("line",this.layers,l);let m=this.layers[0].layout.get("line-sort-key"),w=!m.isConstant(),B=[];for(let{feature:S,id:U,index:M,sourceLayerIndex:D}of e){let z=this.layers[0]._featureFilter.needGeometry,et=sa(S,z);if(!this.layers[0]._featureFilter.filter(new Pr(this.zoom),et,u))continue;let nt=w?m.evaluate(et,{},u):void 0,st={id:U,properties:S.properties,type:S.type,sourceLayerIndex:D,index:M,geometry:z?et.geometry:Mr(S),patterns:{},sortKey:nt};B.push(st)}w&&B.sort((S,U)=>S.sortKey-U.sortKey);for(let S of B){let{geometry:U,index:M,sourceLayerIndex:D}=S;if(this.hasPattern){let z=pm("line",this.layers,S,this.zoom,l);this.patternFeatures.push(z)}else this.addFeature(S,U,M,u,{});l.featureIndex.insert(e[M].feature,U,M,D,this.index)}}update(e,l,u){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,l,this.stateDependentLayers,u)}addFeatures(e,l,u){for(let m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,l,u)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,dS)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hS),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,l,u,m,w){let B=this.layers[0].layout,S=B.get("line-join").evaluate(e,{}),U=B.get("line-cap"),M=B.get("line-miter-limit"),D=B.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(let z of l)this.addLine(z,e,S,U,M,D);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,w,m)}addLine(e,l,u,m,w,B){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let Vt=0;Vt=2&&e[U-1].equals(e[U-2]);)U--;let M=0;for(;M0;if(ni&&Vt>M){let Oe=et.dist(nt);if(Oe>2*D){let fi=et.sub(et.sub(nt)._mult(D/Oe)._round());this.updateDistance(nt,fi),this.addCurrentVertex(fi,mt,0,0,z),nt=fi}}let ri=nt&&st,ti=ri?u:S?"butt":m;if(ri&&ti==="round"&&(bew&&(ti="bevel"),ti==="bevel"&&(be>2&&(ti="flipbevel"),be100)se=St.mult(-1);else{let Oe=be*mt.add(St).mag()/mt.sub(St).mag();se._perp()._mult(Oe*(bi?-1:1))}this.addCurrentVertex(et,se,0,0,z),this.addCurrentVertex(et,se.mult(-1),0,0,z)}else if(ti==="bevel"||ti==="fakeround"){let Oe=-Math.sqrt(be*be-1),fi=bi?Oe:0,qe=bi?0:Oe;if(nt&&this.addCurrentVertex(et,mt,fi,qe,z),ti==="fakeround"){let Ze=Math.round(180*Le/Math.PI/20);for(let Gi=1;Gi2*D){let fi=et.add(st.sub(et)._mult(D/Oe)._round());this.updateDistance(et,fi),this.addCurrentVertex(fi,St,0,0,z),et=fi}}}}addCurrentVertex(e,l,u,m,w,B=!1){let S=l.y*m-l.x,U=-l.y-l.x*m;this.addHalfVertex(e,l.x+l.y*u,l.y-l.x*u,B,!1,u,w),this.addHalfVertex(e,S,U,B,!0,-m,w),this.distance>r1/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,l,u,m,w,B))}addHalfVertex({x:e,y:l},u,m,w,B,S,U){let M=.5*(this.lineClips?this.scaledDistance*(r1-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(w?1:0),(l<<1)+(B?1:0),Math.round(63*u)+128,Math.round(63*m)+128,1+(S===0?0:S<0?-1:1)|(63&M)<<2,M>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let D=U.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,D),U.primitiveLength++),B?this.e2=D:this.e1=D}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,l){this.distance+=e.dist(l),this.updateScaledDistance()}}let n1,s1;si("LineBucket",Im,{omit:["layers","patternFeatures"]});var o1={get paint(){return s1=s1||new Jn({"line-opacity":new Hi(xt.paint_line["line-opacity"]),"line-color":new Hi(xt.paint_line["line-color"]),"line-translate":new wi(xt.paint_line["line-translate"]),"line-translate-anchor":new wi(xt.paint_line["line-translate-anchor"]),"line-width":new Hi(xt.paint_line["line-width"]),"line-gap-width":new Hi(xt.paint_line["line-gap-width"]),"line-offset":new Hi(xt.paint_line["line-offset"]),"line-blur":new Hi(xt.paint_line["line-blur"]),"line-dasharray":new wc(xt.paint_line["line-dasharray"]),"line-pattern":new Na(xt.paint_line["line-pattern"]),"line-gradient":new ll(xt.paint_line["line-gradient"])})},get layout(){return n1=n1||new Jn({"line-cap":new wi(xt.layout_line["line-cap"]),"line-join":new Hi(xt.layout_line["line-join"]),"line-miter-limit":new wi(xt.layout_line["line-miter-limit"]),"line-round-limit":new wi(xt.layout_line["line-round-limit"]),"line-sort-key":new Hi(xt.layout_line["line-sort-key"])})}};class mS extends Hi{possiblyEvaluate(e,l){return l=new Pr(Math.floor(l.zoom),{now:l.now,fadeDuration:l.fadeDuration,zoomHistory:l.zoomHistory,transition:l.transition}),super.possiblyEvaluate(e,l)}evaluate(e,l,u,m){return l=Tt({},l,{zoom:Math.floor(l.zoom)}),super.evaluate(e,l,u,m)}}let td;class CS extends ns{constructor(e){super(e,o1),this.gradientVersion=0,td||(td=new mS(o1.paint.properties["line-width"].specification),td.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let l=this.gradientExpression();this.stepInterpolant=!!function(u){return u._styleExpression!==void 0}(l)&&l._styleExpression.expression instanceof _o,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,l){super.recalculate(e,l),this.paint._values["line-floorwidth"]=td.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Im(e)}queryRadius(e){let l=e,u=a1(QA("line-width",this,l),QA("line-gap-width",this,l)),m=QA("line-offset",this,l);return u/2+Math.abs(m)+GA(this.paint.get("line-translate"))}queryIntersectsFeature(e,l,u,m,w,B,S){let U=lu(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),B.angle,S),M=S/2*a1(this.paint.get("line-width").evaluate(l,u),this.paint.get("line-gap-width").evaluate(l,u)),D=this.paint.get("line-offset").evaluate(l,u);return D&&(m=function(z,et){let nt=[];for(let st=0;st=3){for(let St=0;St0?e+2*a:a}let IS=dn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),yS=dn([{name:"a_projected_pos",components:3,type:"Float32"}],4);dn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let bS=dn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);dn([{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"}]);let A1=dn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),vS=dn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function wS(a,e,l){return a.sections.forEach(u=>{u.text=function(m,w,B){let S=w.layout.get("text-transform").evaluate(B,{});return S==="uppercase"?m=m.toLocaleUpperCase():S==="lowercase"&&(m=m.toLocaleLowerCase()),Go.applyArabicShaping&&(m=Go.applyArabicShaping(m)),m}(u.text,e,l)}),a}dn([{name:"triangle",components:3,type:"Uint16"}]),dn([{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"}]),dn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),dn([{type:"Float32",name:"offsetX"}]),dn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),dn([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);let Lh={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var kn=24,l1=Dr,c1=function(a,e,l,u,m){var w,B,S=8*m-u-1,U=(1<>1,D=-7,z=l?m-1:0,et=l?-1:1,nt=a[e+z];for(z+=et,w=nt&(1<<-D)-1,nt>>=-D,D+=S;D>0;w=256*w+a[e+z],z+=et,D-=8);for(B=w&(1<<-D)-1,w>>=-D,D+=u;D>0;B=256*B+a[e+z],z+=et,D-=8);if(w===0)w=1-M;else{if(w===U)return B?NaN:1/0*(nt?-1:1);B+=Math.pow(2,u),w-=M}return(nt?-1:1)*B*Math.pow(2,w-u)},u1=function(a,e,l,u,m,w){var B,S,U,M=8*w-m-1,D=(1<>1,et=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,nt=u?0:w-1,st=u?1:-1,mt=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(S=isNaN(e)?1:0,B=D):(B=Math.floor(Math.log(e)/Math.LN2),e*(U=Math.pow(2,-B))<1&&(B--,U*=2),(e+=B+z>=1?et/U:et*Math.pow(2,1-z))*U>=2&&(B++,U/=2),B+z>=D?(S=0,B=D):B+z>=1?(S=(e*U-1)*Math.pow(2,m),B+=z):(S=e*Math.pow(2,z-1)*Math.pow(2,m),B=0));m>=8;a[l+nt]=255&S,nt+=st,S/=256,m-=8);for(B=B<0;a[l+nt]=255&B,nt+=st,B/=256,M-=8);a[l+nt-st]|=128*mt};function Dr(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}Dr.Varint=0,Dr.Fixed64=1,Dr.Bytes=2,Dr.Fixed32=5;var ym=4294967296,h1=1/ym,g1=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function pl(a){return a.type===Dr.Bytes?a.readVarint()+a.pos:a.pos+1}function Cu(a,e,l){return l?4294967296*e+(a>>>0):4294967296*(e>>>0)+(a>>>0)}function d1(a,e,l){var u=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));l.realloc(u);for(var m=l.pos-1;m>=a;m--)l.buf[m+u]=l.buf[m]}function BS(a,e){for(var l=0;l>>8,a[l+2]=e>>>16,a[l+3]=e>>>24}function p1(a,e){return(a[e]|a[e+1]<<8|a[e+2]<<16)+(a[e+3]<<24)}Dr.prototype={destroy:function(){this.buf=null},readFields:function(a,e,l){for(l=l||this.length;this.pos>3,w=this.pos;this.type=7&u,a(m,e,this),this.pos===w&&this.skip(u)}return e},readMessage:function(a,e){return this.readFields(a,e,this.readVarint()+this.pos)},readFixed32:function(){var a=ed(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=p1(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=ed(this.buf,this.pos)+ed(this.buf,this.pos+4)*ym;return this.pos+=8,a},readSFixed64:function(){var a=ed(this.buf,this.pos)+p1(this.buf,this.pos+4)*ym;return this.pos+=8,a},readFloat:function(){var a=c1(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=c1(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var e,l,u=this.buf;return e=127&(l=u[this.pos++]),l<128?e:(e|=(127&(l=u[this.pos++]))<<7,l<128?e:(e|=(127&(l=u[this.pos++]))<<14,l<128?e:(e|=(127&(l=u[this.pos++]))<<21,l<128?e:function(m,w,B){var S,U,M=B.buf;if(S=(112&(U=M[B.pos++]))>>4,U<128||(S|=(127&(U=M[B.pos++]))<<3,U<128)||(S|=(127&(U=M[B.pos++]))<<10,U<128)||(S|=(127&(U=M[B.pos++]))<<17,U<128)||(S|=(127&(U=M[B.pos++]))<<24,U<128)||(S|=(1&(U=M[B.pos++]))<<31,U<128))return Cu(m,S,w);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(l=u[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?(a+1)/-2:a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var a=this.readVarint()+this.pos,e=this.pos;return this.pos=a,a-e>=12&&g1?function(l,u,m){return g1.decode(l.subarray(u,m))}(this.buf,e,a):function(l,u,m){for(var w="",B=u;B239?4:D>223?3:D>191?2:1;if(B+et>m)break;et===1?D<128&&(z=D):et===2?(192&(S=l[B+1]))==128&&(z=(31&D)<<6|63&S)<=127&&(z=null):et===3?(U=l[B+2],(192&(S=l[B+1]))==128&&(192&U)==128&&((z=(15&D)<<12|(63&S)<<6|63&U)<=2047||z>=55296&&z<=57343)&&(z=null)):et===4&&(U=l[B+2],M=l[B+3],(192&(S=l[B+1]))==128&&(192&U)==128&&(192&M)==128&&((z=(15&D)<<18|(63&S)<<12|(63&U)<<6|63&M)<=65535||z>=1114112)&&(z=null)),z===null?(z=65533,et=1):z>65535&&(z-=65536,w+=String.fromCharCode(z>>>10&1023|55296),z=56320|1023&z),w+=String.fromCharCode(z),B+=et}return w}(this.buf,e,a)},readBytes:function(){var a=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,a);return this.pos=a,e},readPackedVarint:function(a,e){if(this.type!==Dr.Bytes)return a.push(this.readVarint(e));var l=pl(this);for(a=a||[];this.pos127;);else if(e===Dr.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Dr.Fixed32)this.pos+=4;else{if(e!==Dr.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(a,e){this.writeVarint(a<<3|e)},realloc:function(a){for(var e=this.length||16;e268435455||a<0?function(e,l){var u,m;if(e>=0?(u=e%4294967296|0,m=e/4294967296|0):(m=~(-e/4294967296),4294967295^(u=~(-e%4294967296))?u=u+1|0:(u=0,m=m+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");l.realloc(10),function(w,B,S){S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,w>>>=7,S.buf[S.pos++]=127&w|128,S.buf[S.pos]=127&(w>>>=7)}(u,0,l),function(w,B){var S=(7&w)<<4;B.buf[B.pos++]|=S|((w>>>=3)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w|((w>>>=7)?128:0),w&&(B.buf[B.pos++]=127&w)))))}(m,l)}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?2*-a-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var e=this.pos;this.pos=function(u,m,w){for(var B,S,U=0;U55295&&B<57344){if(!S){B>56319||U+1===m.length?(u[w++]=239,u[w++]=191,u[w++]=189):S=B;continue}if(B<56320){u[w++]=239,u[w++]=191,u[w++]=189,S=B;continue}B=S-55296<<10|B-56320|65536,S=null}else S&&(u[w++]=239,u[w++]=191,u[w++]=189,S=null);B<128?u[w++]=B:(B<2048?u[w++]=B>>6|192:(B<65536?u[w++]=B>>12|224:(u[w++]=B>>18|240,u[w++]=B>>12&63|128),u[w++]=B>>6&63|128),u[w++]=63&B|128)}return w}(this.buf,a,this.pos);var l=this.pos-e;l>=128&&d1(e,l,this),this.pos=e-1,this.writeVarint(l),this.pos+=l},writeFloat:function(a){this.realloc(4),u1(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),u1(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var e=a.length;this.writeVarint(e),this.realloc(e);for(var l=0;l=128&&d1(l,u,this),this.pos=l-1,this.writeVarint(u),this.pos+=u},writeMessage:function(a,e,l){this.writeTag(a,Dr.Bytes),this.writeRawMessage(e,l)},writePackedVarint:function(a,e){e.length&&this.writeMessage(a,BS,e)},writePackedSVarint:function(a,e){e.length&&this.writeMessage(a,_S,e)},writePackedBoolean:function(a,e){e.length&&this.writeMessage(a,FS,e)},writePackedFloat:function(a,e){e.length&&this.writeMessage(a,xS,e)},writePackedDouble:function(a,e){e.length&&this.writeMessage(a,SS,e)},writePackedFixed32:function(a,e){e.length&&this.writeMessage(a,kS,e)},writePackedSFixed32:function(a,e){e.length&&this.writeMessage(a,LS,e)},writePackedFixed64:function(a,e){e.length&&this.writeMessage(a,ES,e)},writePackedSFixed64:function(a,e){e.length&&this.writeMessage(a,TS,e)},writeBytesField:function(a,e){this.writeTag(a,Dr.Bytes),this.writeBytes(e)},writeFixed32Field:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeSFixed64(e)},writeVarintField:function(a,e){this.writeTag(a,Dr.Varint),this.writeVarint(e)},writeSVarintField:function(a,e){this.writeTag(a,Dr.Varint),this.writeSVarint(e)},writeStringField:function(a,e){this.writeTag(a,Dr.Bytes),this.writeString(e)},writeFloatField:function(a,e){this.writeTag(a,Dr.Fixed32),this.writeFloat(e)},writeDoubleField:function(a,e){this.writeTag(a,Dr.Fixed64),this.writeDouble(e)},writeBooleanField:function(a,e){this.writeVarintField(a,Boolean(e))}};var bm=g(l1);let vm=3;function US(a,e,l){a===1&&l.readMessage(QS,e)}function QS(a,e,l){if(a===3){let{id:u,bitmap:m,width:w,height:B,left:S,top:U,advance:M}=l.readMessage(GS,{});e.push({id:u,bitmap:new Zo({width:w+2*vm,height:B+2*vm},m),metrics:{width:w,height:B,left:S,top:U,advance:M}})}}function GS(a,e,l){a===1?e.id=l.readVarint():a===2?e.bitmap=l.readBytes():a===3?e.width=l.readVarint():a===4?e.height=l.readVarint():a===5?e.left=l.readSVarint():a===6?e.top=l.readSVarint():a===7&&(e.advance=l.readVarint())}let f1=vm;function m1(a){let e=0,l=0;for(let B of a)e+=B.w*B.h,l=Math.max(l,B.w);a.sort((B,S)=>S.h-B.h);let u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),l),h:1/0}],m=0,w=0;for(let B of a)for(let S=u.length-1;S>=0;S--){let U=u[S];if(!(B.w>U.w||B.h>U.h)){if(B.x=U.x,B.y=U.y,w=Math.max(w,B.y+B.h),m=Math.max(m,B.x+B.w),B.w===U.w&&B.h===U.h){let M=u.pop();S=0&&u>=e&&rd[this.text.charCodeAt(u)];u--)l--;this.text=this.text.substring(e,l),this.sectionIndex=this.sectionIndex.slice(e,l)}substring(e,l){let u=new yu;return u.text=this.text.substring(e,l),u.sectionIndex=this.sectionIndex.slice(e,l),u.sections=this.sections,u}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,l)=>Math.max(e,this.sections[l].scale),0)}addTextSection(e,l){this.text+=e.text,this.sections.push(Th.forText(e.scale,e.fontStack||l));let u=this.sections.length-1;for(let m=0;m=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function id(a,e,l,u,m,w,B,S,U,M,D,z,et,nt,st,mt){let St=yu.fromFeature(a,m),Vt;z===A.ah.vertical&&St.verticalizePunctuation();let{processBidirectionalText:se,processStyledBidirectionalText:Wt}=Go;if(se&&St.sections.length===1){Vt=[];let Le=se(St.toString(),Bm(St,M,w,e,u,nt,st));for(let ni of Le){let bi=new yu;bi.text=ni,bi.sections=St.sections;for(let ri=0;ri0&&ml>ho&&(ho=ml)}else{let aa=bi[mr.fontStack],po=aa&&aa[ps];if(po&&po.rect)Ja=po.rect,ba=po.metrics;else{let ml=ni[mr.fontStack],Hh=ml&&ml[ps];if(!Hh)continue;ba=Hh.metrics}Qn=(Tn-mr.scale)*kn}va?(Le.verticalizable=!0,ks.push({glyph:ps,imageName:Xa,x:jr,y:nn+Qn,vertical:va,scale:mr.scale,fontStack:mr.fontStack,sectionIndex:Ls,metrics:ba,rect:Ja}),jr+=fl*mr.scale+Gi):(ks.push({glyph:ps,imageName:Xa,x:jr,y:nn+Qn,vertical:va,scale:mr.scale,fontStack:mr.fontStack,sectionIndex:Ls,metrics:ba,rect:Ja}),jr+=ba.advance*mr.scale+Gi)}ks.length!==0&&(Ln=Math.max(jr-Gi,Ln),ZS(ks,0,ks.length-1,Ds,ho)),jr=0;let go=Oe*Tn+ho;Os.lineOffset=Math.max(ho,Fs),nn+=go,Po=Math.max(go,Po),++wn}var os;let ds=nn-Eh,{horizontalAlign:Ks,verticalAlign:Ws}=_m(fi);(function(En,Tn,Fs,Os,ks,ho,go,Un,mr){let Ls=(Tn-Fs)*ks,ps=0;ps=ho!==go?-Un*Os-Eh:(-Os*mr+.5)*go;for(let Qn of En)for(let ba of Qn.positionedGlyphs)ba.x+=Ls,ba.y+=ps})(Le.positionedLines,Ds,Ks,Ws,Ln,Po,Oe,ds,ti.length),Le.top+=-Ws*ds,Le.bottom=Le.top+ds,Le.left+=-Ks*Ln,Le.right=Le.left+Ln}(be,e,l,u,Vt,B,S,U,z,M,et,mt),!function(Le){for(let ni of Le)if(ni.positionedGlyphs.length!==0)return!1;return!0}($t)&&be}let rd={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},RS={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function I1(a,e,l,u,m,w){if(e.imageName){let B=u[e.imageName];return B?B.displaySize[0]*e.scale*kn/w+m:0}{let B=l[e.fontStack],S=B&&B[a];return S?S.metrics.advance*e.scale+m:0}}function y1(a,e,l,u){let m=Math.pow(a-e,2);return u?a=0,D=0;for(let et=0;etB.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=mh([]),this.placementViewportMatrix=mh([]);let l=this.layers[0]._unevaluatedLayout._values;this.textSizeData=B1(this.zoom,l["text-size"]),this.iconSizeData=B1(this.zoom,l["icon-size"]);let u=this.layers[0].layout,m=u.get("symbol-sort-key"),w=u.get("symbol-z-order");this.canOverlap=xm(u,"text-overlap","text-allow-overlap")!=="never"||xm(u,"icon-overlap","icon-allow-overlap")!=="never"||u.get("text-ignore-placement")||u.get("icon-ignore-placement"),this.sortFeaturesByKey=w!=="viewport-y"&&!m.isConstant(),this.sortFeaturesByY=(w==="viewport-y"||w==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,u.get("symbol-placement")==="point"&&(this.writingModes=u.get("text-writing-mode").map(B=>A.ah[B])),this.stateDependentLayerIds=this.layers.filter(B=>B.isStateDependent()).map(B=>B.id),this.sourceID=e.sourceID}createArrays(){this.text=new Fm(new _r(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Fm(new _r(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new f,this.lineVertexArray=new b,this.symbolInstances=new p,this.textAnchorOffsets=new E}calculateGlyphDependencies(e,l,u,m,w){for(let B=0;B0)&&(B.value.kind!=="constant"||B.value.value.length>0),D=U.value.kind!=="constant"||!!U.value.value||Object.keys(U.parameters).length>0,z=w.get("symbol-sort-key");if(this.features=[],!M&&!D)return;let et=l.iconDependencies,nt=l.glyphDependencies,st=l.availableImages,mt=new Pr(this.zoom);for(let{feature:St,id:Vt,index:se,sourceLayerIndex:Wt}of e){let $t=m._featureFilter.needGeometry,be=sa(St,$t);if(!m._featureFilter.filter(mt,be,u))continue;let Le,ni;if($t||(be.geometry=Mr(St)),M){let ri=m.getValueAndResolveTokens("text-field",be,u,st),ti=Sr.factory(ri),Oe=this.hasRTLText=this.hasRTLText||VS(ti);(!Oe||Go.getRTLTextPluginStatus()==="unavailable"||Oe&&Go.isParsed())&&(Le=wS(ti,m,be))}if(D){let ri=m.getValueAndResolveTokens("icon-image",be,u,st);ni=ri instanceof Kn?ri:Kn.fromString(ri)}if(!Le&&!ni)continue;let bi=this.sortFeaturesByKey?z.evaluate(be,{},u):void 0;if(this.features.push({id:Vt,text:Le,icon:ni,index:se,sourceLayerIndex:Wt,geometry:be.geometry,properties:St.properties,type:MS[St.type],sortKey:bi}),ni&&(et[ni.name]=!0),Le){let ri=B.evaluate(be,{},u).join(","),ti=w.get("text-rotation-alignment")!=="viewport"&&w.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(A.ah.vertical)>=0;for(let Oe of Le.sections)if(Oe.image)et[Oe.image.name]=!0;else{let fi=Pa(Le.toString()),qe=Oe.fontStack||ri,Ze=nt[qe]=nt[qe]||{};this.calculateGlyphDependencies(Oe.text,Ze,ti,this.allowVerticalPlacement,fi)}}}w.get("symbol-placement")==="line"&&(this.features=function(St){let Vt={},se={},Wt=[],$t=0;function be(ri){Wt.push(St[ri]),$t++}function Le(ri,ti,Oe){let fi=se[ri];return delete se[ri],se[ti]=fi,Wt[fi].geometry[0].pop(),Wt[fi].geometry[0]=Wt[fi].geometry[0].concat(Oe[0]),fi}function ni(ri,ti,Oe){let fi=Vt[ti];return delete Vt[ti],Vt[ri]=fi,Wt[fi].geometry[0].shift(),Wt[fi].geometry[0]=Oe[0].concat(Wt[fi].geometry[0]),fi}function bi(ri,ti,Oe){let fi=Oe?ti[0][ti[0].length-1]:ti[0][0];return`${ri}:${fi.x}:${fi.y}`}for(let ri=0;riri.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((St,Vt)=>St.sortKey-Vt.sortKey)}update(e,l,u){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,l,this.layers,u),this.icon.programConfigurations.updatePaintArrays(e,l,this.layers,u))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,l){let u=this.lineVertexArray.length;if(e.segment!==void 0){let m=e.dist(l[e.segment+1]),w=e.dist(l[e.segment]),B={};for(let S=e.segment+1;S=0;S--)B[S]={x:l[S].x,y:l[S].y,tileUnitDistanceFromAnchor:w},S>0&&(w+=l[S-1].dist(l[S]));for(let S=0;S0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,l){let u=e.placedSymbolArray.get(l),m=u.vertexStartIndex+4*u.numGlyphs;for(let w=u.vertexStartIndex;wm[S]-m[U]||w[U]-w[S]),B}addToSortKeyRanges(e,l){let u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===l?u.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:l,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let l of this.symbolInstanceIndexes){let u=this.symbolInstances.get(l);this.featureSortOrder.push(u.featureIndex),[u.rightJustifiedTextSymbolIndex,u.centerJustifiedTextSymbolIndex,u.leftJustifiedTextSymbolIndex].forEach((m,w,B)=>{m>=0&&B.indexOf(m)===w&&this.addIndicesForPlacedSymbol(this.text,m)}),u.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,u.verticalPlacedTextSymbolIndex),u.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.placedIconSymbolIndex),u.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,u.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let _1,x1;si("SymbolBucket",bu,{omit:["layers","collisionBoxArray","features","compareText"]}),bu.MAX_GLYPHS=65535,bu.addDynamicAttributes=Sm;var Lm={get paint(){return x1=x1||new Jn({"icon-opacity":new Hi(xt.paint_symbol["icon-opacity"]),"icon-color":new Hi(xt.paint_symbol["icon-color"]),"icon-halo-color":new Hi(xt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Hi(xt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Hi(xt.paint_symbol["icon-halo-blur"]),"icon-translate":new wi(xt.paint_symbol["icon-translate"]),"icon-translate-anchor":new wi(xt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Hi(xt.paint_symbol["text-opacity"]),"text-color":new Hi(xt.paint_symbol["text-color"],{runtimeType:Zi,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new Hi(xt.paint_symbol["text-halo-color"]),"text-halo-width":new Hi(xt.paint_symbol["text-halo-width"]),"text-halo-blur":new Hi(xt.paint_symbol["text-halo-blur"]),"text-translate":new wi(xt.paint_symbol["text-translate"]),"text-translate-anchor":new wi(xt.paint_symbol["text-translate-anchor"])})},get layout(){return _1=_1||new Jn({"symbol-placement":new wi(xt.layout_symbol["symbol-placement"]),"symbol-spacing":new wi(xt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new wi(xt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Hi(xt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new wi(xt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new wi(xt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new wi(xt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new wi(xt.layout_symbol["icon-ignore-placement"]),"icon-optional":new wi(xt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new wi(xt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Hi(xt.layout_symbol["icon-size"]),"icon-text-fit":new wi(xt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new wi(xt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Hi(xt.layout_symbol["icon-image"]),"icon-rotate":new Hi(xt.layout_symbol["icon-rotate"]),"icon-padding":new Hi(xt.layout_symbol["icon-padding"]),"icon-keep-upright":new wi(xt.layout_symbol["icon-keep-upright"]),"icon-offset":new Hi(xt.layout_symbol["icon-offset"]),"icon-anchor":new Hi(xt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new wi(xt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new wi(xt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new wi(xt.layout_symbol["text-rotation-alignment"]),"text-field":new Hi(xt.layout_symbol["text-field"]),"text-font":new Hi(xt.layout_symbol["text-font"]),"text-size":new Hi(xt.layout_symbol["text-size"]),"text-max-width":new Hi(xt.layout_symbol["text-max-width"]),"text-line-height":new wi(xt.layout_symbol["text-line-height"]),"text-letter-spacing":new Hi(xt.layout_symbol["text-letter-spacing"]),"text-justify":new Hi(xt.layout_symbol["text-justify"]),"text-radial-offset":new Hi(xt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new wi(xt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Hi(xt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Hi(xt.layout_symbol["text-anchor"]),"text-max-angle":new wi(xt.layout_symbol["text-max-angle"]),"text-writing-mode":new wi(xt.layout_symbol["text-writing-mode"]),"text-rotate":new Hi(xt.layout_symbol["text-rotate"]),"text-padding":new wi(xt.layout_symbol["text-padding"]),"text-keep-upright":new wi(xt.layout_symbol["text-keep-upright"]),"text-transform":new Hi(xt.layout_symbol["text-transform"]),"text-offset":new Hi(xt.layout_symbol["text-offset"]),"text-allow-overlap":new wi(xt.layout_symbol["text-allow-overlap"]),"text-overlap":new wi(xt.layout_symbol["text-overlap"]),"text-ignore-placement":new wi(xt.layout_symbol["text-ignore-placement"]),"text-optional":new wi(xt.layout_symbol["text-optional"])})}};class S1{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:We,this.defaultValue=e}evaluate(e){if(e.formattedSection){let l=this.defaultValue.property.overrides;if(l&&l.hasOverride(e.formattedSection))return l.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}si("FormatSectionOverride",S1,{omit:["defaultValue"]});class sd extends ns{constructor(e){super(e,Lm)}recalculate(e,l){if(super.recalculate(e,l),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){let u=this.layout.get("text-writing-mode");if(u){let m=[];for(let w of u)m.indexOf(w)<0&&m.push(w);this.layout._values["text-writing-mode"]=m}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,l,u,m){let w=this.layout.get(e).evaluate(l,{},u,m),B=this._unevaluatedLayout._values[e];return B.isDataDriven()||Xi(B.value)||!w?w:function(S,U){return U.replace(/{([^{}]+)}/g,(M,D)=>S&&D in S?String(S[D]):"")}(l.properties,w)}createBucket(e){return new bu(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of Lm.paint.overridableProperties){if(!sd.hasPaintOverride(this.layout,e))continue;let l=this.paint.get(e),u=new S1(l),m=new Vr(u,l.property.specification),w=null;w=l.value.kind==="constant"||l.value.kind==="source"?new un("source",m):new hn("composite",m,l.value.zoomStops),this.paint._values[e]=new ao(l.property,w,l.parameters)}}_handleOverridablePaintPropertyUpdate(e,l,u){return!(!this.layout||l.isDataDriven()||u.isDataDriven())&&sd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,l){let u=e.get("text-field"),m=Lm.paint.properties[l],w=!1,B=S=>{for(let U of S)if(m.overrides&&m.overrides.hasOverride(U))return void(w=!0)};if(u.value.kind==="constant"&&u.value.value instanceof Sr)B(u.value.value.sections);else if(u.value.kind==="source"){let S=M=>{w||(M instanceof Ur&&Tr(M.value)===kr?B(M.value.sections):M instanceof Xo?B(M.sections):M.eachChild(S))},U=u.value;U._styleExpression&&S(U._styleExpression.expression)}return w}}let F1;var DS={get paint(){return F1=F1||new Jn({"background-color":new wi(xt.paint_background["background-color"]),"background-pattern":new wc(xt.paint_background["background-pattern"]),"background-opacity":new wi(xt.paint_background["background-opacity"])})}};class KS extends ns{constructor(e){super(e,DS)}}let k1;var WS={get paint(){return k1=k1||new Jn({"raster-opacity":new wi(xt.paint_raster["raster-opacity"]),"raster-hue-rotate":new wi(xt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new wi(xt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new wi(xt.paint_raster["raster-brightness-max"]),"raster-saturation":new wi(xt.paint_raster["raster-saturation"]),"raster-contrast":new wi(xt.paint_raster["raster-contrast"]),"raster-resampling":new wi(xt.paint_raster["raster-resampling"]),"raster-fade-duration":new wi(xt.paint_raster["raster-fade-duration"])})}};class OS extends ns{constructor(e){super(e,WS)}}class zS extends ns{constructor(e){super(e,{}),this.onAdd=l=>{this.implementation.onAdd&&this.implementation.onAdd(l,l.painter.context.gl)},this.onRemove=l=>{this.implementation.onRemove&&this.implementation.onRemove(l,l.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class JS{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let Em=63710088e-1;class Yl{constructor(e,l){if(isNaN(e)||isNaN(l))throw new Error(`Invalid LngLat object: (${e}, ${l})`);if(this.lng=+e,this.lat=+l,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Yl(Lt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let l=Math.PI/180,u=this.lat*l,m=e.lat*l,w=Math.sin(u)*Math.sin(m)+Math.cos(u)*Math.cos(m)*Math.cos((e.lng-this.lng)*l);return Em*Math.acos(Math.min(w,1))}static convert(e){if(e instanceof Yl)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Yl(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Yl(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}let L1=2*Math.PI*Em;function E1(a){return L1*Math.cos(a*Math.PI/180)}function T1(a){return(180+a)/360}function U1(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function Q1(a,e){return a/E1(e)}function Tm(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}class od{constructor(e,l,u=0){this.x=+e,this.y=+l,this.z=+u}static fromLngLat(e,l=0){let u=Yl.convert(e);return new od(T1(u.lng),U1(u.lat),Q1(l,u.lat))}toLngLat(){return new Yl(360*this.x-180,Tm(this.y))}toAltitude(){return this.z*E1(Tm(this.y))}meterInMercatorCoordinateUnits(){return 1/L1*(e=Tm(this.y),1/Math.cos(e*Math.PI/180));var e}}function G1(a,e,l){var u=2*Math.PI*6378137/256/Math.pow(2,l);return[a*u-2*Math.PI*6378137/2,e*u-2*Math.PI*6378137/2]}class Um{constructor(e,l,u){if(e<0||e>25||u<0||u>=Math.pow(2,e)||l<0||l>=Math.pow(2,e))throw new Error(`x=${l}, y=${u}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=l,this.y=u,this.key=Qh(0,e,e,l,u)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,l,u){let m=(B=this.y,S=this.z,U=G1(256*(w=this.x),256*(B=Math.pow(2,S)-B-1),S),M=G1(256*(w+1),256*(B+1),S),U[0]+","+U[1]+","+M[0]+","+M[1]);var w,B,S,U,M;let D=function(z,et,nt){let st,mt="";for(let St=z;St>0;St--)st=1<1?"@2x":"").replace(/{quadkey}/g,D).replace(/{bbox-epsg-3857}/g,m)}isChildOf(e){let l=this.z-e.z;return l>0&&e.x===this.x>>l&&e.y===this.y>>l}getTilePoint(e){let l=Math.pow(2,this.z);return new v((e.x*l-this.x)*$i,(e.y*l-this.y)*$i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class R1{constructor(e,l){this.wrap=e,this.canonical=l,this.key=Qh(e,l.z,l.z,l.x,l.y)}}class oa{constructor(e,l,u,m,w){if(e= z; overscaledZ = ${e}; z = ${u}`);this.overscaledZ=e,this.wrap=l,this.canonical=new Um(u,+m,+w),this.key=Qh(l,e,u,m,w)}clone(){return new oa(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let l=this.canonical.z-e;return e>this.canonical.z?new oa(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oa(e,this.wrap,e,this.canonical.x>>l,this.canonical.y>>l)}calculateScaledKey(e,l){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let u=this.canonical.z-e;return e>this.canonical.z?Qh(this.wrap*+l,e,this.canonical.z,this.canonical.x,this.canonical.y):Qh(this.wrap*+l,e,e,this.canonical.x>>u,this.canonical.y>>u)}isChildOf(e){if(e.wrap!==this.wrap)return!1;let l=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>l&&e.canonical.y===this.canonical.y>>l}children(e){if(this.overscaledZ>=e)return[new oa(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let l=this.canonical.z+1,u=2*this.canonical.x,m=2*this.canonical.y;return[new oa(l,this.wrap,l,u,m),new oa(l,this.wrap,l,u+1,m),new oa(l,this.wrap,l,u,m+1),new oa(l,this.wrap,l,u+1,m+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.max&&(this.max=z),z=this.dim+1||l<-1||l>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(l+1)*this.stride+(e+1)}unpack(e,l,u){return e*this.redFactor+l*this.greenFactor+u*this.blueFactor-this.baseShift}getPixels(){return new Vs({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,l,u){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let m=l*this.dim,w=l*this.dim+this.dim,B=u*this.dim,S=u*this.dim+this.dim;switch(l){case-1:m=w-1;break;case 1:w=m+1}switch(u){case-1:B=S-1;break;case 1:S=B+1}let U=-l*this.dim,M=-u*this.dim;for(let D=B;D=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class P1{constructor(e,l,u,m,w){this.type="Feature",this._vectorTileFeature=e,e._z=l,e._x=u,e._y=m,this.properties=e.properties,this.id=w}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let l in this)l!=="_geometry"&&l!=="_vectorTileFeature"&&(e[l]=this[l]);return e}}class M1{constructor(e,l){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ls($i,16,0),this.grid3D=new ls($i,16,0),this.featureIndexArray=new h,this.promoteId=l}insert(e,l,u,m,w,B){let S=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(u,m,w);let U=B?this.grid3D:this.grid;for(let M=0;M=0&&z[3]>=0&&U.insert(S,z[0],z[1],z[2],z[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new zl.VectorTile(new bm(this.rawTileData)).layers,this.sourceLayerCoder=new Z1(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,l,u,m){this.loadVTLayers();let w=e.params||{},B=$i/e.tileSize/e.scale,S=ga(w.filter),U=e.queryGeometry,M=e.queryPadding*B,D=V1(U),z=this.grid.query(D.minX-M,D.minY-M,D.maxX+M,D.maxY+M),et=V1(e.cameraQueryGeometry),nt=this.grid3D.query(et.minX-M,et.minY-M,et.maxX+M,et.maxY+M,(St,Vt,se,Wt)=>function($t,be,Le,ni,bi){for(let ti of $t)if(be<=ti.x&&Le<=ti.y&&ni>=ti.x&&bi>=ti.y)return!0;let ri=[new v(be,Le),new v(be,bi),new v(ni,bi),new v(ni,Le)];if($t.length>2){for(let ti of ri)if(Wa($t,ti))return!0}for(let ti=0;ti<$t.length-1;ti++)if(fh($t[ti],$t[ti+1],ri))return!0;return!1}(e.cameraQueryGeometry,St-M,Vt-M,se+M,Wt+M));for(let St of nt)z.push(St);z.sort(XS);let st={},mt;for(let St=0;St(Wt||(Wt=Mr($t)),be.queryIntersectsFeature(U,$t,Le,Wt,this.z,e.transform,B,e.pixelPosMatrix)))}return st}loadMatchingFeature(e,l,u,m,w,B,S,U,M,D,z){let et=this.bucketLayerIDs[l];if(B&&!function(St,Vt){for(let se=0;se=0)return!0;return!1}(B,et))return;let nt=this.sourceLayerCoder.decode(u),st=this.vtLayers[nt].feature(m);if(w.needGeometry){let St=sa(st,!0);if(!w.filter(new Pr(this.tileID.overscaledZ),St,this.tileID.canonical))return}else if(!w.filter(new Pr(this.tileID.overscaledZ),st))return;let mt=this.getId(st,nt);for(let St=0;St{let S=e instanceof SA?e.get(B):null;return S&&S.evaluate?S.evaluate(l,u,m):S})}function V1(a){let e=1/0,l=1/0,u=-1/0,m=-1/0;for(let w of a)e=Math.min(e,w.x),l=Math.min(l,w.y),u=Math.max(u,w.x),m=Math.max(m,w.y);return{minX:e,minY:l,maxX:u,maxY:m}}function XS(a,e){return e-a}function D1(a,e,l,u,m){let w=[];for(let B=0;B=u&&z.x>=u||(D.x>=u?D=new v(u,D.y+(u-D.x)/(z.x-D.x)*(z.y-D.y))._round():z.x>=u&&(z=new v(u,D.y+(u-D.x)/(z.x-D.x)*(z.y-D.y))._round()),D.y>=m&&z.y>=m||(D.y>=m?D=new v(D.x+(m-D.y)/(z.y-D.y)*(z.x-D.x),m)._round():z.y>=m&&(z=new v(D.x+(m-D.y)/(z.y-D.y)*(z.x-D.x),m)._round()),U&&D.equals(U[U.length-1])||(U=[D],w.push(U)),U.push(z)))))}}return w}si("FeatureIndex",M1,{omit:["rawTileData","sourceLayerCoder"]});class jl extends v{constructor(e,l,u,m){super(e,l),this.angle=u,m!==void 0&&(this.segment=m)}clone(){return new jl(this.x,this.y,this.angle,this.segment)}}function K1(a,e,l,u,m){if(e.segment===void 0||l===0)return!0;let w=e,B=e.segment+1,S=0;for(;S>-l/2;){if(B--,B<0)return!1;S-=a[B].dist(w),w=a[B]}S+=a[B].dist(a[B+1]),B++;let U=[],M=0;for(;Su;)M-=U.shift().angleDelta;if(M>m)return!1;B++,S+=D.dist(z)}return!0}function W1(a){let e=0;for(let l=0;lM){let st=(M-U)/nt,mt=qn.number(z.x,et.x,st),St=qn.number(z.y,et.y,st),Vt=new jl(mt,St,et.angleTo(z),D);return Vt._round(),!B||K1(a,Vt,S,B,e)?Vt:void 0}U+=nt}}function jS(a,e,l,u,m,w,B,S,U){let M=O1(u,w,B),D=z1(u,m),z=D*B,et=a[0].x===0||a[0].x===U||a[0].y===0||a[0].y===U;return e-z=0&&$t=0&&be=0&&et+M<=D){let Le=new jl($t,be,se,st);Le._round(),u&&!K1(a,Le,w,u,m)||nt.push(Le)}}z+=Vt}return S||nt.length||B||(nt=J1(a,z/2,l,u,m,w,B,!0,U)),nt}si("Anchor",jl);let vu=uo;function X1(a,e,l,u){let m=[],w=a.image,B=w.pixelRatio,S=w.paddedRect.w-2*vu,U=w.paddedRect.h-2*vu,M=a.right-a.left,D=a.bottom-a.top,z=w.stretchX||[[0,S]],et=w.stretchY||[[0,U]],nt=(Oe,fi)=>Oe+fi[1]-fi[0],st=z.reduce(nt,0),mt=et.reduce(nt,0),St=S-st,Vt=U-mt,se=0,Wt=st,$t=0,be=mt,Le=0,ni=St,bi=0,ri=Vt;if(w.content&&u){let Oe=w.content;se=ad(z,0,Oe[0]),$t=ad(et,0,Oe[1]),Wt=ad(z,Oe[0],Oe[2]),be=ad(et,Oe[1],Oe[3]),Le=Oe[0]-se,bi=Oe[1]-$t,ni=Oe[2]-Oe[0]-Wt,ri=Oe[3]-Oe[1]-be}let ti=(Oe,fi,qe,Ze)=>{let Gi=Ad(Oe.stretch-se,Wt,M,a.left),Bi=ld(Oe.fixed-Le,ni,Oe.stretch,st),hr=Ad(fi.stretch-$t,be,D,a.top),jr=ld(fi.fixed-bi,ri,fi.stretch,mt),nn=Ad(qe.stretch-se,Wt,M,a.left),Ln=ld(qe.fixed-Le,ni,qe.stretch,st),Po=Ad(Ze.stretch-$t,be,D,a.top),Ds=ld(Ze.fixed-bi,ri,Ze.stretch,mt),wn=new v(Gi,hr),os=new v(nn,hr),ds=new v(nn,Po),Ks=new v(Gi,Po),Ws=new v(Bi/B,jr/B),En=new v(Ln/B,Ds/B),Tn=e*Math.PI/180;if(Tn){let ks=Math.sin(Tn),ho=Math.cos(Tn),go=[ho,-ks,ks,ho];wn._matMult(go),os._matMult(go),Ks._matMult(go),ds._matMult(go)}let Fs=Oe.stretch+Oe.fixed,Os=fi.stretch+fi.fixed;return{tl:wn,tr:os,bl:Ks,br:ds,tex:{x:w.paddedRect.x+vu+Fs,y:w.paddedRect.y+vu+Os,w:qe.stretch+qe.fixed-Fs,h:Ze.stretch+Ze.fixed-Os},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ws,pixelOffsetBR:En,minFontScaleX:ni/B/M,minFontScaleY:ri/B/D,isSDF:l}};if(u&&(w.stretchX||w.stretchY)){let Oe=Y1(z,St,st),fi=Y1(et,Vt,mt);for(let qe=0;qe0&&(st=Math.max(10,st),this.circleDiameter=st)}else{let z=B.top*S-U[0],et=B.bottom*S+U[2],nt=B.left*S-U[3],st=B.right*S+U[1],mt=B.collisionPadding;if(mt&&(nt-=mt[0]*S,z-=mt[1]*S,st+=mt[2]*S,et+=mt[3]*S),D){let St=new v(nt,z),Vt=new v(st,z),se=new v(nt,et),Wt=new v(st,et),$t=D*Math.PI/180;St._rotate($t),Vt._rotate($t),se._rotate($t),Wt._rotate($t),nt=Math.min(St.x,Vt.x,se.x,Wt.x),st=Math.max(St.x,Vt.x,se.x,Wt.x),z=Math.min(St.y,Vt.y,se.y,Wt.y),et=Math.max(St.y,Vt.y,se.y,Wt.y)}e.emplaceBack(l.x,l.y,nt,z,st,et,u,m,w)}this.boxEndIndex=e.length}}class qS{constructor(e=[],l=$S){if(this.data=e,this.length=this.data.length,this.compare=l,this.length>0)for(let u=(this.length>>1)-1;u>=0;u--)this._down(u)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let e=this.data[0],l=this.data.pop();return this.length--,this.length>0&&(this.data[0]=l,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:l,compare:u}=this,m=l[e];for(;e>0;){let w=e-1>>1,B=l[w];if(u(m,B)>=0)break;l[e]=B,e=w}l[e]=m}_down(e){let{data:l,compare:u}=this,m=this.length>>1,w=l[e];for(;e=0)break;l[e]=S,e=B}l[e]=w}}function $S(a,e){return ae?1:0}function t3(a,e=1,l=!1){let u=1/0,m=1/0,w=-1/0,B=-1/0,S=a[0];for(let nt=0;ntw)&&(w=st.x),(!nt||st.y>B)&&(B=st.y)}let U=Math.min(w-u,B-m),M=U/2,D=new qS([],e3);if(U===0)return new v(u,m);for(let nt=u;ntz.d||!z.d)&&(z=nt,l&&console.log("found best %d after %d probes",Math.round(1e4*nt.d)/1e4,et)),nt.max-z.d<=e||(M=nt.h/2,D.push(new wu(nt.p.x-M,nt.p.y-M,M,a)),D.push(new wu(nt.p.x+M,nt.p.y-M,M,a)),D.push(new wu(nt.p.x-M,nt.p.y+M,M,a)),D.push(new wu(nt.p.x+M,nt.p.y+M,M,a)),et+=4)}return l&&(console.log(`num probes: ${et}`),console.log(`best distance: ${z.d}`)),z.p}function e3(a,e){return e.max-a.max}function wu(a,e,l,u){this.p=new v(a,e),this.h=l,this.d=function(m,w){let B=!1,S=1/0;for(let U=0;Um.y!=st.y>m.y&&m.x<(st.x-nt.x)*(m.y-nt.y)/(st.y-nt.y)+nt.x&&(B=!B),S=Math.min(S,Fc(m,nt,st))}}return(B?1:-1)*Math.sqrt(S)}(this.p,u),this.max=this.d+this.h*Math.SQRT2}var gs;A.ap=void 0,(gs=A.ap||(A.ap={}))[gs.center=1]="center",gs[gs.left=2]="left",gs[gs.right=3]="right",gs[gs.top=4]="top",gs[gs.bottom=5]="bottom",gs[gs["top-left"]=6]="top-left",gs[gs["top-right"]=7]="top-right",gs[gs["bottom-left"]=8]="bottom-left",gs[gs["bottom-right"]=9]="bottom-right";let ql=7,Qm=Number.POSITIVE_INFINITY;function j1(a,e){return e[1]!==Qm?function(l,u,m){let w=0,B=0;switch(u=Math.abs(u),m=Math.abs(m),l){case"top-right":case"top-left":case"top":B=m-ql;break;case"bottom-right":case"bottom-left":case"bottom":B=-m+ql}switch(l){case"top-right":case"bottom-right":case"right":w=-u;break;case"top-left":case"bottom-left":case"left":w=u}return[w,B]}(a,e[0],e[1]):function(l,u){let m=0,w=0;u<0&&(u=0);let B=u/Math.SQRT2;switch(l){case"top-right":case"top-left":w=B-ql;break;case"bottom-right":case"bottom-left":w=-B+ql;break;case"bottom":w=-u+ql;break;case"top":w=u-ql}switch(l){case"top-right":case"bottom-right":m=-B;break;case"top-left":case"bottom-left":m=B;break;case"left":m=u;break;case"right":m=-u}return[m,w]}(a,e[0])}function q1(a,e,l){var u;let m=a.layout,w=(u=m.get("text-variable-anchor-offset"))===null||u===void 0?void 0:u.evaluate(e,{},l);if(w){let S=w.values,U=[];for(let M=0;Met*kn);D.startsWith("top")?z[1]-=ql:D.startsWith("bottom")&&(z[1]+=ql),U[M+1]=z}return new an(U)}let B=m.get("text-variable-anchor");if(B){let S;S=a._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[m.get("text-radial-offset").evaluate(e,{},l)*kn,Qm]:m.get("text-offset").evaluate(e,{},l).map(M=>M*kn);let U=[];for(let M of B)U.push(M,j1(M,S));return new an(U)}return null}function Gm(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function i3(a,e,l,u,m,w,B,S,U,M,D){let z=w.textMaxSize.evaluate(e,{});z===void 0&&(z=B);let et=a.layers[0].layout,nt=et.get("icon-offset").evaluate(e,{},D),st=tb(l.horizontal),mt=B/24,St=a.tilePixelRatio*mt,Vt=a.tilePixelRatio*z/24,se=a.tilePixelRatio*S,Wt=a.tilePixelRatio*et.get("symbol-spacing"),$t=et.get("text-padding")*a.tilePixelRatio,be=function(Ze,Gi,Bi,hr=1){let jr=Ze.get("icon-padding").evaluate(Gi,{},Bi),nn=jr&&jr.values;return[nn[0]*hr,nn[1]*hr,nn[2]*hr,nn[3]*hr]}(et,e,D,a.tilePixelRatio),Le=et.get("text-max-angle")/180*Math.PI,ni=et.get("text-rotation-alignment")!=="viewport"&&et.get("symbol-placement")!=="point",bi=et.get("icon-rotation-alignment")==="map"&&et.get("symbol-placement")!=="point",ri=et.get("symbol-placement"),ti=Wt/2,Oe=et.get("icon-text-fit"),fi;u&&Oe!=="none"&&(a.allowVerticalPlacement&&l.vertical&&(fi=w1(u,l.vertical,Oe,et.get("icon-text-fit-padding"),nt,mt)),st&&(u=w1(u,st,Oe,et.get("icon-text-fit-padding"),nt,mt)));let qe=(Ze,Gi)=>{Gi.x<0||Gi.x>=$i||Gi.y<0||Gi.y>=$i||function(Bi,hr,jr,nn,Ln,Po,Ds,wn,os,ds,Ks,Ws,En,Tn,Fs,Os,ks,ho,go,Un,mr,Ls,ps,Qn,ba){let Ja=Bi.addToLineVertexArray(hr,jr),Xa,fl,va,aa,po=0,ml=0,Hh=0,nb=0,Dm=-1,Km=-1,Cl={},sb=pi("");if(Bi.allowVerticalPlacement&&nn.vertical){let Es=wn.layout.get("text-rotate").evaluate(mr,{},Qn)+90;va=new cd(os,hr,ds,Ks,Ws,nn.vertical,En,Tn,Fs,Es),Ds&&(aa=new cd(os,hr,ds,Ks,Ws,Ds,ks,ho,Fs,Es))}if(Ln){let Es=wn.layout.get("icon-rotate").evaluate(mr,{}),Aa=wn.layout.get("icon-text-fit")!=="none",Tc=X1(Ln,Es,ps,Aa),ja=Ds?X1(Ds,Es,ps,Aa):void 0;fl=new cd(os,hr,ds,Ks,Ws,Ln,ks,ho,!1,Es),po=4*Tc.length;let Uc=Bi.iconSizeData,VA=null;Uc.kind==="source"?(VA=[NA*wn.layout.get("icon-size").evaluate(mr,{})],VA[0]>Xl&&At(`${Bi.layerIds[0]}: Value for "icon-size" is >= ${Uh}. Reduce your "icon-size".`)):Uc.kind==="composite"&&(VA=[NA*Ls.compositeIconSizes[0].evaluate(mr,{},Qn),NA*Ls.compositeIconSizes[1].evaluate(mr,{},Qn)],(VA[0]>Xl||VA[1]>Xl)&&At(`${Bi.layerIds[0]}: Value for "icon-size" is >= ${Uh}. Reduce your "icon-size".`)),Bi.addSymbols(Bi.icon,Tc,VA,Un,go,mr,A.ah.none,hr,Ja.lineStartIndex,Ja.lineLength,-1,Qn),Dm=Bi.icon.placedSymbolArray.length-1,ja&&(ml=4*ja.length,Bi.addSymbols(Bi.icon,ja,VA,Un,go,mr,A.ah.vertical,hr,Ja.lineStartIndex,Ja.lineLength,-1,Qn),Km=Bi.icon.placedSymbolArray.length-1)}let ob=Object.keys(nn.horizontal);for(let Es of ob){let Aa=nn.horizontal[Es];if(!Xa){sb=pi(Aa.text);let ja=wn.layout.get("text-rotate").evaluate(mr,{},Qn);Xa=new cd(os,hr,ds,Ks,Ws,Aa,En,Tn,Fs,ja)}let Tc=Aa.positionedLines.length===1;if(Hh+=$1(Bi,hr,Aa,Po,wn,Fs,mr,Os,Ja,nn.vertical?A.ah.horizontal:A.ah.horizontalOnly,Tc?ob:[Es],Cl,Dm,Ls,Qn),Tc)break}nn.vertical&&(nb+=$1(Bi,hr,nn.vertical,Po,wn,Fs,mr,Os,Ja,A.ah.vertical,["vertical"],Cl,Km,Ls,Qn));let s3=Xa?Xa.boxStartIndex:Bi.collisionBoxArray.length,o3=Xa?Xa.boxEndIndex:Bi.collisionBoxArray.length,a3=va?va.boxStartIndex:Bi.collisionBoxArray.length,A3=va?va.boxEndIndex:Bi.collisionBoxArray.length,l3=fl?fl.boxStartIndex:Bi.collisionBoxArray.length,c3=fl?fl.boxEndIndex:Bi.collisionBoxArray.length,u3=aa?aa.boxStartIndex:Bi.collisionBoxArray.length,h3=aa?aa.boxEndIndex:Bi.collisionBoxArray.length,Ya=-1,hd=(Es,Aa)=>Es&&Es.circleDiameter?Math.max(Es.circleDiameter,Aa):Aa;Ya=hd(Xa,Ya),Ya=hd(va,Ya),Ya=hd(fl,Ya),Ya=hd(aa,Ya);let ab=Ya>-1?1:0;ab&&(Ya*=ba/kn),Bi.glyphOffsetArray.length>=bu.MAX_GLYPHS&&At("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),mr.sortKey!==void 0&&Bi.addToSortKeyRanges(Bi.symbolInstances.length,mr.sortKey);let g3=q1(wn,mr,Qn),[d3,p3]=function(Es,Aa){let Tc=Es.length,ja=Aa?.values;if(ja?.length>0)for(let Uc=0;Uc=0?Cl.right:-1,Cl.center>=0?Cl.center:-1,Cl.left>=0?Cl.left:-1,Cl.vertical||-1,Dm,Km,sb,s3,o3,a3,A3,l3,c3,u3,h3,ds,Hh,nb,po,ml,ab,0,En,Ya,d3,p3)}(a,Gi,Ze,l,u,m,fi,a.layers[0],a.collisionBoxArray,e.index,e.sourceLayerIndex,a.index,St,[$t,$t,$t,$t],ni,U,se,be,bi,nt,e,w,M,D,B)};if(ri==="line")for(let Ze of D1(e.geometry,0,0,$i,$i)){let Gi=jS(Ze,Wt,Le,l.vertical||st,u,24,Vt,a.overscaling,$i);for(let Bi of Gi)st&&r3(a,st.text,ti,Bi)||qe(Ze,Bi)}else if(ri==="line-center"){for(let Ze of e.geometry)if(Ze.length>1){let Gi=YS(Ze,Le,l.vertical||st,u,24,Vt);Gi&&qe(Ze,Gi)}}else if(e.type==="Polygon")for(let Ze of gm(e.geometry,0)){let Gi=t3(Ze,16);qe(Ze[0],new jl(Gi.x,Gi.y,0))}else if(e.type==="LineString")for(let Ze of e.geometry)qe(Ze,new jl(Ze[0].x,Ze[0].y,0));else if(e.type==="Point")for(let Ze of e.geometry)for(let Gi of Ze)qe([Gi],new jl(Gi.x,Gi.y,0))}function $1(a,e,l,u,m,w,B,S,U,M,D,z,et,nt,st){let mt=function(se,Wt,$t,be,Le,ni,bi,ri){let ti=be.layout.get("text-rotate").evaluate(ni,{})*Math.PI/180,Oe=[];for(let fi of Wt.positionedLines)for(let qe of fi.positionedGlyphs){if(!qe.rect)continue;let Ze=qe.rect||{},Gi=f1+1,Bi=!0,hr=1,jr=0,nn=(Le||ri)&&qe.vertical,Ln=qe.metrics.advance*qe.scale/2;if(ri&&Wt.verticalizable&&(jr=fi.lineOffset/2-(qe.imageName?-(kn-qe.metrics.width*qe.scale)/2:(qe.scale-1)*kn)),qe.imageName){let Un=bi[qe.imageName];Bi=Un.sdf,hr=Un.pixelRatio,Gi=uo/hr}let Po=Le?[qe.x+Ln,qe.y]:[0,0],Ds=Le?[0,0]:[qe.x+Ln+$t[0],qe.y+$t[1]-jr],wn=[0,0];nn&&(wn=Ds,Ds=[0,0]);let os=qe.metrics.isDoubleResolution?2:1,ds=(qe.metrics.left-Gi)*qe.scale-Ln+Ds[0],Ks=(-qe.metrics.top-Gi)*qe.scale+Ds[1],Ws=ds+Ze.w/os*qe.scale/hr,En=Ks+Ze.h/os*qe.scale/hr,Tn=new v(ds,Ks),Fs=new v(Ws,Ks),Os=new v(ds,En),ks=new v(Ws,En);if(nn){let Un=new v(-Ln,Ln-Eh),mr=-Math.PI/2,Ls=kn/2-Ln,ps=new v(5-Eh-Ls,-(qe.imageName?Ls:0)),Qn=new v(...wn);Tn._rotateAround(mr,Un)._add(ps)._add(Qn),Fs._rotateAround(mr,Un)._add(ps)._add(Qn),Os._rotateAround(mr,Un)._add(ps)._add(Qn),ks._rotateAround(mr,Un)._add(ps)._add(Qn)}if(ti){let Un=Math.sin(ti),mr=Math.cos(ti),Ls=[mr,-Un,Un,mr];Tn._matMult(Ls),Fs._matMult(Ls),Os._matMult(Ls),ks._matMult(Ls)}let ho=new v(0,0),go=new v(0,0);Oe.push({tl:Tn,tr:Fs,bl:Os,br:ks,tex:Ze,writingMode:Wt.writingMode,glyphOffset:Po,sectionIndex:qe.sectionIndex,isSDF:Bi,pixelOffsetTL:ho,pixelOffsetBR:go,minFontScaleX:0,minFontScaleY:0})}return Oe}(0,l,S,m,w,B,u,a.allowVerticalPlacement),St=a.textSizeData,Vt=null;St.kind==="source"?(Vt=[NA*m.layout.get("text-size").evaluate(B,{})],Vt[0]>Xl&&At(`${a.layerIds[0]}: Value for "text-size" is >= ${Uh}. Reduce your "text-size".`)):St.kind==="composite"&&(Vt=[NA*nt.compositeTextSizes[0].evaluate(B,{},st),NA*nt.compositeTextSizes[1].evaluate(B,{},st)],(Vt[0]>Xl||Vt[1]>Xl)&&At(`${a.layerIds[0]}: Value for "text-size" is >= ${Uh}. Reduce your "text-size".`)),a.addSymbols(a.text,mt,Vt,S,w,B,M,e,U.lineStartIndex,U.lineLength,et,st);for(let se of D)z[se]=a.text.placedSymbolArray.length-1;return 4*mt.length}function tb(a){for(let e in a)return a[e];return null}function r3(a,e,l,u){let m=a.compareText;if(e in m){let w=m[e];for(let B=w.length-1;B>=0;B--)if(u.dist(w[B])>4;if(m!==1)throw new Error(`Got v${m} data when expected v1.`);let w=eb[15&u];if(!w)throw new Error("Unrecognized array type.");let[B]=new Uint16Array(e,2,1),[S]=new Uint32Array(e,4,1);return new Rm(S,B,w,e)}constructor(e,l=64,u=Float64Array,m){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+l,2),65535),this.ArrayType=u,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let w=eb.indexOf(this.ArrayType),B=2*e*this.ArrayType.BYTES_PER_ELEMENT,S=e*this.IndexArrayType.BYTES_PER_ELEMENT,U=(8-S%8)%8;if(w<0)throw new Error(`Unexpected typed array class: ${u}.`);m&&m instanceof ArrayBuffer?(this.data=m,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+S+U,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+B+S+U),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+S+U,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+w]),new Uint16Array(this.data,2,1)[0]=l,new Uint32Array(this.data,4,1)[0]=e)}add(e,l){let u=this._pos>>1;return this.ids[u]=u,this.coords[this._pos++]=e,this.coords[this._pos++]=l,u}finish(){let e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Hm(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,l,u,m){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:w,coords:B,nodeSize:S}=this,U=[0,w.length-1,0],M=[];for(;U.length;){let D=U.pop()||0,z=U.pop()||0,et=U.pop()||0;if(z-et<=S){for(let St=et;St<=z;St++){let Vt=B[2*St],se=B[2*St+1];Vt>=e&&Vt<=u&&se>=l&&se<=m&&M.push(w[St])}continue}let nt=et+z>>1,st=B[2*nt],mt=B[2*nt+1];st>=e&&st<=u&&mt>=l&&mt<=m&&M.push(w[nt]),(D===0?e<=st:l<=mt)&&(U.push(et),U.push(nt-1),U.push(1-D)),(D===0?u>=st:m>=mt)&&(U.push(nt+1),U.push(z),U.push(1-D))}return M}within(e,l,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:m,coords:w,nodeSize:B}=this,S=[0,m.length-1,0],U=[],M=u*u;for(;S.length;){let D=S.pop()||0,z=S.pop()||0,et=S.pop()||0;if(z-et<=B){for(let St=et;St<=z;St++)rb(w[2*St],w[2*St+1],e,l)<=M&&U.push(m[St]);continue}let nt=et+z>>1,st=w[2*nt],mt=w[2*nt+1];rb(st,mt,e,l)<=M&&U.push(m[nt]),(D===0?e-u<=st:l-u<=mt)&&(S.push(et),S.push(nt-1),S.push(1-D)),(D===0?e+u>=st:l+u>=mt)&&(S.push(nt+1),S.push(z),S.push(1-D))}return U}}function Hm(a,e,l,u,m,w){if(m-u<=l)return;let B=u+m>>1;ib(a,e,B,u,m,w),Hm(a,e,l,u,B-1,1-w),Hm(a,e,l,B+1,m,1-w)}function ib(a,e,l,u,m,w){for(;m>u;){if(m-u>600){let M=m-u+1,D=l-u+1,z=Math.log(M),et=.5*Math.exp(2*z/3),nt=.5*Math.sqrt(z*et*(M-et)/M)*(D-M/2<0?-1:1);ib(a,e,l,Math.max(u,Math.floor(l-D*et/M+nt)),Math.min(m,Math.floor(l+(M-D)*et/M+nt)),w)}let B=e[2*l+w],S=u,U=m;for(Gh(a,e,u,l),e[2*m+w]>B&&Gh(a,e,u,m);SB;)U--}e[2*u+w]===B?Gh(a,e,u,U):(U++,Gh(a,e,U,m)),U<=l&&(u=U+1),l<=U&&(m=U-1)}}function Gh(a,e,l,u){Zm(a,l,u),Zm(e,2*l,2*u),Zm(e,2*l+1,2*u+1)}function Zm(a,e,l){let u=a[e];a[e]=a[l],a[l]=u}function rb(a,e,l,u){let m=a-l,w=e-u;return m*m+w*w}var Pm;A.bd=void 0,(Pm=A.bd||(A.bd={})).create="create",Pm.load="load",Pm.fullLoad="fullLoad";let ud=null,Rh=[],Mm=1e3/60,Nm="loadTime",Vm="fullLoadTime",n3={mark(a){performance.mark(a)},frame(a){let e=a;ud!=null&&Rh.push(e-ud),ud=e},clearMetrics(){ud=null,Rh=[],performance.clearMeasures(Nm),performance.clearMeasures(Vm);for(let a in A.bd)performance.clearMarks(A.bd[a])},getPerformanceMetrics(){performance.measure(Nm,A.bd.create,A.bd.load),performance.measure(Vm,A.bd.create,A.bd.fullLoad);let a=performance.getEntriesByName(Nm)[0].duration,e=performance.getEntriesByName(Vm)[0].duration,l=Rh.length,u=1/(Rh.reduce((w,B)=>w+B,0)/l/1e3),m=Rh.filter(w=>w>Mm).reduce((w,B)=>w+(B-Mm)/Mm,0);return{loadTime:a,fullLoadTime:e,fps:u,percentDroppedFrames:m/(l+m)*100,totalFrames:l}}};A.$=Ct,A.A=Vl,A.B=function(a){if(le==null){let e=a.navigator?a.navigator.userAgent:null;le=!!a.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return le},A.C=class{constructor(a,e){this.target=a,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new JS(()=>this.process()),this.subscription=function(l,u,m,w){return l.addEventListener(u,m,!1),{unsubscribe:()=>{l.removeEventListener(u,m,!1)}}}(this.target,"message",l=>this.receive(l)),this.globalScope=_t(self)?a:window}registerMessageHandler(a,e){this.messageHandlers[a]=e}sendAsync(a,e){return new Promise((l,u)=>{let m=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[m]={resolve:l,reject:u},e&&e.signal.addEventListener("abort",()=>{delete this.resolveRejects[m];let S={id:m,type:"",origin:location.origin,targetMapId:a.targetMapId,sourceMapId:this.mapId};this.target.postMessage(S)},{once:!0});let w=[],B=Object.assign(Object.assign({},a),{id:m,sourceMapId:this.mapId,origin:location.origin,data:Ca(a.data,w)});this.target.postMessage(B,{transfer:w})})}receive(a){let e=a.data,l=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type===""){delete this.tasks[l];let u=this.abortControllers[l];return delete this.abortControllers[l],void(u&&u.abort())}if(_t(self)||e.mustQueue)return this.tasks[l]=e,this.taskQueue.push(l),void this.invoker.trigger();this.processTask(l,e)}}process(){if(this.taskQueue.length===0)return;let a=this.taskQueue.shift(),e=this.tasks[a];delete this.tasks[a],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(a,e)}processTask(a,e){return o(this,void 0,void 0,function*(){if(e.type===""){let m=this.resolveRejects[a];return delete this.resolveRejects[a],m?void(e.error?m.reject(Za(e.error)):m.resolve(Za(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(a,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));let l=Za(e.data),u=new AbortController;this.abortControllers[a]=u;try{let m=yield this.messageHandlers[e.type](e.sourceMapId,l,u);this.completeTask(a,null,m)}catch(m){this.completeTask(a,m)}})}completeTask(a,e,l){let u=[];delete this.abortControllers[a];let m={id:a,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Ca(e):null,data:Ca(l,u)};this.target.postMessage(m,{transfer:u})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},A.D=wi,A.E=gi,A.F=function(){var a=new Vl(16);return Vl!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},A.G=Ht,A.H=function(a,e,l){var u,m,w,B,S,U,M,D,z,et,nt,st,mt=l[0],St=l[1],Vt=l[2];return e===a?(a[12]=e[0]*mt+e[4]*St+e[8]*Vt+e[12],a[13]=e[1]*mt+e[5]*St+e[9]*Vt+e[13],a[14]=e[2]*mt+e[6]*St+e[10]*Vt+e[14],a[15]=e[3]*mt+e[7]*St+e[11]*Vt+e[15]):(m=e[1],w=e[2],B=e[3],S=e[4],U=e[5],M=e[6],D=e[7],z=e[8],et=e[9],nt=e[10],st=e[11],a[0]=u=e[0],a[1]=m,a[2]=w,a[3]=B,a[4]=S,a[5]=U,a[6]=M,a[7]=D,a[8]=z,a[9]=et,a[10]=nt,a[11]=st,a[12]=u*mt+S*St+z*Vt+e[12],a[13]=m*mt+U*St+et*Vt+e[13],a[14]=w*mt+M*St+nt*Vt+e[14],a[15]=B*mt+D*St+st*Vt+e[15]),a},A.I=wm,A.J=function(a,e,l){var u=l[0],m=l[1],w=l[2];return a[0]=e[0]*u,a[1]=e[1]*u,a[2]=e[2]*u,a[3]=e[3]*u,a[4]=e[4]*m,a[5]=e[5]*m,a[6]=e[6]*m,a[7]=e[7]*m,a[8]=e[8]*w,a[9]=e[9]*w,a[10]=e[10]*w,a[11]=e[11]*w,a[12]=e[12],a[13]=e[13],a[14]=e[14],a[15]=e[15],a},A.K=Ch,A.L=function(a,e){let l={};for(let u=0;u{let e=window.document.createElement("video");return e.muted=!0,new Promise(l=>{e.onloadstart=()=>{l(e)};for(let u of a){let m=window.document.createElement("source");de(u)||(e.crossOrigin="Anonymous"),m.src=u,e.appendChild(m)}})},A.a3=function(){return Ut++},A.a4=Au,A.a5=bu,A.a6=ga,A.a7=sa,A.a8=Pr,A.a9=P1,A.aA=Jt,A.aB=function(a,e){if(!a)return[{command:"setStyle",args:[e]}];let l=[];try{if(!Qe(a.version,e.version))return[{command:"setStyle",args:[e]}];Qe(a.center,e.center)||l.push({command:"setCenter",args:[e.center]}),Qe(a.zoom,e.zoom)||l.push({command:"setZoom",args:[e.zoom]}),Qe(a.bearing,e.bearing)||l.push({command:"setBearing",args:[e.bearing]}),Qe(a.pitch,e.pitch)||l.push({command:"setPitch",args:[e.pitch]}),Qe(a.sprite,e.sprite)||l.push({command:"setSprite",args:[e.sprite]}),Qe(a.glyphs,e.glyphs)||l.push({command:"setGlyphs",args:[e.glyphs]}),Qe(a.transition,e.transition)||l.push({command:"setTransition",args:[e.transition]}),Qe(a.light,e.light)||l.push({command:"setLight",args:[e.light]}),Qe(a.terrain,e.terrain)||l.push({command:"setTerrain",args:[e.terrain]}),Qe(a.sky,e.sky)||l.push({command:"setSky",args:[e.sky]});let u={},m=[];(function(B,S,U,M){let D;for(D in S=S||{},B=B||{})Object.prototype.hasOwnProperty.call(B,D)&&(Object.prototype.hasOwnProperty.call(S,D)||Je(D,U,M));for(D in S)Object.prototype.hasOwnProperty.call(S,D)&&(Object.prototype.hasOwnProperty.call(B,D)?Qe(B[D],S[D])||(B[D].type==="geojson"&&S[D].type==="geojson"&&ui(B,S,D)?Ee(U,{command:"setGeoJSONSourceData",args:[D,S[D].data]}):ze(D,S,U,M)):Ne(D,S,U))})(a.sources,e.sources,m,u);let w=[];a.layers&&a.layers.forEach(B=>{"source"in B&&u[B.source]?l.push({command:"removeLayer",args:[B.id]}):w.push(B)}),l=l.concat(m),function(B,S,U){S=S||[];let M=(B=B||[]).map(Ei),D=S.map(Ei),z=B.reduce(Pi,{}),et=S.reduce(Pi,{}),nt=M.slice(),st=Object.create(null),mt,St,Vt,se,Wt;for(let $t=0,be=0;$t@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(l,u,m,w)=>{let B=m||w;return e[u]=!B||B.toLowerCase(),""}),e["max-age"]){let l=parseInt(e["max-age"],10);isNaN(l)?delete e["max-age"]:e["max-age"]=l}return e},A.ab=function(a,e){let l=[];for(let u in a)u in e||l.push(u);return l},A.ac=at,A.ad=function(a,e,l){var u=Math.sin(l),m=Math.cos(l),w=e[0],B=e[1],S=e[2],U=e[3],M=e[4],D=e[5],z=e[6],et=e[7];return e!==a&&(a[8]=e[8],a[9]=e[9],a[10]=e[10],a[11]=e[11],a[12]=e[12],a[13]=e[13],a[14]=e[14],a[15]=e[15]),a[0]=w*m+M*u,a[1]=B*m+D*u,a[2]=S*m+z*u,a[3]=U*m+et*u,a[4]=M*m-w*u,a[5]=D*m-B*u,a[6]=z*m-S*u,a[7]=et*m-U*u,a},A.ae=function(a){var e=new Vl(16);return e[0]=a[0],e[1]=a[1],e[2]=a[2],e[3]=a[3],e[4]=a[4],e[5]=a[5],e[6]=a[6],e[7]=a[7],e[8]=a[8],e[9]=a[9],e[10]=a[10],e[11]=a[11],e[12]=a[12],e[13]=a[13],e[14]=a[14],e[15]=a[15],e},A.af=kc,A.ag=function(a,e){let l=0,u=0;if(a.kind==="constant")u=a.layoutSize;else if(a.kind!=="source"){let{interpolationType:m,minZoom:w,maxZoom:B}=a,S=m?at(cn.interpolationFactor(m,e,w,B),0,1):0;a.kind==="camera"?u=qn.number(a.minSize,a.maxSize,S):l=S}return{uSizeT:l,uSize:u}},A.ai=function(a,{uSize:e,uSizeT:l},{lowerSize:u,upperSize:m}){return a.kind==="source"?u/NA:a.kind==="composite"?qn.number(u/NA,m/NA,l):e},A.aj=Sm,A.ak=function(a,e,l,u){let m=e.y-a.y,w=e.x-a.x,B=u.y-l.y,S=u.x-l.x,U=B*w-S*m;if(U===0)return null;let M=(S*(a.y-l.y)-B*(a.x-l.x))/U;return new v(a.x+M*w,a.y+M*m)},A.al=D1,A.am=Ro,A.an=mh,A.ao=kn,A.aq=xm,A.ar=function(a,e){var l=e[0],u=e[1],m=e[2],w=e[3],B=e[4],S=e[5],U=e[6],M=e[7],D=e[8],z=e[9],et=e[10],nt=e[11],st=e[12],mt=e[13],St=e[14],Vt=e[15],se=l*S-u*B,Wt=l*U-m*B,$t=l*M-w*B,be=u*U-m*S,Le=u*M-w*S,ni=m*M-w*U,bi=D*mt-z*st,ri=D*St-et*st,ti=D*Vt-nt*st,Oe=z*St-et*mt,fi=z*Vt-nt*mt,qe=et*Vt-nt*St,Ze=se*qe-Wt*fi+$t*Oe+be*ti-Le*ri+ni*bi;return Ze?(a[0]=(S*qe-U*fi+M*Oe)*(Ze=1/Ze),a[1]=(m*fi-u*qe-w*Oe)*Ze,a[2]=(mt*ni-St*Le+Vt*be)*Ze,a[3]=(et*Le-z*ni-nt*be)*Ze,a[4]=(U*ti-B*qe-M*ri)*Ze,a[5]=(l*qe-m*ti+w*ri)*Ze,a[6]=(St*$t-st*ni-Vt*Wt)*Ze,a[7]=(D*ni-et*$t+nt*Wt)*Ze,a[8]=(B*fi-S*ti+M*bi)*Ze,a[9]=(u*ti-l*fi-w*bi)*Ze,a[10]=(st*Le-mt*$t+Vt*se)*Ze,a[11]=(z*$t-D*Le-nt*se)*Ze,a[12]=(S*ri-B*Oe-U*bi)*Ze,a[13]=(l*Oe-u*ri+m*bi)*Ze,a[14]=(mt*Wt-st*be-St*se)*Ze,a[15]=(D*be-z*Wt+et*se)*Ze,a):null},A.as=Gm,A.at=_m,A.au=Rm,A.av=function(){let a={},e=xt.$version;for(let l in xt.$root){let u=xt.$root[l];if(u.required){let m=null;m=l==="version"?e:u.type==="array"?[]:{},m!=null&&(a[l]=m)}}return a},A.aw=Ql,A.ax=Ae,A.ay=function(a){a=a.slice();let e=Object.create(null);for(let l=0;lZe*kn)}let ri=B?"center":l.get("text-justify").evaluate(M,{},a.canonical),ti=l.get("symbol-placement"),Oe=ti==="point"?l.get("text-max-width").evaluate(M,{},a.canonical)*kn:0,fi=()=>{a.bucket.allowVerticalPlacement&&Pa($t)&&(st.vertical=id(mt,a.glyphMap,a.glyphPositions,a.imagePositions,D,Oe,w,ni,"left",Le,Vt,A.ah.vertical,!0,ti,et,z))};if(!B&&bi){let qe=new Set;if(ri==="auto")for(let Gi=0;Gio(void 0,void 0,void 0,function*(){if(a.byteLength===0)return createImageBitmap(new ImageData(1,1));let e=new Blob([new Uint8Array(a)],{type:"image/png"});try{return createImageBitmap(e)}catch(l){throw new Error(`Could not load image because of ${l.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),A.e=Tt,A.f=a=>new Promise((e,l)=>{let u=new Image;u.onload=()=>{e(u),URL.revokeObjectURL(u.src),u.onload=null,window.requestAnimationFrame(()=>{u.src=ne})},u.onerror=()=>l(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."));let m=new Blob([new Uint8Array(a)],{type:"image/png"});u.src=a.byteLength?URL.createObjectURL(m):ne}),A.g=It,A.h=(a,e)=>he(Tt(a,{type:"json"}),e),A.i=_t,A.j=Me,A.k=je,A.l=(a,e)=>he(Tt(a,{type:"arrayBuffer"}),e),A.m=he,A.n=function(a){return new bm(a).readFields(US,[])},A.o=Zo,A.p=m1,A.q=Jn,A.r=en,A.s=de,A.t=ea,A.u=ei,A.v=xt,A.w=At,A.x=Fr,A.y=function([a,e,l]){return e+=90,e*=Math.PI/180,l*=Math.PI/180,{x:a*Math.cos(e)*Math.sin(l),y:a*Math.sin(e)*Math.sin(l),z:a*Math.cos(l)}},A.z=qn}),i("worker",["./shared"],function(A){"use strict";class o{constructor(Y){this.keyCache={},Y&&this.replace(Y)}replace(Y){this._layerConfigs={},this._layers={},this.update(Y,[])}update(Y,q){for(let ht of Y){this._layerConfigs[ht.id]=ht;let Zt=this._layers[ht.id]=A.az(ht);Zt._featureFilter=A.a6(Zt.filter),this.keyCache[ht.id]&&delete this.keyCache[ht.id]}for(let ht of q)delete this.keyCache[ht],delete this._layerConfigs[ht],delete this._layers[ht];this.familiesBySource={};let rt=A.bh(Object.values(this._layerConfigs),this.keyCache);for(let ht of rt){let Zt=ht.map(pe=>this._layers[pe.id]),zt=Zt[0];if(zt.visibility==="none")continue;let Xt=zt.source||"",Mt=this.familiesBySource[Xt];Mt||(Mt=this.familiesBySource[Xt]={});let re=zt.sourceLayer||"_geojsonTileLayer",ce=Mt[re];ce||(ce=Mt[re]=[]),ce.push(Zt)}}}class g{constructor(Y){let q={},rt=[];for(let Xt in Y){let Mt=Y[Xt],re=q[Xt]={};for(let ce in Mt){let pe=Mt[+ce];if(!pe||pe.bitmap.width===0||pe.bitmap.height===0)continue;let me={x:0,y:0,w:pe.bitmap.width+2,h:pe.bitmap.height+2};rt.push(me),re[ce]={rect:me,metrics:pe.metrics}}}let{w:ht,h:Zt}=A.p(rt),zt=new A.o({width:ht||1,height:Zt||1});for(let Xt in Y){let Mt=Y[Xt];for(let re in Mt){let ce=Mt[+re];if(!ce||ce.bitmap.width===0||ce.bitmap.height===0)continue;let pe=q[Xt][re].rect;A.o.copy(ce.bitmap,zt,{x:0,y:0},{x:pe.x+1,y:pe.y+1},ce.bitmap)}}this.image=zt,this.positions=q}}A.bi("GlyphAtlas",g);class d{constructor(Y){this.tileID=new A.Q(Y.tileID.overscaledZ,Y.tileID.wrap,Y.tileID.canonical.z,Y.tileID.canonical.x,Y.tileID.canonical.y),this.uid=Y.uid,this.zoom=Y.zoom,this.pixelRatio=Y.pixelRatio,this.tileSize=Y.tileSize,this.source=Y.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Y.showCollisionBoxes,this.collectResourceTiming=!!Y.collectResourceTiming,this.returnDependencies=!!Y.returnDependencies,this.promoteId=Y.promoteId,this.inFlightDependencies=[]}parse(Y,q,rt,ht){return A._(this,void 0,void 0,function*(){this.status="parsing",this.data=Y,this.collisionBoxArray=new A.a4;let Zt=new A.bj(Object.keys(Y.layers).sort()),zt=new A.bk(this.tileID,this.promoteId);zt.bucketLayerIDs=[];let Xt={},Mt={featureIndex:zt,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:rt},re=q.familiesBySource[this.source];for(let ki in re){let fr=Y.layers[ki];if(!fr)continue;fr.version===1&&A.w(`Vector tile source "${this.source}" layer "${ki}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let br=Zt.encode(ki),Er=[];for(let Dt=0;Dt=Ke.maxzoom||Ke.visibility!=="none"&&(C(Dt,this.zoom,rt),(Xt[Ke.id]=Ke.createBucket({index:zt.bucketLayerIDs.length,layers:Dt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:br,sourceID:this.source})).populate(Er,Mt,this.tileID.canonical),zt.bucketLayerIDs.push(Dt.map(Te=>Te.id)))}}let ce=A.aE(Mt.glyphDependencies,ki=>Object.keys(ki).map(Number));this.inFlightDependencies.forEach(ki=>ki?.abort()),this.inFlightDependencies=[];let pe=Promise.resolve({});if(Object.keys(ce).length){let ki=new AbortController;this.inFlightDependencies.push(ki),pe=ht.sendAsync({type:"getGlyphs",data:{stacks:ce,source:this.source,tileID:this.tileID,type:"glyphs"}},ki)}let me=Object.keys(Mt.iconDependencies),Xe=Promise.resolve({});if(me.length){let ki=new AbortController;this.inFlightDependencies.push(ki),Xe=ht.sendAsync({type:"getImages",data:{icons:me,source:this.source,tileID:this.tileID,type:"icons"}},ki)}let oi=Object.keys(Mt.patternDependencies),ii=Promise.resolve({});if(oi.length){let ki=new AbortController;this.inFlightDependencies.push(ki),ii=ht.sendAsync({type:"getImages",data:{icons:oi,source:this.source,tileID:this.tileID,type:"patterns"}},ki)}let[Ni,Ui,rr]=yield Promise.all([pe,Xe,ii]),zi=new g(Ni),Cr=new A.bl(Ui,rr);for(let ki in Xt){let fr=Xt[ki];fr instanceof A.a5?(C(fr.layers,this.zoom,rt),A.bm({bucket:fr,glyphMap:Ni,glyphPositions:zi.positions,imageMap:Ui,imagePositions:Cr.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):fr.hasPattern&&(fr instanceof A.bn||fr instanceof A.bo||fr instanceof A.bp)&&(C(fr.layers,this.zoom,rt),fr.addFeatures(Mt,this.tileID.canonical,Cr.patternPositions))}return this.status="done",{buckets:Object.values(Xt).filter(ki=>!ki.isEmpty()),featureIndex:zt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:zi.image,imageAtlas:Cr,glyphMap:this.returnDependencies?Ni:null,iconMap:this.returnDependencies?Ui:null,glyphPositions:this.returnDependencies?zi.positions:null}})}}function C(ft,Y,q){let rt=new A.a8(Y);for(let ht of ft)ht.recalculate(rt,q)}class v{constructor(Y,q,rt){this.actor=Y,this.layerIndex=q,this.availableImages=rt,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(Y,q){return A._(this,void 0,void 0,function*(){let rt=yield A.l(Y.request,q);try{return{vectorTile:new A.bq.VectorTile(new A.br(rt.data)),rawData:rt.data,cacheControl:rt.cacheControl,expires:rt.expires}}catch(ht){let Zt=new Uint8Array(rt.data),zt=`Unable to parse the tile at ${Y.request.url}, `;throw zt+=Zt[0]===31&&Zt[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${ht.messge}`,new Error(zt)}})}loadTile(Y){return A._(this,void 0,void 0,function*(){let q=Y.uid,rt=!!(Y&&Y.request&&Y.request.collectResourceTiming)&&new A.bs(Y.request),ht=new d(Y);this.loading[q]=ht;let Zt=new AbortController;ht.abort=Zt;try{let zt=yield this.loadVectorTile(Y,Zt);if(delete this.loading[q],!zt)return null;let Xt=zt.rawData,Mt={};zt.expires&&(Mt.expires=zt.expires),zt.cacheControl&&(Mt.cacheControl=zt.cacheControl);let re={};if(rt){let pe=rt.finish();pe&&(re.resourceTiming=JSON.parse(JSON.stringify(pe)))}ht.vectorTile=zt.vectorTile;let ce=ht.parse(zt.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[q]=ht,this.fetching[q]={rawTileData:Xt,cacheControl:Mt,resourceTiming:re};try{let pe=yield ce;return A.e({rawTileData:Xt.slice(0)},pe,Mt,re)}finally{delete this.fetching[q]}}catch(zt){throw delete this.loading[q],ht.status="done",this.loaded[q]=ht,zt}})}reloadTile(Y){return A._(this,void 0,void 0,function*(){let q=Y.uid;if(!this.loaded||!this.loaded[q])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");let rt=this.loaded[q];if(rt.showCollisionBoxes=Y.showCollisionBoxes,rt.status==="parsing"){let ht=yield rt.parse(rt.vectorTile,this.layerIndex,this.availableImages,this.actor),Zt;if(this.fetching[q]){let{rawTileData:zt,cacheControl:Xt,resourceTiming:Mt}=this.fetching[q];delete this.fetching[q],Zt=A.e({rawTileData:zt.slice(0)},ht,Xt,Mt)}else Zt=ht;return Zt}if(rt.status==="done"&&rt.vectorTile)return rt.parse(rt.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(Y){return A._(this,void 0,void 0,function*(){let q=this.loading,rt=Y.uid;q&&q[rt]&&q[rt].abort&&(q[rt].abort.abort(),delete q[rt])})}removeTile(Y){return A._(this,void 0,void 0,function*(){this.loaded&&this.loaded[Y.uid]&&delete this.loaded[Y.uid]})}}class x{constructor(){this.loaded={}}loadTile(Y){return A._(this,void 0,void 0,function*(){let{uid:q,encoding:rt,rawImageData:ht,redFactor:Zt,greenFactor:zt,blueFactor:Xt,baseShift:Mt}=Y,re=ht.width+2,ce=ht.height+2,pe=A.b(ht)?new A.R({width:re,height:ce},yield A.bt(ht,-1,-1,re,ce)):ht,me=new A.bu(q,pe,rt,Zt,zt,Xt,Mt);return this.loaded=this.loaded||{},this.loaded[q]=me,me})}removeTile(Y){let q=this.loaded,rt=Y.uid;q&&q[rt]&&delete q[rt]}}function T(ft,Y){if(ft.length!==0){G(ft[0],Y);for(var q=1;q=Math.abs(Xt)?q-Mt+Xt:Xt-Mt+q,q=Mt}q+rt>=0!=!!Y&&ft.reverse()}var k=A.bv(function ft(Y,q){var rt,ht=Y&&Y.type;if(ht==="FeatureCollection")for(rt=0;rt>31}function kt(ft,Y){for(var q=ft.loadGeometry(),rt=ft.type,ht=0,Zt=0,zt=q.length,Xt=0;Xtft},ne=Math.fround||(te=new Float32Array(1),ft=>(te[0]=+ft,te[0]));var te;let wt=3,Qt=5,fe=6;class j{constructor(Y){this.options=Object.assign(Object.create(ie),Y),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Y){let{log:q,minZoom:rt,maxZoom:ht}=this.options;q&&console.time("total time");let Zt=`prepare ${Y.length} points`;q&&console.time(Zt),this.points=Y;let zt=[];for(let Mt=0;Mt=rt;Mt--){let re=+Date.now();Xt=this.trees[Mt]=this._createTree(this._cluster(Xt,Mt)),q&&console.log("z%d: %d clusters in %dms",Mt,Xt.numItems,+Date.now()-re)}return q&&console.timeEnd("total time"),this}getClusters(Y,q){let rt=((Y[0]+180)%360+360)%360-180,ht=Math.max(-90,Math.min(90,Y[1])),Zt=Y[2]===180?180:((Y[2]+180)%360+360)%360-180,zt=Math.max(-90,Math.min(90,Y[3]));if(Y[2]-Y[0]>=360)rt=-180,Zt=180;else if(rt>Zt){let pe=this.getClusters([rt,ht,180,zt],q),me=this.getClusters([-180,ht,Zt,zt],q);return pe.concat(me)}let Xt=this.trees[this._limitZoom(q)],Mt=Xt.range(Ht(rt),Ot(zt),Ht(Zt),Ot(ht)),re=Xt.data,ce=[];for(let pe of Mt){let me=this.stride*pe;ce.push(re[me+Qt]>1?yt(re,me,this.clusterProps):this.points[re[me+wt]])}return ce}getChildren(Y){let q=this._getOriginId(Y),rt=this._getOriginZoom(Y),ht="No cluster with the specified id.",Zt=this.trees[rt];if(!Zt)throw new Error(ht);let zt=Zt.data;if(q*this.stride>=zt.length)throw new Error(ht);let Xt=this.options.radius/(this.options.extent*Math.pow(2,rt-1)),Mt=Zt.within(zt[q*this.stride],zt[q*this.stride+1],Xt),re=[];for(let ce of Mt){let pe=ce*this.stride;zt[pe+4]===Y&&re.push(zt[pe+Qt]>1?yt(zt,pe,this.clusterProps):this.points[zt[pe+wt]])}if(re.length===0)throw new Error(ht);return re}getLeaves(Y,q,rt){let ht=[];return this._appendLeaves(ht,Y,q=q||10,rt=rt||0,0),ht}getTile(Y,q,rt){let ht=this.trees[this._limitZoom(Y)],Zt=Math.pow(2,Y),{extent:zt,radius:Xt}=this.options,Mt=Xt/zt,re=(rt-Mt)/Zt,ce=(rt+1+Mt)/Zt,pe={features:[]};return this._addTileFeatures(ht.range((q-Mt)/Zt,re,(q+1+Mt)/Zt,ce),ht.data,q,rt,Zt,pe),q===0&&this._addTileFeatures(ht.range(1-Mt/Zt,re,1,ce),ht.data,Zt,rt,Zt,pe),q===Zt-1&&this._addTileFeatures(ht.range(0,re,Mt/Zt,ce),ht.data,-1,rt,Zt,pe),pe.features.length?pe:null}getClusterExpansionZoom(Y){let q=this._getOriginZoom(Y)-1;for(;q<=this.options.maxZoom;){let rt=this.getChildren(Y);if(q++,rt.length!==1)break;Y=rt[0].properties.cluster_id}return q}_appendLeaves(Y,q,rt,ht,Zt){let zt=this.getChildren(q);for(let Xt of zt){let Mt=Xt.properties;if(Mt&&Mt.cluster?Zt+Mt.point_count<=ht?Zt+=Mt.point_count:Zt=this._appendLeaves(Y,Mt.cluster_id,rt,ht,Zt):Zt1,ce,pe,me;if(re)ce=It(q,Mt,this.clusterProps),pe=q[Mt],me=q[Mt+1];else{let ii=this.points[q[Mt+wt]];ce=ii.properties;let[Ni,Ui]=ii.geometry.coordinates;pe=Ht(Ni),me=Ot(Ui)}let Xe={type:1,geometry:[[Math.round(this.options.extent*(pe*Zt-rt)),Math.round(this.options.extent*(me*Zt-ht))]],tags:ce},oi;oi=re||this.options.generateId?q[Mt+wt]:this.points[q[Mt+wt]].id,oi!==void 0&&(Xe.id=oi),zt.features.push(Xe)}}_limitZoom(Y){return Math.max(this.options.minZoom,Math.min(Math.floor(+Y),this.options.maxZoom+1))}_cluster(Y,q){let{radius:rt,extent:ht,reduce:Zt,minPoints:zt}=this.options,Xt=rt/(ht*Math.pow(2,q)),Mt=Y.data,re=[],ce=this.stride;for(let pe=0;peq&&(Ni+=Mt[rr+Qt])}if(Ni>ii&&Ni>=zt){let Ui,rr=me*ii,zi=Xe*ii,Cr=-1,ki=((pe/ce|0)<<5)+(q+1)+this.points.length;for(let fr of oi){let br=fr*ce;if(Mt[br+2]<=q)continue;Mt[br+2]=q;let Er=Mt[br+Qt];rr+=Mt[br]*Er,zi+=Mt[br+1]*Er,Mt[br+4]=ki,Zt&&(Ui||(Ui=this._map(Mt,pe,!0),Cr=this.clusterProps.length,this.clusterProps.push(Ui)),Zt(Ui,this._map(Mt,br)))}Mt[pe+4]=ki,re.push(rr/Ni,zi/Ni,1/0,ki,-1,Ni),Zt&&re.push(Cr)}else{for(let Ui=0;Ui1)for(let Ui of oi){let rr=Ui*ce;if(!(Mt[rr+2]<=q)){Mt[rr+2]=q;for(let zi=0;zi>5}_getOriginZoom(Y){return(Y-this.points.length)%32}_map(Y,q,rt){if(Y[q+Qt]>1){let zt=this.clusterProps[Y[q+fe]];return rt?Object.assign({},zt):zt}let ht=this.points[Y[q+wt]].properties,Zt=this.options.map(ht);return rt&&Zt===ht?Object.assign({},Zt):Zt}}function yt(ft,Y,q){return{type:"Feature",id:ft[Y+wt],properties:It(ft,Y,q),geometry:{type:"Point",coordinates:[(rt=ft[Y],360*(rt-.5)),Ae(ft[Y+1])]}};var rt}function It(ft,Y,q){let rt=ft[Y+Qt],ht=rt>=1e4?`${Math.round(rt/1e3)}k`:rt>=1e3?Math.round(rt/100)/10+"k":rt,Zt=ft[Y+fe],zt=Zt===-1?{}:Object.assign({},q[Zt]);return Object.assign(zt,{cluster:!0,cluster_id:ft[Y+wt],point_count:rt,point_count_abbreviated:ht})}function Ht(ft){return ft/360+.5}function Ot(ft){let Y=Math.sin(ft*Math.PI/180),q=.5-.25*Math.log((1+Y)/(1-Y))/Math.PI;return q<0?0:q>1?1:q}function Ae(ft){let Y=(180-360*ft)*Math.PI/180;return 360*Math.atan(Math.exp(Y))/Math.PI-90}function he(ft,Y,q,rt){for(var ht,Zt=rt,zt=q-Y>>1,Xt=q-Y,Mt=ft[Y],re=ft[Y+1],ce=ft[q],pe=ft[q+1],me=Y+3;meZt)ht=me,Zt=Xe;else if(Xe===Zt){var oi=Math.abs(me-zt);oirt&&(ht-Y>3&&he(ft,Y,ht,rt),ft[ht+2]=Zt,q-ht>3&&he(ft,ht,q,rt))}function de(ft,Y,q,rt,ht,Zt){var zt=ht-q,Xt=Zt-rt;if(zt!==0||Xt!==0){var Mt=((ft-q)*zt+(Y-rt)*Xt)/(zt*zt+Xt*Xt);Mt>1?(q=ht,rt=Zt):Mt>0&&(q+=zt*Mt,rt+=Xt*Mt)}return(zt=ft-q)*zt+(Xt=Y-rt)*Xt}function He(ft,Y,q,rt){var ht={id:ft===void 0?null:ft,type:Y,geometry:q,tags:rt,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Zt){var zt=Zt.geometry,Xt=Zt.type;if(Xt==="Point"||Xt==="MultiPoint"||Xt==="LineString")Ge(Zt,zt);else if(Xt==="Polygon"||Xt==="MultiLineString")for(var Mt=0;Mt0&&(zt+=rt?(ht*re-Mt*Zt)/2:Math.sqrt(Math.pow(Mt-ht,2)+Math.pow(re-Zt,2))),ht=Mt,Zt=re}var ce=Y.length-3;Y[2]=1,he(Y,0,ce,q),Y[ce+2]=1,Y.size=Math.abs(zt),Y.start=0,Y.end=Y.size}function xt(ft,Y,q,rt){for(var ht=0;ht1?1:q}function Qe(ft,Y,q,rt,ht,Zt,zt,Xt){if(rt/=Y,Zt>=(q/=Y)&&zt=rt)return null;for(var Mt=[],re=0;re=q&&oi=rt)){var ii=[];if(me==="Point"||me==="MultiPoint")Ee(pe,ii,q,rt,ht);else if(me==="LineString")Ne(pe,ii,q,rt,ht,!1,Xt.lineMetrics);else if(me==="MultiLineString")ze(pe,ii,q,rt,ht,!1);else if(me==="Polygon")ze(pe,ii,q,rt,ht,!0);else if(me==="MultiPolygon")for(var Ni=0;Ni=q&&zt<=rt&&(Y.push(ft[Zt]),Y.push(ft[Zt+1]),Y.push(ft[Zt+2]))}}function Ne(ft,Y,q,rt,ht,Zt,zt){for(var Xt,Mt,re=Je(ft),ce=ht===0?hi:Ei,pe=ft.start,me=0;meq&&(Mt=ce(re,Xe,oi,Ni,Ui,q),zt&&(re.start=pe+Xt*Mt)):rr>rt?zi=q&&(Mt=ce(re,Xe,oi,Ni,Ui,q),Cr=!0),zi>rt&&rr<=rt&&(Mt=ce(re,Xe,oi,Ni,Ui,rt),Cr=!0),!Zt&&Cr&&(zt&&(re.end=pe+Xt*Mt),Y.push(re),re=Je(ft)),zt&&(pe+=Xt)}var ki=ft.length-3;Xe=ft[ki],oi=ft[ki+1],ii=ft[ki+2],(rr=ht===0?Xe:oi)>=q&&rr<=rt&&ui(re,Xe,oi,ii),ki=re.length-3,Zt&&ki>=3&&(re[ki]!==re[0]||re[ki+1]!==re[1])&&ui(re,re[0],re[1],re[2]),re.length&&Y.push(re)}function Je(ft){var Y=[];return Y.size=ft.size,Y.start=ft.start,Y.end=ft.end,Y}function ze(ft,Y,q,rt,ht,Zt){for(var zt=0;ztzt.maxX&&(zt.maxX=ce),pe>zt.maxY&&(zt.maxY=pe)}return zt}function We(ft,Y,q,rt){var ht=Y.geometry,Zt=Y.type,zt=[];if(Zt==="Point"||Zt==="MultiPoint")for(var Xt=0;Xt0&&Y.size<(ht?zt:rt))q.numPoints+=Y.length/3;else{for(var Xt=[],Mt=0;Mtzt)&&(q.numSimplified++,Xt.push(Y[Mt]),Xt.push(Y[Mt+1])),q.numPoints++;ht&&function(re,ce){for(var pe=0,me=0,Xe=re.length,oi=Xe-2;me0===ce)for(me=0,Xe=re.length;me24)throw new Error("maxZoom should be in the 0-24 range");if(Y.promoteId&&Y.generateId)throw new Error("promoteId and generateId cannot be used together.");var rt=function(ht,Zt){var zt=[];if(ht.type==="FeatureCollection")for(var Xt=0;Xt1&&console.time("creation"),me=this.tiles[pe]=Vi(ft,Y,q,rt,Mt),this.tileCoords.push({z:Y,x:q,y:rt}),re)){re>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Y,q,rt,me.numFeatures,me.numPoints,me.numSimplified),console.timeEnd("creation"));var Xe="z"+Y;this.stats[Xe]=(this.stats[Xe]||0)+1,this.total++}if(me.source=ft,ht){if(Y===Mt.maxZoom||Y===ht)continue;var oi=1<1&&console.time("clipping");var ii,Ni,Ui,rr,zi,Cr,ki=.5*Mt.buffer/Mt.extent,fr=.5-ki,br=.5+ki,Er=1+ki;ii=Ni=Ui=rr=null,zi=Qe(ft,ce,q-ki,q+br,0,me.minX,me.maxX,Mt),Cr=Qe(ft,ce,q+fr,q+Er,0,me.minX,me.maxX,Mt),ft=null,zi&&(ii=Qe(zi,ce,rt-ki,rt+br,1,me.minY,me.maxY,Mt),Ni=Qe(zi,ce,rt+fr,rt+Er,1,me.minY,me.maxY,Mt),zi=null),Cr&&(Ui=Qe(Cr,ce,rt-ki,rt+br,1,me.minY,me.maxY,Mt),rr=Qe(Cr,ce,rt+fr,rt+Er,1,me.minY,me.maxY,Mt),Cr=null),re>1&&console.timeEnd("clipping"),Xt.push(ii||[],Y+1,2*q,2*rt),Xt.push(Ni||[],Y+1,2*q,2*rt+1),Xt.push(Ui||[],Y+1,2*q+1,2*rt),Xt.push(rr||[],Y+1,2*q+1,2*rt+1)}}},$e.prototype.getTile=function(ft,Y,q){var rt=this.options,ht=rt.extent,Zt=rt.debug;if(ft<0||ft>24)return null;var zt=1<1&&console.log("drilling down to z%d-%d-%d",ft,Y,q);for(var Mt,re=ft,ce=Y,pe=q;!Mt&&re>0;)re--,ce=Math.floor(ce/2),pe=Math.floor(pe/2),Mt=this.tiles[di(re,ce,pe)];return Mt&&Mt.source?(Zt>1&&console.log("found parent tile z%d-%d-%d",re,ce,pe),Zt>1&&console.time("drilling down"),this.splitTile(Mt.source,re,ce,pe,ft,Y,q),Zt>1&&console.timeEnd("drilling down"),this.tiles[Xt]?Oi(this.tiles[Xt],ht):null):null};class tr extends v{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(Y,q){return A._(this,void 0,void 0,function*(){let rt=Y.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");let ht=this._geoJSONIndex.getTile(rt.z,rt.x,rt.y);if(!ht)return null;let Zt=new class{constructor(Xt){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=A.W,this.length=Xt.length,this._features=Xt}feature(Xt){return new class{constructor(Mt){this._feature=Mt,this.extent=A.W,this.type=Mt.type,this.properties=Mt.tags,"id"in Mt&&!isNaN(Mt.id)&&(this.id=parseInt(Mt.id,10))}loadGeometry(){if(this._feature.type===1){let Mt=[];for(let re of this._feature.geometry)Mt.push([new A.P(re[0],re[1])]);return Mt}{let Mt=[];for(let re of this._feature.geometry){let ce=[];for(let pe of re)ce.push(new A.P(pe[0],pe[1]));Mt.push(ce)}return Mt}}toGeoJSON(Mt,re,ce){return W.call(this,Mt,re,ce)}}(this._features[Xt])}}(ht.features),zt=le(Zt);return zt.byteOffset===0&&zt.byteLength===zt.buffer.byteLength||(zt=new Uint8Array(zt)),{vectorTile:Zt,rawData:zt.buffer}})}loadData(Y){return A._(this,void 0,void 0,function*(){var q;(q=this._pendingRequest)===null||q===void 0||q.abort();let rt=!!(Y&&Y.request&&Y.request.collectResourceTiming)&&new A.bs(Y.request);this._pendingRequest=new AbortController;try{let ht=yield this.loadGeoJSON(Y,this._pendingRequest);if(delete this._pendingRequest,typeof ht!="object")throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`);if(k(ht,!0),Y.filter){let zt=A.by(Y.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(zt.result==="error")throw new Error(zt.value.map(Mt=>`${Mt.key}: ${Mt.message}`).join(", "));ht={type:"FeatureCollection",features:ht.features.filter(Mt=>zt.value.evaluate({zoom:0},Mt))}}this._geoJSONIndex=Y.cluster?new j(function({superclusterOptions:zt,clusterProperties:Xt}){if(!Xt||!zt)return zt;let Mt={},re={},ce={accumulated:null,zoom:0},pe={properties:null},me=Object.keys(Xt);for(let Xe of me){let[oi,ii]=Xt[Xe],Ni=A.by(ii),Ui=A.by(typeof oi=="string"?[oi,["accumulated"],["get",Xe]]:oi);Mt[Xe]=Ni.value,re[Xe]=Ui.value}return zt.map=Xe=>{pe.properties=Xe;let oi={};for(let ii of me)oi[ii]=Mt[ii].evaluate(ce,pe);return oi},zt.reduce=(Xe,oi)=>{pe.properties=oi;for(let ii of me)ce.accumulated=Xe[ii],Xe[ii]=re[ii].evaluate(ce,pe)},zt}(Y)).load(ht.features):function(zt,Xt){return new $e(zt,Xt)}(ht,Y.geojsonVtOptions),this.loaded={};let Zt={};if(rt){let zt=rt.finish();zt&&(Zt.resourceTiming={},Zt.resourceTiming[Y.source]=JSON.parse(JSON.stringify(zt)))}return Zt}catch(ht){if(delete this._pendingRequest,A.bz(ht))return{abandoned:!0};throw ht}})}reloadTile(Y){let q=this.loaded;return q&&q[Y.uid]?super.reloadTile(Y):this.loadTile(Y)}loadGeoJSON(Y,q){return A._(this,void 0,void 0,function*(){let{promoteId:rt}=Y;if(Y.request){let ht=yield A.h(Y.request,q);return this._dataUpdateable=qi(ht.data,rt)?vi(ht.data,rt):void 0,ht.data}if(typeof Y.data=="string")try{let ht=JSON.parse(Y.data);return this._dataUpdateable=qi(ht,rt)?vi(ht,rt):void 0,ht}catch{throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`)}if(!Y.dataDiff)throw new Error(`Input data given to '${Y.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${Y.source}`);return function(ht,Zt,zt){var Xt,Mt,re,ce;if(Zt.removeAll&&ht.clear(),Zt.remove)for(let pe of Zt.remove)ht.delete(pe);if(Zt.add)for(let pe of Zt.add){let me=Zi(pe,zt);me!=null&&ht.set(me,pe)}if(Zt.update)for(let pe of Zt.update){let me=ht.get(pe.id);if(me==null)continue;let Xe=!pe.removeAllProperties&&(((Xt=pe.removeProperties)===null||Xt===void 0?void 0:Xt.length)>0||((Mt=pe.addOrUpdateProperties)===null||Mt===void 0?void 0:Mt.length)>0);if((pe.newGeometry||pe.removeAllProperties||Xe)&&(me=Object.assign({},me),ht.set(pe.id,me),Xe&&(me.properties=Object.assign({},me.properties))),pe.newGeometry&&(me.geometry=pe.newGeometry),pe.removeAllProperties)me.properties={};else if(((re=pe.removeProperties)===null||re===void 0?void 0:re.length)>0)for(let oi of pe.removeProperties)Object.prototype.hasOwnProperty.call(me.properties,oi)&&delete me.properties[oi];if(((ce=pe.addOrUpdateProperties)===null||ce===void 0?void 0:ce.length)>0)for(let{key:oi,value:ii}of pe.addOrUpdateProperties)me.properties[oi]=ii}}(this._dataUpdateable,Y.dataDiff,rt),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(Y){return A._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(Y){return this._geoJSONIndex.getClusterExpansionZoom(Y.clusterId)}getClusterChildren(Y){return this._geoJSONIndex.getChildren(Y.clusterId)}getClusterLeaves(Y){return this._geoJSONIndex.getLeaves(Y.clusterId,Y.limit,Y.offset)}}class kr{constructor(Y){this.self=Y,this.actor=new A.C(Y),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(q,rt)=>{if(this.externalWorkerSourceTypes[q])throw new Error(`Worker source with name "${q}" already registered.`);this.externalWorkerSourceTypes[q]=rt},this.self.addProtocol=A.bf,this.self.removeProtocol=A.bg,this.self.registerRTLTextPlugin=q=>{if(A.bA.isParsed())throw new Error("RTL text plugin already registered.");A.bA.setMethods(q)},this.actor.registerMessageHandler("loadDEMTile",(q,rt)=>this._getDEMWorkerSource(q,rt.source).loadTile(rt)),this.actor.registerMessageHandler("removeDEMTile",(q,rt)=>A._(this,void 0,void 0,function*(){this._getDEMWorkerSource(q,rt.source).removeTile(rt)})),this.actor.registerMessageHandler("getClusterExpansionZoom",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterExpansionZoom(rt)})),this.actor.registerMessageHandler("getClusterChildren",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterChildren(rt)})),this.actor.registerMessageHandler("getClusterLeaves",(q,rt)=>A._(this,void 0,void 0,function*(){return this._getWorkerSource(q,rt.type,rt.source).getClusterLeaves(rt)})),this.actor.registerMessageHandler("loadData",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).loadData(rt)),this.actor.registerMessageHandler("loadTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).loadTile(rt)),this.actor.registerMessageHandler("reloadTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).reloadTile(rt)),this.actor.registerMessageHandler("abortTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).abortTile(rt)),this.actor.registerMessageHandler("removeTile",(q,rt)=>this._getWorkerSource(q,rt.type,rt.source).removeTile(rt)),this.actor.registerMessageHandler("removeSource",(q,rt)=>A._(this,void 0,void 0,function*(){if(!this.workerSources[q]||!this.workerSources[q][rt.type]||!this.workerSources[q][rt.type][rt.source])return;let ht=this.workerSources[q][rt.type][rt.source];delete this.workerSources[q][rt.type][rt.source],ht.removeSource!==void 0&&ht.removeSource(rt)})),this.actor.registerMessageHandler("removeMap",q=>A._(this,void 0,void 0,function*(){delete this.layerIndexes[q],delete this.availableImages[q],delete this.workerSources[q],delete this.demWorkerSources[q]})),this.actor.registerMessageHandler("setReferrer",(q,rt)=>A._(this,void 0,void 0,function*(){this.referrer=rt})),this.actor.registerMessageHandler("syncRTLPluginState",(q,rt)=>this._syncRTLPluginState(q,rt)),this.actor.registerMessageHandler("importScript",(q,rt)=>A._(this,void 0,void 0,function*(){this.self.importScripts(rt)})),this.actor.registerMessageHandler("setImages",(q,rt)=>this._setImages(q,rt)),this.actor.registerMessageHandler("updateLayers",(q,rt)=>A._(this,void 0,void 0,function*(){this._getLayerIndex(q).update(rt.layers,rt.removedIds)})),this.actor.registerMessageHandler("setLayers",(q,rt)=>A._(this,void 0,void 0,function*(){this._getLayerIndex(q).replace(rt)}))}_setImages(Y,q){return A._(this,void 0,void 0,function*(){this.availableImages[Y]=q;for(let rt in this.workerSources[Y]){let ht=this.workerSources[Y][rt];for(let Zt in ht)ht[Zt].availableImages=q}})}_syncRTLPluginState(Y,q){return A._(this,void 0,void 0,function*(){if(A.bA.isParsed())return A.bA.getState();if(q.pluginStatus!=="loading")return A.bA.setState(q),q;let rt=q.pluginURL;if(this.self.importScripts(rt),A.bA.isParsed()){let ht={pluginStatus:"loaded",pluginURL:rt};return A.bA.setState(ht),ht}throw A.bA.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${rt}`)})}_getAvailableImages(Y){let q=this.availableImages[Y];return q||(q=[]),q}_getLayerIndex(Y){let q=this.layerIndexes[Y];return q||(q=this.layerIndexes[Y]=new o),q}_getWorkerSource(Y,q,rt){if(this.workerSources[Y]||(this.workerSources[Y]={}),this.workerSources[Y][q]||(this.workerSources[Y][q]={}),!this.workerSources[Y][q][rt]){let ht={sendAsync:(Zt,zt)=>(Zt.targetMapId=Y,this.actor.sendAsync(Zt,zt))};switch(q){case"vector":this.workerSources[Y][q][rt]=new v(ht,this._getLayerIndex(Y),this._getAvailableImages(Y));break;case"geojson":this.workerSources[Y][q][rt]=new tr(ht,this._getLayerIndex(Y),this._getAvailableImages(Y));break;default:this.workerSources[Y][q][rt]=new this.externalWorkerSourceTypes[q](ht,this._getLayerIndex(Y),this._getAvailableImages(Y))}}return this.workerSources[Y][q][rt]}_getDEMWorkerSource(Y,q){return this.demWorkerSources[Y]||(this.demWorkerSources[Y]={}),this.demWorkerSources[Y][q]||(this.demWorkerSources[Y][q]=new x),this.demWorkerSources[Y][q]}}return A.i(self)&&(self.worker=new kr(self)),kr}),i("index",["exports","./shared"],function(A,o){"use strict";var g="4.1.2";let d,C,v={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:y=>new Promise((n,c)=>{let p=requestAnimationFrame(n);y.signal.addEventListener("abort",()=>{cancelAnimationFrame(p),c(o.c())})}),getImageData(y,n=0){return this.getImageCanvasContext(y).getImageData(-n,-n,y.width+2*n,y.height+2*n)},getImageCanvasContext(y){let n=window.document.createElement("canvas"),c=n.getContext("2d",{willReadFrequently:!0});if(!c)throw new Error("failed to create canvas 2d context");return n.width=y.width,n.height=y.height,c.drawImage(y,0,0,y.width,y.height),c},resolveURL:y=>(d||(d=document.createElement("a")),d.href=y,d.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(C==null&&(C=matchMedia("(prefers-reduced-motion: reduce)")),C.matches)}};class x{static testProp(n){if(!x.docStyle)return n[0];for(let c=0;c{window.removeEventListener("click",x.suppressClickInternal,!0)},0)}static getScale(n){let c=n.getBoundingClientRect();return{x:c.width/n.offsetWidth||1,y:c.height/n.offsetHeight||1,boundingClientRect:c}}static getPoint(n,c,p){let f=c.boundingClientRect;return new o.P((p.clientX-f.left)/c.x-n.clientLeft,(p.clientY-f.top)/c.y-n.clientTop)}static mousePos(n,c){let p=x.getScale(n);return x.getPoint(n,p,c)}static touchPos(n,c){let p=[],f=x.getScale(n);for(let b=0;b{n=[],c=0,p=0,f={}},y.addThrottleControl=H=>{let h=p++;return f[h]=H,h},y.removeThrottleControl=H=>{delete f[H],L()},y.getImage=(H,h,I=!0)=>new Promise((_,F)=>{T.supported&&(H.headers||(H.headers={}),H.headers.accept="image/webp,*/*"),o.e(H,{type:"image"}),n.push({abortController:h,requestParameters:H,supportImageRefresh:I,state:"queued",onError:R=>{F(R)},onSuccess:R=>{_(R)}}),L()});let b=H=>o._(this,void 0,void 0,function*(){H.state="running";let{requestParameters:h,supportImageRefresh:I,onError:_,onSuccess:F,abortController:R}=H,Z=I===!1&&!o.i(self)&&!o.g(h.url)&&(!h.headers||Object.keys(h.headers).reduce((V,X)=>V&&X==="accept",!0));c++;let N=Z?E(h,R):o.m(h,R);try{let V=yield N;delete H.abortController,H.state="completed",V.data instanceof HTMLImageElement||o.b(V.data)?F(V):V.data&&F({data:yield(P=V.data,typeof createImageBitmap=="function"?o.d(P):o.f(P)),cacheControl:V.cacheControl,expires:V.expires})}catch(V){delete H.abortController,_(V)}finally{c--,L()}var P}),L=()=>{let H=(()=>{for(let h of Object.keys(f))if(f[h]())return!0;return!1})()?o.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:o.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let h=c;h0;h++){let I=n.shift();I.abortController.signal.aborted?h--:b(I)}},E=(H,h)=>new Promise((I,_)=>{let F=new Image,R=H.url,Z=H.credentials;Z&&Z==="include"?F.crossOrigin="use-credentials":(Z&&Z==="same-origin"||!o.s(R))&&(F.crossOrigin="anonymous"),h.signal.addEventListener("abort",()=>{F.src="",_(o.c())}),F.fetchPriority="high",F.onload=()=>{F.onerror=F.onload=null,I({data:F})},F.onerror=()=>{F.onerror=F.onload=null,h.signal.aborted||_(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."))},F.src=R})}(O||(O={})),O.resetRequestQueue(),function(y){y.Glyphs="Glyphs",y.Image="Image",y.Source="Source",y.SpriteImage="SpriteImage",y.SpriteJSON="SpriteJSON",y.Style="Style",y.Tile="Tile",y.Unknown="Unknown"}(tt||(tt={}));class at{constructor(n){this._transformRequestFn=n}transformRequest(n,c){return this._transformRequestFn&&this._transformRequestFn(n,c)||{url:n}}normalizeSpriteURL(n,c,p){let f=function(b){let L=b.match(Lt);if(!L)throw new Error(`Unable to parse URL "${b}"`);return{protocol:L[1],authority:L[2],path:L[3]||"/",params:L[4]?L[4].split("&"):[]}}(n);return f.path+=`${c}${p}`,function(b){let L=b.params.length?`?${b.params.join("&")}`:"";return`${b.protocol}://${b.authority}${b.path}${L}`}(f)}setTransformRequest(n){this._transformRequestFn=n}}let Lt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Tt(y){var n=new o.A(3);return n[0]=y[0],n[1]=y[1],n[2]=y[2],n}var Ut,Ft=function(y,n,c){return y[0]=n[0]-c[0],y[1]=n[1]-c[1],y[2]=n[2]-c[2],y};Ut=new o.A(3),o.A!=Float32Array&&(Ut[0]=0,Ut[1]=0,Ut[2]=0);var vt=function(y){var n=y[0],c=y[1];return n*n+c*c};function Jt(y){let n=[];if(typeof y=="string")n.push({id:"default",url:y});else if(y&&y.length>0){let c=[];for(let{id:p,url:f}of y){let b=`${p}${f}`;c.indexOf(b)===-1&&(c.push(b),n.push({id:p,url:f}))}}return n}(function(){var y=new o.A(2);o.A!=Float32Array&&(y[0]=0,y[1]=0)})();class qt{constructor(n,c,p,f){this.context=n,this.format=p,this.texture=n.gl.createTexture(),this.update(c,f)}update(n,c,p){let{width:f,height:b}=n,L=!(this.size&&this.size[0]===f&&this.size[1]===b||p),{context:E}=this,{gl:H}=E;if(this.useMipmap=Boolean(c&&c.useMipmap),H.bindTexture(H.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===H.RGBA&&(!c||c.premultiply!==!1)),L)this.size=[f,b],n instanceof HTMLImageElement||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageData||o.b(n)?H.texImage2D(H.TEXTURE_2D,0,this.format,this.format,H.UNSIGNED_BYTE,n):H.texImage2D(H.TEXTURE_2D,0,this.format,f,b,0,this.format,H.UNSIGNED_BYTE,n.data);else{let{x:h,y:I}=p||{x:0,y:0};n instanceof HTMLImageElement||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageData||o.b(n)?H.texSubImage2D(H.TEXTURE_2D,0,h,I,H.RGBA,H.UNSIGNED_BYTE,n):H.texSubImage2D(H.TEXTURE_2D,0,h,I,f,b,H.RGBA,H.UNSIGNED_BYTE,n.data)}this.useMipmap&&this.isSizePowerOfTwo()&&H.generateMipmap(H.TEXTURE_2D)}bind(n,c,p){let{context:f}=this,{gl:b}=f;b.bindTexture(b.TEXTURE_2D,this.texture),p!==b.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(p=b.LINEAR),n!==this.filter&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,n),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,p||n),this.filter=n),c!==this.wrap&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,c),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,c),this.wrap=c)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}}function At(y){let{userImage:n}=y;return!!(n&&n.render&&n.render())&&(y.data.replace(new Uint8Array(n.data.buffer)),!0)}class lt extends o.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new o.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(n){if(this.loaded!==n&&(this.loaded=n,n)){for(let{ids:c,promiseResolve:p}of this.requestors)p(this._getImagesForIds(c));this.requestors=[]}}getImage(n){let c=this.images[n];if(c&&!c.data&&c.spriteData){let p=c.spriteData;c.data=new o.R({width:p.width,height:p.height},p.context.getImageData(p.x,p.y,p.width,p.height).data),c.spriteData=null}return c}addImage(n,c){if(this.images[n])throw new Error(`Image id ${n} already exist, use updateImage instead`);this._validate(n,c)&&(this.images[n]=c)}_validate(n,c){let p=!0,f=c.data||c.spriteData;return this._validateStretch(c.stretchX,f&&f.width)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "stretchX" value`))),p=!1),this._validateStretch(c.stretchY,f&&f.height)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "stretchY" value`))),p=!1),this._validateContent(c.content,c)||(this.fire(new o.j(new Error(`Image "${n}" has invalid "content" value`))),p=!1),p}_validateStretch(n,c){if(!n)return!0;let p=0;for(let f of n){if(f[0]{let f=!0;if(!this.isLoaded())for(let b of n)this.images[b]||(f=!1);this.isLoaded()||f?c(this._getImagesForIds(n)):this.requestors.push({ids:n,promiseResolve:c})})}_getImagesForIds(n){let c={};for(let p of n){let f=this.getImage(p);f||(this.fire(new o.k("styleimagemissing",{id:p})),f=this.getImage(p)),f?c[p]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:Boolean(f.userImage&&f.userImage.render)}:o.w(`Image "${p}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return c}getPixelSize(){let{width:n,height:c}=this.atlasImage;return{width:n,height:c}}getPattern(n){let c=this.patterns[n],p=this.getImage(n);if(!p)return null;if(c&&c.position.version===p.version)return c.position;if(c)c.position.version=p.version;else{let f={w:p.data.width+2,h:p.data.height+2,x:0,y:0},b=new o.I(f,p);this.patterns[n]={bin:f,position:b}}return this._updatePatternAtlas(),this.patterns[n].position}bind(n){let c=n.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new qt(n,this.atlasImage,c.RGBA),this.atlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(){let n=[];for(let b in this.patterns)n.push(this.patterns[b].bin);let{w:c,h:p}=o.p(n),f=this.atlasImage;f.resize({width:c||1,height:p||1});for(let b in this.patterns){let{bin:L}=this.patterns[b],E=L.x+1,H=L.y+1,h=this.getImage(b).data,I=h.width,_=h.height;o.R.copy(h,f,{x:0,y:0},{x:E,y:H},{width:I,height:_}),o.R.copy(h,f,{x:0,y:_-1},{x:E,y:H-1},{width:I,height:1}),o.R.copy(h,f,{x:0,y:0},{x:E,y:H+_},{width:I,height:1}),o.R.copy(h,f,{x:I-1,y:0},{x:E-1,y:H},{width:1,height:_}),o.R.copy(h,f,{x:0,y:0},{x:E+I,y:H},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(n){for(let c of n){if(this.callbackDispatchedThisFrame[c])continue;this.callbackDispatchedThisFrame[c]=!0;let p=this.getImage(c);p||o.w(`Image with ID: "${c}" was not found`),At(p)&&this.updateImage(c,p)}}}let kt=1e20;function _t(y,n,c,p,f,b,L,E,H){for(let h=n;h-1);H++,b[H]=E,L[H]=h,L[H+1]=kt}for(let E=0,H=0;E65535)throw new Error("glyphs > 65535 not supported");if(p.ranges[b])return{stack:n,id:c,glyph:f};if(!this.url)throw new Error("glyphsUrl is not set");if(!p.requests[b]){let E=ie.loadGlyphRange(n,b,this.url,this.requestManager);p.requests[b]=E}let L=yield p.requests[b];for(let E in L)this._doesCharSupportLocalGlyph(+E)||(p.glyphs[+E]=L[+E]);return p.ranges[b]=!0,{stack:n,id:c,glyph:L[c]||null}})}_doesCharSupportLocalGlyph(n){return!!this.localIdeographFontFamily&&(o.u["CJK Unified Ideographs"](n)||o.u["Hangul Syllables"](n)||o.u.Hiragana(n)||o.u.Katakana(n))}_tinySDF(n,c,p){let f=this.localIdeographFontFamily;if(!f||!this._doesCharSupportLocalGlyph(p))return;let b=n.tinySDF;if(!b){let E="400";/bold/i.test(c)?E="900":/medium/i.test(c)?E="500":/light/i.test(c)&&(E="200"),b=n.tinySDF=new ie.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:f,fontWeight:E})}let L=b.draw(String.fromCharCode(p));return{id:p,bitmap:new o.o({width:L.width||60,height:L.height||60},L.data),metrics:{width:L.glyphWidth/2||24,height:L.glyphHeight/2||24,left:L.glyphLeft/2+.5||0,top:L.glyphTop/2-27.5||-8,advance:L.glyphAdvance/2||24,isDoubleResolution:!0}}}}ie.loadGlyphRange=function(y,n,c,p){return o._(this,void 0,void 0,function*(){let f=256*n,b=f+255,L=p.transformRequest(c.replace("{fontstack}",y).replace("{range}",`${f}-${b}`),tt.Glyphs),E=yield o.l(L,new AbortController);if(!E||!E.data)throw new Error(`Could not load glyph range. range: ${n}, ${f}-${b}`);let H={};for(let h of o.n(E.data))H[h.id]=h;return H})},ie.TinySDF=class{constructor({fontSize:y=24,buffer:n=3,radius:c=8,cutoff:p=.25,fontFamily:f="sans-serif",fontWeight:b="normal",fontStyle:L="normal"}={}){this.buffer=n,this.cutoff=p,this.radius=c;let E=this.size=y+4*n,H=this._createCanvas(E),h=this.ctx=H.getContext("2d",{willReadFrequently:!0});h.font=`${L} ${b} ${y}px ${f}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(E*E),this.gridInner=new Float64Array(E*E),this.f=new Float64Array(E),this.z=new Float64Array(E+1),this.v=new Uint16Array(E)}_createCanvas(y){let n=document.createElement("canvas");return n.width=n.height=y,n}draw(y){let{width:n,actualBoundingBoxAscent:c,actualBoundingBoxDescent:p,actualBoundingBoxLeft:f,actualBoundingBoxRight:b}=this.ctx.measureText(y),L=Math.ceil(c),E=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(b-f))),H=Math.min(this.size-this.buffer,L+Math.ceil(p)),h=E+2*this.buffer,I=H+2*this.buffer,_=Math.max(h*I,0),F=new Uint8ClampedArray(_),R={data:F,width:h,height:I,glyphWidth:E,glyphHeight:H,glyphTop:L,glyphLeft:0,glyphAdvance:n};if(E===0||H===0)return R;let{ctx:Z,buffer:N,gridInner:P,gridOuter:V}=this;Z.clearRect(N,N,E,H),Z.fillText(y,N,N+L);let X=Z.getImageData(N,N,E,H);V.fill(kt,0,_),P.fill(0,0,_);for(let J=0;J0?Gt*Gt:0,P[ut]=Gt<0?Gt*Gt:0}}_t(V,0,0,h,I,h,this.f,this.v,this.z),_t(P,N,N,E,H,h,this.f,this.v,this.z);for(let J=0;J<_;J++){let ot=Math.sqrt(V[J])-Math.sqrt(P[J]);F[J]=Math.round(255-255*(ot/this.radius+this.cutoff))}return R}};class ne{constructor(){this.specification=o.v.light.position}possiblyEvaluate(n,c){return o.y(n.expression.evaluate(c))}interpolate(n,c,p){return{x:o.z.number(n.x,c.x,p),y:o.z.number(n.y,c.y,p),z:o.z.number(n.z,c.z,p)}}}let te;class wt extends o.E{constructor(n){super(),te=te||new o.q({anchor:new o.D(o.v.light.anchor),position:new ne,color:new o.D(o.v.light.color),intensity:new o.D(o.v.light.intensity)}),this._transitionable=new o.T(te),this.setLight(n),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(n,c={}){if(!this._validate(o.r,n,c))for(let p in n){let f=n[p];p.endsWith("-transition")?this._transitionable.setTransition(p.slice(0,-11),f):this._transitionable.setValue(p,f)}}updateTransitions(n){this._transitioning=this._transitionable.transitioned(n,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(n){this.properties=this._transitioning.possiblyEvaluate(n)}_validate(n,c,p){return(!p||p.validate!==!1)&&o.t(this,n.call(o.x,{value:c,style:{glyphs:!0,sprite:!0},styleSpec:o.v}))}}class Qt{constructor(n,c){this.width=n,this.height=c,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(n,c){let p=n.join(",")+String(c);return this.dashEntry[p]||(this.dashEntry[p]=this.addDash(n,c)),this.dashEntry[p]}getDashRanges(n,c,p){let f=[],b=n.length%2==1?-n[n.length-1]*p:0,L=n[0]*p,E=!0;f.push({left:b,right:L,isDash:E,zeroLength:n[0]===0});let H=n[0];for(let h=1;h1&&(H=n[++E]);let I=Math.abs(h-H.left),_=Math.abs(h-H.right),F=Math.min(I,_),R,Z=b/p*(f+1);if(H.isDash){let N=f-Math.abs(Z);R=Math.sqrt(F*F+N*N)}else R=f-Math.sqrt(F*F+Z*Z);this.data[L+h]=Math.max(0,Math.min(255,R+128))}}}addRegularDash(n){for(let E=n.length-1;E>=0;--E){let H=n[E],h=n[E+1];H.zeroLength?n.splice(E,1):h&&h.isDash===H.isDash&&(h.left=H.left,n.splice(E,1))}let c=n[0],p=n[n.length-1];c.isDash===p.isDash&&(c.left=p.left-this.width,p.right=c.right+this.width);let f=this.width*this.nextRow,b=0,L=n[b];for(let E=0;E1&&(L=n[++b]);let H=Math.abs(E-L.left),h=Math.abs(E-L.right),I=Math.min(H,h);this.data[f+E]=Math.max(0,Math.min(255,(L.isDash?I:-I)+128))}}addDash(n,c){let p=c?7:0,f=2*p+1;if(this.nextRow+f>this.height)return o.w("LineAtlas out of space"),null;let b=0;for(let E=0;E{c.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[fe]}numActive(){return Object.keys(this.active).length}}let yt=Math.floor(v.hardwareConcurrency/2),It,Ht;function Ot(){return It||(It=new j),It}j.workerCount=o.B(globalThis)?Math.max(Math.min(yt,3),1):1;class Ae{constructor(n,c){this.workerPool=n,this.actors=[],this.currentActor=0,this.id=c;let p=this.workerPool.acquire(c);for(let f=0;f{c.remove()}),this.actors=[],n&&this.workerPool.release(this.id)}registerMessageHandler(n,c){for(let p of this.actors)p.registerMessageHandler(n,c)}}function he(){return Ht||(Ht=new Ae(Ot(),o.G),Ht.registerMessageHandler("getResource",(y,n,c)=>o.m(n,c))),Ht}function de(y,n){let c=o.F();return o.H(c,c,[1,1,0]),o.J(c,c,[.5*y.width,.5*y.height,1]),o.K(c,c,y.calculatePosMatrix(n.toUnwrapped()))}function He(y,n,c,p,f,b){let L=function(_,F,R){if(_)for(let Z of _){let N=F[Z];if(N&&N.source===R&&N.type==="fill-extrusion")return!0}else for(let Z in F){let N=F[Z];if(N.source===R&&N.type==="fill-extrusion")return!0}return!1}(f&&f.layers,n,y.id),E=b.maxPitchScaleFactor(),H=y.tilesIn(p,E,L);H.sort(Ge);let h=[];for(let _ of H)h.push({wrappedTileID:_.tileID.wrapped().key,queryResults:_.tile.queryRenderedFeatures(n,c,y._state,_.queryGeometry,_.cameraQueryGeometry,_.scale,f,b,E,de(y.transform,_.tileID))});let I=function(_){let F={},R={};for(let Z of _){let N=Z.queryResults,P=Z.wrappedTileID,V=R[P]=R[P]||{};for(let X in N){let J=N[X],ot=V[X]=V[X]||{},pt=F[X]=F[X]||[];for(let ut of J)ot[ut.featureIndex]||(ot[ut.featureIndex]=!0,pt.push(ut))}}return F}(h);for(let _ in I)I[_].forEach(F=>{let R=F.feature,Z=y.getFeatureState(R.layer["source-layer"],R.id);R.source=R.layer.source,R.layer["source-layer"]&&(R.sourceLayer=R.layer["source-layer"]),R.state=Z});return I}function Ge(y,n){let c=y.tileID,p=n.tileID;return c.overscaledZ-p.overscaledZ||c.canonical.y-p.canonical.y||c.wrap-p.wrap||c.canonical.x-p.canonical.x}function je(y,n,c){return o._(this,void 0,void 0,function*(){let p=y;if(y.url?p=(yield o.h(n.transformRequest(y.url,tt.Source),c)).data:yield v.frameAsync(c),!p)return null;let f=o.L(o.e(p,y),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in p&&p.vector_layers&&(f.vectorLayerIds=p.vector_layers.map(b=>b.id)),f})}class Me{constructor(n,c){n&&(c?this.setSouthWest(n).setNorthEast(c):Array.isArray(n)&&(n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1])))}setNorthEast(n){return this._ne=n instanceof o.M?new o.M(n.lng,n.lat):o.M.convert(n),this}setSouthWest(n){return this._sw=n instanceof o.M?new o.M(n.lng,n.lat):o.M.convert(n),this}extend(n){let c=this._sw,p=this._ne,f,b;if(n instanceof o.M)f=n,b=n;else{if(!(n instanceof Me))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(Me.convert(n)):this.extend(o.M.convert(n)):n&&("lng"in n||"lon"in n)&&"lat"in n?this.extend(o.M.convert(n)):this;if(f=n._sw,b=n._ne,!f||!b)return this}return c||p?(c.lng=Math.min(f.lng,c.lng),c.lat=Math.min(f.lat,c.lat),p.lng=Math.max(b.lng,p.lng),p.lat=Math.max(b.lat,p.lat)):(this._sw=new o.M(f.lng,f.lat),this._ne=new o.M(b.lng,b.lat)),this}getCenter(){return new o.M((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 o.M(this.getWest(),this.getNorth())}getSouthEast(){return new o.M(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(n){let{lng:c,lat:p}=o.M.convert(n),f=this._sw.lng<=c&&c<=this._ne.lng;return this._sw.lng>this._ne.lng&&(f=this._sw.lng>=c&&c>=this._ne.lng),this._sw.lat<=p&&p<=this._ne.lat&&f}static convert(n){return n instanceof Me?n:n&&new Me(n)}static fromLngLat(n,c=0){let p=360*c/40075017,f=p/Math.cos(Math.PI/180*n.lat);return new Me(new o.M(n.lng-f,n.lat-p),new o.M(n.lng+f,n.lat+p))}}class gi{constructor(n,c,p){this.bounds=Me.convert(this.validateBounds(n)),this.minzoom=c||0,this.maxzoom=p||24}validateBounds(n){return Array.isArray(n)&&n.length===4?[Math.max(-180,n[0]),Math.max(-90,n[1]),Math.min(180,n[2]),Math.min(90,n[3])]:[-180,-90,180,90]}contains(n){let c=Math.pow(2,n.z),p=Math.floor(o.N(this.bounds.getWest())*c),f=Math.floor(o.O(this.bounds.getNorth())*c),b=Math.ceil(o.N(this.bounds.getEast())*c),L=Math.ceil(o.O(this.bounds.getSouth())*c);return n.x>=p&&n.x=f&&n.y{this._options.tiles=n}),this}setUrl(n){return this.setSourceProperty(()=>{this.url=n,this._options.url=n}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return o.e({},this._options)}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p={request:this.map._requestManager.transformRequest(c,tt.Tile),uid:n.uid,tileID:n.tileID,zoom:n.tileID.overscaledZ,tileSize:this.tileSize*n.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};p.request.collectResourceTiming=this._collectResourceTiming;let f="reloadTile";if(n.actor&&n.state!=="expired"){if(n.state==="loading")return new Promise((b,L)=>{n.reloadPromise={resolve:b,reject:L}})}else n.actor=this.dispatcher.getActor(),f="loadTile";n.abortController=new AbortController;try{let b=yield n.actor.sendAsync({type:f,data:p},n.abortController);if(delete n.abortController,n.aborted)return;this._afterTileLoadWorkerResponse(n,b)}catch(b){if(delete n.abortController,n.aborted)return;if(b&&b.status!==404)throw b;this._afterTileLoadWorkerResponse(n,null)}})}_afterTileLoadWorkerResponse(n,c){if(c&&c.resourceTiming&&(n.resourceTiming=c.resourceTiming),c&&this.map._refreshExpiredTiles&&n.setExpiryData(c),n.loadVectorData(c,this.map.painter),n.reloadPromise){let p=n.reloadPromise;n.reloadPromise=null,this.loadTile(n).then(p.resolve).catch(p.reject)}}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController),n.actor&&(yield n.actor.sendAsync({type:"abortTile",data:{uid:n.uid,type:this.type,source:this.id}}))})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.unloadVectorData(),n.actor&&(yield n.actor.sendAsync({type:"removeTile",data:{uid:n.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Rt extends o.E{constructor(n,c,p,f){super(),this.id=n,this.dispatcher=p,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=o.e({type:"raster"},c),o.e(this,o.L(c,["url","scheme","tileSize"]))}load(){return o._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let n=yield je(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(o.e(this,n),n.bounds&&(this.tileBounds=new gi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new o.k("data",{dataType:"source",sourceDataType:"content"})))}catch(n){this._tileJSONRequest=null,this.fire(new o.j(n))}})}loaded(){return this._loaded}onAdd(n){this.map=n,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(n){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),n(),this.load()}setTiles(n){return this.setSourceProperty(()=>{this._options.tiles=n}),this}setUrl(n){return this.setSourceProperty(()=>{this.url=n,this._options.url=n}),this}serialize(){return o.e({},this._options)}hasTile(n){return!this.tileBounds||this.tileBounds.contains(n.canonical)}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);n.abortController=new AbortController;try{let p=yield O.getImage(this.map._requestManager.transformRequest(c,tt.Tile),n.abortController,this.map._refreshExpiredTiles);if(delete n.abortController,n.aborted)return void(n.state="unloaded");if(p&&p.data){this.map._refreshExpiredTiles&&p.cacheControl&&p.expires&&n.setExpiryData({cacheControl:p.cacheControl,expires:p.expires});let f=this.map.painter.context,b=f.gl,L=p.data;n.texture=this.map.painter.getTileTexture(L.width),n.texture?n.texture.update(L,{useMipmap:!0}):(n.texture=new qt(f,L,b.RGBA,{useMipmap:!0}),n.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE,b.LINEAR_MIPMAP_NEAREST),f.extTextureFilterAnisotropic&&b.texParameterf(b.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax)),n.state="loaded"}}catch(p){if(delete n.abortController,n.aborted)n.state="unloaded";else if(p)throw n.state="errored",p}})}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController)})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.texture&&this.map.painter.saveTileTexture(n.texture)})}hasTransition(){return!1}}class Li extends Rt{constructor(n,c,p,f){super(n,c,p,f),this.type="raster-dem",this.maxzoom=22,this._options=o.e({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox",this.redFactor=c.redFactor,this.greenFactor=c.greenFactor,this.blueFactor=c.blueFactor,this.baseShift=c.baseShift}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),p=this.map._requestManager.transformRequest(c,tt.Tile);n.neighboringTiles=this._getNeighboringTiles(n.tileID),n.abortController=new AbortController;try{let f=yield O.getImage(p,n.abortController,this.map._refreshExpiredTiles);if(delete n.abortController,n.aborted)return void(n.state="unloaded");if(f&&f.data){let b=f.data;this.map._refreshExpiredTiles&&f.cacheControl&&f.expires&&n.setExpiryData({cacheControl:f.cacheControl,expires:f.expires});let L=o.b(b)&&o.S()?b:yield this.readImageNow(b),E={type:this.type,uid:n.uid,source:this.id,rawImageData:L,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!n.actor||n.state==="expired"){n.actor=this.dispatcher.getActor();let H=yield n.actor.sendAsync({type:"loadDEMTile",data:E});n.dem=H,n.needsHillshadePrepare=!0,n.needsTerrainPrepare=!0,n.state="loaded"}}}catch(f){if(delete n.abortController,n.aborted)n.state="unloaded";else if(f)throw n.state="errored",f}})}readImageNow(n){return o._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&o.U()){let c=n.width+2,p=n.height+2;try{return new o.R({width:c,height:p},yield o.V(n,-1,-1,c,p))}catch{}}return v.getImageData(n,1)})}_getNeighboringTiles(n){let c=n.canonical,p=Math.pow(2,c.z),f=(c.x-1+p)%p,b=c.x===0?n.wrap-1:n.wrap,L=(c.x+1+p)%p,E=c.x+1===p?n.wrap+1:n.wrap,H={};return H[new o.Q(n.overscaledZ,b,c.z,f,c.y).key]={backfilled:!1},H[new o.Q(n.overscaledZ,E,c.z,L,c.y).key]={backfilled:!1},c.y>0&&(H[new o.Q(n.overscaledZ,b,c.z,f,c.y-1).key]={backfilled:!1},H[new o.Q(n.overscaledZ,n.wrap,c.z,c.x,c.y-1).key]={backfilled:!1},H[new o.Q(n.overscaledZ,E,c.z,L,c.y-1).key]={backfilled:!1}),c.y+10&&o.e(b,{resourceTiming:f}),this.fire(new o.k("data",Object.assign(Object.assign({},b),{sourceDataType:"metadata"}))),this.fire(new o.k("data",Object.assign(Object.assign({},b),{sourceDataType:"content"})))}catch(p){if(this._pendingLoads--,this._removed)return void this.fire(new o.k("dataabort",{dataType:"source"}));this.fire(new o.j(p))}})}loaded(){return this._pendingLoads===0}loadTile(n){return o._(this,void 0,void 0,function*(){let c=n.actor?"reloadTile":"loadTile";n.actor=this.actor;let p={type:this.type,uid:n.uid,tileID:n.tileID,zoom:n.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};n.abortController=new AbortController;let f=yield this.actor.sendAsync({type:c,data:p},n.abortController);delete n.abortController,n.unloadVectorData(),n.aborted||n.loadVectorData(f,this.map.painter,c==="reloadTile")})}abortTile(n){return o._(this,void 0,void 0,function*(){n.abortController&&(n.abortController.abort(),delete n.abortController),n.aborted=!0})}unloadTile(n){return o._(this,void 0,void 0,function*(){n.unloadVectorData(),yield this.actor.sendAsync({type:"removeTile",data:{uid:n.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"removeSource",data:{type:this.type,source:this.id}})}serialize(){return o.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Ee=o.X([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ne extends o.E{constructor(n,c,p,f){super(),this.id=n,this.dispatcher=p,this.coordinates=c.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(f),this.options=c}load(n){return o._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new o.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{let c=yield O.getImage(this.map._requestManager.transformRequest(this.url,tt.Image),this._request);this._request=null,this._loaded=!0,c&&c.data&&(this.image=c.data,n&&(this.coordinates=n),this._finishLoading())}catch(c){this._request=null,this.fire(new o.j(c))}})}loaded(){return this._loaded}updateImage(n){return n.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=n.url,this.load(n.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new o.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(n){this.map=n,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(n){this.coordinates=n;let c=n.map(o.Y.fromLngLat);this.tileID=function(f){let b=1/0,L=1/0,E=-1/0,H=-1/0;for(let F of f)b=Math.min(b,F.x),L=Math.min(L,F.y),E=Math.max(E,F.x),H=Math.max(H,F.y);let h=Math.max(E-b,H-L),I=Math.max(0,Math.floor(-Math.log(h)/Math.LN2)),_=Math.pow(2,I);return new o.a0(I,Math.floor((b+E)/2*_),Math.floor((L+H)/2*_))}(c),this.minzoom=this.maxzoom=this.tileID.z;let p=c.map(f=>this.tileID.getTilePoint(f)._round());return this._boundsArray=new o.Z,this._boundsArray.emplaceBack(p[0].x,p[0].y,0,0),this._boundsArray.emplaceBack(p[1].x,p[1].y,o.W,0),this._boundsArray.emplaceBack(p[3].x,p[3].y,0,o.W),this._boundsArray.emplaceBack(p[2].x,p[2].y,o.W,o.W),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new o.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let n=this.map.painter.context,c=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture||(this.texture=new qt(n,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(let f in this.tiles){let b=this.tiles[f];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,p=!0)}p&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(n){return o._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(n.tileID.canonical)?(this.tiles[String(n.tileID.wrap)]=n,n.buckets={}):n.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Je extends Ne{constructor(n,c,p,f){super(n,c,p,f),this.roundZoom=!0,this.type="video",this.options=c}load(){return o._(this,void 0,void 0,function*(){this._loaded=!1;let n=this.options;this.urls=[];for(let c of n.urls)this.urls.push(this.map._requestManager.transformRequest(c,tt.Source).url);try{let c=yield o.a2(this.urls);if(this._loaded=!0,!c)return;this.video=c,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(c){this.fire(new o.j(c))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(n){if(this.video){let c=this.video.seekable;nc.end(0)?this.fire(new o.j(new o.a1(`sources.${this.id}`,null,`Playback for this video can be set only between the ${c.start(0)} and ${c.end(0)}-second mark.`))):this.video.currentTime=n}}getVideo(){return this.video}onAdd(n){this.map||(this.map=n,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let n=this.map.painter.context,c=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,this.video)):(this.texture=new qt(n,this.video,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let p=!1;for(let f in this.tiles){let b=this.tiles[f];b.state!=="loaded"&&(b.state="loaded",b.texture=this.texture,p=!0)}p&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ze extends Ne{constructor(n,c,p,f){super(n,c,p,f),c.coordinates?Array.isArray(c.coordinates)&&c.coordinates.length===4&&!c.coordinates.some(b=>!Array.isArray(b)||b.length!==2||b.some(L=>typeof L!="number"))||this.fire(new o.j(new o.a1(`sources.${n}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new o.j(new o.a1(`sources.${n}`,null,'missing required property "coordinates"'))),c.animate&&typeof c.animate!="boolean"&&this.fire(new o.j(new o.a1(`sources.${n}`,null,'optional "animate" property must be a boolean value'))),c.canvas?typeof c.canvas=="string"||c.canvas instanceof HTMLCanvasElement||this.fire(new o.j(new o.a1(`sources.${n}`,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 o.j(new o.a1(`sources.${n}`,null,'missing required property "canvas"'))),this.options=c,this.animate=c.animate===void 0||c.animate}load(){return o._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new o.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(n){this.map=n,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let n=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,n=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,n=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let c=this.map.painter.context,p=c.gl;this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,Ee.members)),this.boundsSegments||(this.boundsSegments=o.$.simpleSegment(0,0,4,2)),this.texture?(n||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new qt(c,this.canvas,p.RGBA,{premultiply:!0});let f=!1;for(let b in this.tiles){let L=this.tiles[b];L.state!=="loaded"&&(L.state="loaded",L.texture=this.texture,f=!0)}f&&this.fire(new o.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let n of[this.canvas.width,this.canvas.height])if(isNaN(n)||n<=0)return!0;return!1}}let ui={},hi=y=>{switch(y){case"geojson":return Qe;case"image":return Ne;case"raster":return Rt;case"raster-dem":return Li;case"vector":return xt;case"video":return Je;case"canvas":return ze}return ui[y]},Ei="RTLPluginLoaded";class Pi extends o.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=he()}_syncState(n){return this.status=n,this.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:n,pluginURL:this.url}).catch(c=>{throw this.status="error",c})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(n){return o._(this,arguments,void 0,function*(c,p=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=v.resolveURL(c),!this.url)throw new Error(`requested url ${c} is invalid`);if(this.status==="unavailable"){if(!p)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return o._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new o.k(Ei))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Ce=null;function Oi(){return Ce||(Ce=new Pi),Ce}class mi{constructor(n,c){this.timeAdded=0,this.fadeEndTime=0,this.tileID=n,this.uid=o.a3(),this.uses=0,this.tileSize=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(n){let c=n+this.timeAdded;cb.getLayer(h)).filter(Boolean);if(H.length!==0){E.layers=H,E.stateDependentLayerIds&&(E.stateDependentLayers=E.stateDependentLayerIds.map(h=>H.filter(I=>I.id===h)[0]));for(let h of H)L[h.id]=E}}return L}(n.buckets,c.style),this.hasSymbolBuckets=!1;for(let f in this.buckets){let b=this.buckets[f];if(b instanceof o.a5){if(this.hasSymbolBuckets=!0,!p)break;b.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let f in this.buckets){let b=this.buckets[f];if(b instanceof o.a5&&b.hasRTLText){this.hasRTLText=!0,Oi().lazyLoad();break}}this.queryPadding=0;for(let f in this.buckets){let b=this.buckets[f];this.queryPadding=Math.max(this.queryPadding,c.style.getLayer(f).queryRadius(b))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage)}else this.collisionBoxArray=new o.a4}unloadVectorData(){for(let n in this.buckets)this.buckets[n].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(n){return this.buckets[n.id]}upload(n){for(let p in this.buckets){let f=this.buckets[p];f.uploadPending()&&f.upload(n)}let c=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new qt(n,this.imageAtlas.image,c.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new qt(n,this.glyphAtlasImage,c.ALPHA),this.glyphAtlasImage=null)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,c,p,f,b,L,E,H,h,I){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:f,cameraQueryGeometry:b,scale:L,tileSize:this.tileSize,pixelPosMatrix:I,transform:H,params:E,queryPadding:this.queryPadding*h},n,c,p):{}}querySourceFeatures(n,c){let p=this.latestFeatureIndex;if(!p||!p.rawTileData)return;let f=p.loadVTLayers(),b=c&&c.sourceLayer?c.sourceLayer:"",L=f._geojsonTileLayer||f[b];if(!L)return;let E=o.a6(c&&c.filter),{z:H,x:h,y:I}=this.tileID.canonical,_={z:H,x:h,y:I};for(let F=0;Fp)f=!1;else if(c)if(this.expirationTime{this.remove(n,b)},p)),this.data[f].push(b),this.order.push(f),this.order.length>this.max){let L=this._getAndRemoveByKey(this.order[0]);L&&this.onRemove(L)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){let c=this.data[n].shift();return c.timeout&&clearTimeout(c.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),c.value}getByKey(n){let c=this.data[n];return c?c[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,c){if(!this.has(n))return this;let p=n.wrapped().key,f=c===void 0?0:this.data[p].indexOf(c),b=this.data[p][f];return this.data[p].splice(f,1),b.timeout&&clearTimeout(b.timeout),this.data[p].length===0&&delete this.data[p],this.onRemove(b.value),this.order.splice(this.order.indexOf(p),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){let c=this._getAndRemoveByKey(this.order[0]);c&&this.onRemove(c)}return this}filter(n){let c=[];for(let p in this.data)for(let f of this.data[p])n(f.value)||c.push(f);for(let p of c)this.remove(p.value.tileID,p)}}class We{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(n,c,p){let f=String(c);if(this.stateChanges[n]=this.stateChanges[n]||{},this.stateChanges[n][f]=this.stateChanges[n][f]||{},o.e(this.stateChanges[n][f],p),this.deletedStates[n]===null){this.deletedStates[n]={};for(let b in this.state[n])b!==f&&(this.deletedStates[n][b]=null)}else if(this.deletedStates[n]&&this.deletedStates[n][f]===null){this.deletedStates[n][f]={};for(let b in this.state[n][f])p[b]||(this.deletedStates[n][f][b]=null)}else for(let b in p)this.deletedStates[n]&&this.deletedStates[n][f]&&this.deletedStates[n][f][b]===null&&delete this.deletedStates[n][f][b]}removeFeatureState(n,c,p){if(this.deletedStates[n]===null)return;let f=String(c);if(this.deletedStates[n]=this.deletedStates[n]||{},p&&c!==void 0)this.deletedStates[n][f]!==null&&(this.deletedStates[n][f]=this.deletedStates[n][f]||{},this.deletedStates[n][f][p]=null);else if(c!==void 0)if(this.stateChanges[n]&&this.stateChanges[n][f])for(p in this.deletedStates[n][f]={},this.stateChanges[n][f])this.deletedStates[n][f][p]=null;else this.deletedStates[n][f]=null;else this.deletedStates[n]=null}getState(n,c){let p=String(c),f=o.e({},(this.state[n]||{})[p],(this.stateChanges[n]||{})[p]);if(this.deletedStates[n]===null)return{};if(this.deletedStates[n]){let b=this.deletedStates[n][c];if(b===null)return{};for(let L in b)delete f[L]}return f}initializeTileState(n,c){n.setFeatureState(this.state,c)}coalesceChanges(n,c){let p={};for(let f in this.stateChanges){this.state[f]=this.state[f]||{};let b={};for(let L in this.stateChanges[f])this.state[f][L]||(this.state[f][L]={}),o.e(this.state[f][L],this.stateChanges[f][L]),b[L]=this.state[f][L];p[f]=b}for(let f in this.deletedStates){this.state[f]=this.state[f]||{};let b={};if(this.deletedStates[f]===null)for(let L in this.state[f])b[L]={},this.state[f][L]={};else for(let L in this.deletedStates[f]){if(this.deletedStates[f][L]===null)this.state[f][L]={};else for(let E of Object.keys(this.deletedStates[f][L]))delete this.state[f][L][E];b[L]=this.state[f][L]}p[f]=p[f]||{},o.e(p[f],b)}if(this.stateChanges={},this.deletedStates={},Object.keys(p).length!==0)for(let f in n)n[f].setFeatureState(p,c)}}class Se extends o.E{constructor(n,c,p){super(),this.id=n,this.dispatcher=p,this.on("data",f=>{f.dataType==="source"&&f.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&f.dataType==="source"&&f.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((f,b,L,E)=>{let H=new(hi(b.type))(f,b,L,E);if(H.id!==f)throw new Error(`Expected Source id to be ${f} instead of ${H.id}`);return H})(n,c,p,this),this._tiles={},this._cache=new Vi(0,f=>this._unloadTile(f)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new We,this._didEmitContent=!1,this._updated=!1}onAdd(n){this.map=n,this._maxTileCacheSize=n?n._maxTileCacheSize:null,this._maxTileCacheZoomLevels=n?n._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(n)}onRemove(n){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(n)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let n in this._tiles){let c=this._tiles[n];if(c.state!=="loaded"&&c.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(n,c,p){return o._(this,void 0,void 0,function*(){try{yield this._source.loadTile(n),this._tileLoaded(n,c,p)}catch(f){n.state="errored",f.status!==404?this._source.fire(new o.j(f,{tile:n})):this.update(this.transform,this.terrain)}})}_unloadTile(n){this._source.unloadTile&&this._source.unloadTile(n)}_abortTile(n){this._source.abortTile&&this._source.abortTile(n),this._source.fire(new o.k("dataabort",{tile:n,coord:n.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(n){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let c in this._tiles){let p=this._tiles[c];p.upload(n),p.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(n=>n.tileID).sort($e).map(n=>n.key)}getRenderableIds(n){let c=[];for(let p in this._tiles)this._isIdRenderable(p,n)&&c.push(this._tiles[p]);return n?c.sort((p,f)=>{let b=p.tileID,L=f.tileID,E=new o.P(b.canonical.x,b.canonical.y)._rotate(this.transform.angle),H=new o.P(L.canonical.x,L.canonical.y)._rotate(this.transform.angle);return b.overscaledZ-L.overscaledZ||H.y-E.y||H.x-E.x}).map(p=>p.tileID.key):c.map(p=>p.tileID).sort($e).map(p=>p.key)}hasRenderableParent(n){let c=this.findLoadedParent(n,0);return!!c&&this._isIdRenderable(c.tileID.key)}_isIdRenderable(n,c){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(c||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(n,"reloading")}}_reloadTile(n,c){return o._(this,void 0,void 0,function*(){let p=this._tiles[n];p&&(p.state!=="loading"&&(p.state=c),yield this._loadTile(p,n,c))})}_tileLoaded(n,c,p){n.timeAdded=v.now(),p==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(c,n),this.getSource().type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),n.aborted||this._source.fire(new o.k("data",{dataType:"source",tile:n,coord:n.tileID}))}_backfillDEM(n){let c=this.getRenderableIds();for(let f=0;f1||(Math.abs(L)>1&&(Math.abs(L+H)===1?L+=H:Math.abs(L-H)===1&&(L-=H)),b.dem&&f.dem&&(f.dem.backfillBorder(b.dem,L,E),f.neighboringTiles&&f.neighboringTiles[h]&&(f.neighboringTiles[h].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,c,p,f){for(let b in this._tiles){let L=this._tiles[b];if(f[b]||!L.hasData()||L.tileID.overscaledZ<=c||L.tileID.overscaledZ>p)continue;let E=L.tileID;for(;L&&L.tileID.overscaledZ>c+1;){let h=L.tileID.scaledTo(L.tileID.overscaledZ-1);L=this._tiles[h.key],L&&L.hasData()&&(E=h)}let H=E;for(;H.overscaledZ>c;)if(H=H.scaledTo(H.overscaledZ-1),n[H.key]){f[E.key]=E;break}}}findLoadedParent(n,c){if(n.key in this._loadedParentTiles){let p=this._loadedParentTiles[n.key];return p&&p.tileID.overscaledZ>=c?p:null}for(let p=n.overscaledZ-1;p>=c;p--){let f=n.scaledTo(p),b=this._getLoadedTile(f);if(b)return b}}_getLoadedTile(n){let c=this._tiles[n.key];return c&&c.hasData()?c:this._cache.getByKey(n.wrapped().key)}updateCacheSize(n){let c=Math.ceil(n.width/this._source.tileSize)+1,p=Math.ceil(n.height/this._source.tileSize)+1,f=Math.floor(c*p*(this._maxTileCacheZoomLevels===null?o.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),b=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,f):f;this._cache.setMaxSize(b)}handleWrapJump(n){let c=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,c){let p={};for(let f in this._tiles){let b=this._tiles[f];b.tileID=b.tileID.unwrapTo(b.tileID.wrap+c),p[b.tileID.key]=b}this._tiles=p;for(let f in this._timers)clearTimeout(this._timers[f]),delete this._timers[f];for(let f in this._tiles)this._setTileReloadTimer(f,this._tiles[f])}}update(n,c){if(this.transform=n,this.terrain=c,!this._sourceLoaded||this._paused)return;let p;this.updateCacheSize(n),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?p=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(I=>new o.Q(I.canonical.z,I.wrap,I.canonical.z,I.canonical.x,I.canonical.y)):(p=n.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:c}),this._source.hasTile&&(p=p.filter(I=>this._source.hasTile(I)))):p=[];let f=n.coveringZoomLevel(this._source),b=Math.max(f-Se.maxOverzooming,this._source.minzoom),L=Math.max(f+Se.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let I={};for(let _ of p)if(_.canonical.z>this._source.minzoom){let F=_.scaledTo(_.canonical.z-1);I[F.key]=F;let R=_.scaledTo(Math.max(this._source.minzoom,Math.min(_.canonical.z,5)));I[R.key]=R}p=p.concat(Object.values(I))}let E=p.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,E&&this.fire(new o.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));let H=this._updateRetainedTiles(p,f);if(di(this._source.type)){let I={},_={},F=Object.keys(H),R=v.now();for(let Z of F){let N=H[Z],P=this._tiles[Z];if(!P||P.fadeEndTime!==0&&P.fadeEndTime<=R)continue;let V=this.findLoadedParent(N,b);V&&(this._addTile(V.tileID),I[V.tileID.key]=V.tileID),_[Z]=N}this._retainLoadedChildren(_,f,L,H);for(let Z in I)H[Z]||(this._coveredTiles[Z]=!0,H[Z]=I[Z]);if(c){let Z={},N={};for(let P of p)this._tiles[P.key].hasData()?Z[P.key]=P:N[P.key]=P;for(let P in N){let V=N[P].children(this._source.maxzoom);this._tiles[V[0].key]&&this._tiles[V[1].key]&&this._tiles[V[2].key]&&this._tiles[V[3].key]&&(Z[V[0].key]=H[V[0].key]=V[0],Z[V[1].key]=H[V[1].key]=V[1],Z[V[2].key]=H[V[2].key]=V[2],Z[V[3].key]=H[V[3].key]=V[3],delete N[P])}for(let P in N){let V=this.findLoadedParent(N[P],this._source.minzoom);if(V){Z[V.tileID.key]=H[V.tileID.key]=V.tileID;for(let X in Z)Z[X].isChildOf(V.tileID)&&delete Z[X]}}for(let P in this._tiles)Z[P]||(this._coveredTiles[P]=!0)}}for(let I in H)this._tiles[I].clearFadeHold();let h=o.ab(this._tiles,H);for(let I of h){let _=this._tiles[I];_.hasSymbolBuckets&&!_.holdingForFade()?_.setHoldDuration(this.map._fadeDuration):_.hasSymbolBuckets&&!_.symbolFadeFinished()||this._removeTile(I)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(let n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(n)}_updateRetainedTiles(n,c){let p={},f={},b=Math.max(c-Se.maxOverzooming,this._source.minzoom),L=Math.max(c+Se.maxUnderzooming,this._source.minzoom),E={};for(let H of n){let h=this._addTile(H);p[H.key]=H,h.hasData()||cthis._source.maxzoom){let _=H.children(this._source.maxzoom)[0],F=this.getTile(_);if(F&&F.hasData()){p[_.key]=_;continue}}else{let _=H.children(this._source.maxzoom);if(p[_[0].key]&&p[_[1].key]&&p[_[2].key]&&p[_[3].key])continue}let I=h.wasRequested();for(let _=H.overscaledZ-1;_>=b;--_){let F=H.scaledTo(_);if(f[F.key])break;if(f[F.key]=!0,h=this.getTile(F),!h&&I&&(h=this._addTile(F)),h){let R=h.hasData();if((I||R)&&(p[F.key]=F),I=h.wasRequested(),R)break}}}return p}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let n in this._tiles){let c=[],p,f=this._tiles[n].tileID;for(;f.overscaledZ>0;){if(f.key in this._loadedParentTiles){p=this._loadedParentTiles[f.key];break}c.push(f.key);let b=f.scaledTo(f.overscaledZ-1);if(p=this._getLoadedTile(b),p)break;f=b}for(let b of c)this._loadedParentTiles[b]=p}}_addTile(n){let c=this._tiles[n.key];if(c)return c;c=this._cache.getAndRemove(n),c&&(this._setTileReloadTimer(n.key,c),c.tileID=n,this._state.initializeTileState(c,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,c)));let p=c;return c||(c=new mi(n,this._source.tileSize*n.overscaleFactor()),this._loadTile(c,n.key,c.state)),c.uses++,this._tiles[n.key]=c,p||this._source.fire(new o.k("dataloading",{tile:c,coord:c.tileID,dataType:"source"})),c}_setTileReloadTimer(n,c){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);let p=c.getExpiryTimeout();p&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},p))}_removeTile(n){let c=this._tiles[n];c&&(c.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),c.uses>0||(c.hasData()&&c.state!=="reloading"?this._cache.add(c.tileID,c,c.getExpiryTimeout()):(c.aborted=!0,this._abortTile(c),this._unloadTile(c))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let n in this._tiles)this._removeTile(n);this._cache.reset()}tilesIn(n,c,p){let f=[],b=this.transform;if(!b)return f;let L=p?b.getCameraQueryGeometry(n):n,E=n.map(Z=>b.pointCoordinate(Z,this.terrain)),H=L.map(Z=>b.pointCoordinate(Z,this.terrain)),h=this.getIds(),I=1/0,_=1/0,F=-1/0,R=-1/0;for(let Z of H)I=Math.min(I,Z.x),_=Math.min(_,Z.y),F=Math.max(F,Z.x),R=Math.max(R,Z.y);for(let Z=0;Z=0&&J[1].y+X>=0){let ot=E.map(ut=>P.getTilePoint(ut)),pt=H.map(ut=>P.getTilePoint(ut));f.push({tile:N,tileID:P,queryGeometry:ot,cameraQueryGeometry:pt,scale:V})}}return f}getVisibleCoordinates(n){let c=this.getRenderableIds(n).map(p=>this._tiles[p].tileID);for(let p of c)p.posMatrix=this.transform.calculatePosMatrix(p.toUnwrapped());return c}hasTransition(){if(this._source.hasTransition())return!0;if(di(this._source.type)){let n=v.now();for(let c in this._tiles)if(this._tiles[c].fadeEndTime>=n)return!0}return!1}setFeatureState(n,c,p){this._state.updateState(n=n||"_geojsonTileLayer",c,p)}removeFeatureState(n,c,p){this._state.removeFeatureState(n=n||"_geojsonTileLayer",c,p)}getFeatureState(n,c){return this._state.getState(n=n||"_geojsonTileLayer",c)}setDependencies(n,c,p){let f=this._tiles[n];f&&f.setDependencies(c,p)}reloadTilesForDependencies(n,c){for(let p in this._tiles)this._tiles[p].hasDependency(n,c)&&this._reloadTile(p,"reloading");this._cache.filter(p=>!p.hasDependency(n,c))}}function $e(y,n){let c=Math.abs(2*y.wrap)-+(y.wrap<0),p=Math.abs(2*n.wrap)-+(n.wrap<0);return y.overscaledZ-n.overscaledZ||p-c||n.canonical.y-y.canonical.y||n.canonical.x-y.canonical.x}function di(y){return y==="raster"||y==="image"||y==="video"}Se.maxOverzooming=10,Se.maxUnderzooming=3;class Zi{constructor(n,c){this.reset(n,c)}reset(n,c){this.points=n||[],this._distances=[0];for(let p=1;p0?(f-L)/E:0;return this.points[b].mult(1-H).add(this.points[c].mult(H))}}function qi(y,n){let c=!0;return y==="always"||y!=="never"&&n!=="never"||(c=!1),c}class vi{constructor(n,c,p){let f=this.boxCells=[],b=this.circleCells=[];this.xCellCount=Math.ceil(n/p),this.yCellCount=Math.ceil(c/p);for(let L=0;Lthis.width||f<0||c>this.height)return[];let H=[];if(n<=0&&c<=0&&this.width<=p&&this.height<=f){if(b)return[{key:null,x1:n,y1:c,x2:p,y2:f}];for(let h=0;h0}hitTestCircle(n,c,p,f,b){let L=n-p,E=n+p,H=c-p,h=c+p;if(E<0||L>this.width||h<0||H>this.height)return!1;let I=[];return this._forEachCell(L,H,E,h,this._queryCellCircle,I,{hitTest:!0,overlapMode:f,circle:{x:n,y:c,radius:p},seenUids:{box:{},circle:{}}},b),I.length>0}_queryCell(n,c,p,f,b,L,E,H){let{seenUids:h,hitTest:I,overlapMode:_}=E,F=this.boxCells[b];if(F!==null){let Z=this.bboxes;for(let N of F)if(!h.box[N]){h.box[N]=!0;let P=4*N,V=this.boxKeys[N];if(n<=Z[P+2]&&c<=Z[P+3]&&p>=Z[P+0]&&f>=Z[P+1]&&(!H||H(V))&&(!I||!qi(_,V.overlapMode))&&(L.push({key:V,x1:Z[P],y1:Z[P+1],x2:Z[P+2],y2:Z[P+3]}),I))return!0}}let R=this.circleCells[b];if(R!==null){let Z=this.circles;for(let N of R)if(!h.circle[N]){h.circle[N]=!0;let P=3*N,V=this.circleKeys[N];if(this._circleAndRectCollide(Z[P],Z[P+1],Z[P+2],n,c,p,f)&&(!H||H(V))&&(!I||!qi(_,V.overlapMode))){let X=Z[P],J=Z[P+1],ot=Z[P+2];if(L.push({key:V,x1:X-ot,y1:J-ot,x2:X+ot,y2:J+ot}),I)return!0}}}return!1}_queryCellCircle(n,c,p,f,b,L,E,H){let{circle:h,seenUids:I,overlapMode:_}=E,F=this.boxCells[b];if(F!==null){let Z=this.bboxes;for(let N of F)if(!I.box[N]){I.box[N]=!0;let P=4*N,V=this.boxKeys[N];if(this._circleAndRectCollide(h.x,h.y,h.radius,Z[P+0],Z[P+1],Z[P+2],Z[P+3])&&(!H||H(V))&&!qi(_,V.overlapMode))return L.push(!0),!0}}let R=this.circleCells[b];if(R!==null){let Z=this.circles;for(let N of R)if(!I.circle[N]){I.circle[N]=!0;let P=3*N,V=this.circleKeys[N];if(this._circlesCollide(Z[P],Z[P+1],Z[P+2],h.x,h.y,h.radius)&&(!H||H(V))&&!qi(_,V.overlapMode))return L.push(!0),!0}}}_forEachCell(n,c,p,f,b,L,E,H){let h=this._convertToXCellCoord(n),I=this._convertToYCellCoord(c),_=this._convertToXCellCoord(p),F=this._convertToYCellCoord(f);for(let R=h;R<=_;R++)for(let Z=I;Z<=F;Z++)if(b.call(this,n,c,p,f,this.xCellCount*Z+R,L,E,H))return}_convertToXCellCoord(n){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(n*this.xScale)))}_convertToYCellCoord(n){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(n*this.yScale)))}_circlesCollide(n,c,p,f,b,L){let E=f-n,H=b-c,h=p+L;return h*h>E*E+H*H}_circleAndRectCollide(n,c,p,f,b,L,E){let H=(L-f)/2,h=Math.abs(n-(f+H));if(h>H+p)return!1;let I=(E-b)/2,_=Math.abs(c-(b+I));if(_>I+p)return!1;if(h<=H||_<=I)return!0;let F=h-H,R=_-I;return F*F+R*R<=p*p}}function tr(y,n,c,p,f){let b=o.F();return n?(o.J(b,b,[1/f,1/f,1]),c||o.ad(b,b,p.angle)):o.K(b,p.labelPlaneMatrix,y),b}function kr(y,n,c,p,f){if(n){let b=o.ae(y);return o.J(b,b,[f,f,1]),c||o.ad(b,b,-p.angle),b}return p.glCoordMatrix}function ft(y,n,c){let p;c?(p=[y.x,y.y,c(y.x,y.y),1],o.af(p,p,n)):(p=[y.x,y.y,0,1],oi(p,p,n));let f=p[3];return{point:new o.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f}}function Y(y,n){return .5+y/n*.5}function q(y,n){let c=y[0]/y[3],p=y[1]/y[3];return c>=-n[0]&&c<=n[0]&&p>=-n[1]&&p<=n[1]}function rt(y,n,c,p,f,b,L,E,H,h){let I=p?y.textSizeData:y.iconSizeData,_=o.ag(I,c.transform.zoom),F=[256/c.width*2+1,256/c.height*2+1],R=p?y.text.dynamicLayoutVertexArray:y.icon.dynamicLayoutVertexArray;R.clear();let Z=y.lineVertexArray,N=p?y.text.placedSymbolArray:y.icon.placedSymbolArray,P=c.transform.width/c.transform.height,V=!1;for(let X=0;XMath.abs(c.x-n.x)*p?{useVertical:!0}:(y===o.ah.vertical?n.yc.x)?{needsFlipping:!0}:null}function zt(y,n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N){let P=n/24,V=y.lineOffsetX*P,X=y.lineOffsetY*P,J;if(y.numGlyphs>1){let ot=y.glyphStartIndex+y.numGlyphs,pt=y.lineStartIndex,ut=y.lineStartIndex+y.lineLength,Gt=ht(P,E,V,X,c,I,_,y,H,b,F,Z,N);if(!Gt)return{notEnoughRoom:!0};let Pt=ft(Gt.first.point,L,N).point,dt=ft(Gt.last.point,L,N).point;if(p&&!c){let Ct=Zt(y.writingMode,Pt,dt,R);if(Ct)return Ct}J=[Gt.first];for(let Ct=y.glyphStartIndex+1;Ct0?Pt.point:Xt(_,Gt,pt,1,f,N),Ct=Zt(y.writingMode,pt,dt,R);if(Ct)return Ct}let ot=pe(P*E.getoffsetX(y.glyphStartIndex),V,X,c,I,_,y.segment,y.lineStartIndex,y.lineStartIndex+y.lineLength,H,b,F,Z,N);if(!ot)return{notEnoughRoom:!0};J=[ot]}for(let ot of J)o.aj(h,ot.point,ot.angle);return{}}function Xt(y,n,c,p,f,b){let L=ft(y.add(y.sub(n)._unit()),f,b).point,E=c.sub(L);return c.add(E._mult(p/E.mag()))}function Mt(y,n){let{projectionCache:c,lineVertexArray:p,labelPlaneMatrix:f,tileAnchorPoint:b,distanceFromAnchor:L,getElevation:E,previousVertex:H,direction:h,absOffsetX:I}=n;if(c.projections[y])return c.projections[y];let _=new o.P(p.getx(y),p.gety(y)),F=ft(_,f,E);if(F.signedDistanceFromCamera>0)return c.projections[y]=F.point,F.point;let R=y-h;return Xt(L===0?b:new o.P(p.getx(R),p.gety(R)),_,H,I-L+1,f,E)}function re(y,n,c){return y._unit()._perp()._mult(n*c)}function ce(y,n,c,p,f,b,L,E){let{projectionCache:H,direction:h}=E;if(H.offsets[y])return H.offsets[y];let I=c.add(n);if(y+h=f)return H.offsets[y]=I,I;let _=Mt(y+h,E),F=re(_.sub(c),L,h),R=c.add(F),Z=_.add(F);return H.offsets[y]=o.ak(b,I,R,Z)||I,H.offsets[y]}function pe(y,n,c,p,f,b,L,E,H,h,I,_,F,R){let Z=p?y-n:y+n,N=Z>0?1:-1,P=0;p&&(N*=-1,P=Math.PI),N<0&&(P+=Math.PI);let V,X,J=N>0?E+L:E+L+1,ot=f,pt=f,ut=0,Gt=0,Pt=Math.abs(Z),dt=[],Ct;for(;ut+Gt<=Pt;){if(J+=N,J=H)return null;ut+=Gt,pt=ot,X=V;let jt={projectionCache:_,lineVertexArray:h,labelPlaneMatrix:I,tileAnchorPoint:b,distanceFromAnchor:ut,getElevation:R,previousVertex:pt,direction:N,absOffsetX:Pt};if(ot=Mt(J,jt),c===0)dt.push(pt),Ct=ot.sub(pt);else{let Fe,ke=ot.sub(pt);Fe=ke.mag()===0?re(Mt(J+N,jt).sub(ot),c,N):re(ke,c,N),X||(X=pt.add(Fe)),V=ce(J,Fe,ot,E,H,X,c,jt),dt.push(X),Ct=V.sub(X)}Gt=Ct.mag()}let ee=Ct._mult((Pt-ut)/Gt)._add(X||pt),ge=P+Math.atan2(ot.y-pt.y,ot.x-pt.x);return dt.push(ee),{point:ee,angle:F?ge:0,path:dt}}let me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Xe(y,n){for(let c=0;c=1;ci--)ke.push(jt.path[ci]);for(let ci=1;cift(pi,H,Z));ke=ci.some(pi=>pi.signedDistanceFromCamera<=0)?[]:ci.map(pi=>pi.point)}let xe=[];if(ke.length>0){let ci=ke[0].clone(),pi=ke[0].clone();for(let Mi=1;Mi=Ct.x&&pi.x<=ee.x&&ci.y>=Ct.y&&pi.y<=ee.y?[ke]:pi.xee.x||pi.yee.y?[]:o.al([ke],Ct.x,Ct.y,ee.x,ee.y)}for(let ci of xe){ge.reset(ci,.25*dt);let pi=0;pi=ge.length<=.5*dt?1:Math.ceil(ge.paddedLength/Ye)+1;for(let Mi=0;Mi=this.screenRightBoundary||fthis.screenBottomBoundary}isInsideGrid(n,c,p,f){return p>=0&&n=0&&cp.collisionGroupID===c}}return this.collisionGroups[n]}}function Er(y,n,c,p,f){let{horizontalAlign:b,verticalAlign:L}=o.at(y);return new o.P(-(b-.5)*n+p[0]*f,-(L-.5)*c+p[1]*f)}function Dt(y,n,c,p,f,b){let{x1:L,x2:E,y1:H,y2:h,anchorPointX:I,anchorPointY:_}=y,F=new o.P(n,c);return p&&F._rotate(f?b:-b),{x1:L+F.x,y1:H+F.y,x2:E+F.x,y2:h+F.y,anchorPointX:I,anchorPointY:_}}class Ke{constructor(n,c,p,f,b){this.transform=n.clone(),this.terrain=c,this.collisionIndex=new Ni(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=p,this.retainedQueryData={},this.collisionGroups=new br(f),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(n,c,p,f){let b=p.getBucket(c),L=p.latestFeatureIndex;if(!b||!L||c.id!==b.layerIds[0])return;let E=p.collisionBoxArray,H=b.layers[0].layout,h=Math.pow(2,this.transform.zoom-p.tileID.overscaledZ),I=p.tileSize/o.W,_=this.transform.calculatePosMatrix(p.tileID.toUnwrapped()),F=H.get("text-pitch-alignment")==="map",R=H.get("text-rotation-alignment")==="map",Z=Ui(p,1,this.transform.zoom),N=tr(_,F,R,this.transform,Z),P=null;if(F){let X=kr(_,F,R,this.transform,Z);P=o.K([],this.transform.labelPlaneMatrix,X)}this.retainedQueryData[b.bucketInstanceId]=new fr(b.bucketInstanceId,L,b.sourceLayerIndex,b.index,p.tileID);let V={bucket:b,layout:H,posMatrix:_,textLabelPlaneMatrix:N,labelToScreenMatrix:P,scale:h,textPixelRatio:I,holdingForFade:p.holdingForFade(),collisionBoxArray:E,partiallyEvaluatedTextSize:o.ag(b.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(b.sourceID)};if(f)for(let X of b.sortKeyRanges){let{sortKey:J,symbolInstanceStart:ot,symbolInstanceEnd:pt}=X;n.push({sortKey:J,symbolInstanceStart:ot,symbolInstanceEnd:pt,parameters:V})}else n.push({symbolInstanceStart:0,symbolInstanceEnd:b.symbolInstances.length,parameters:V})}attemptAnchorPlacement(n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N,P){let V=o.ap[n.textAnchor],X=[n.textOffset0,n.textOffset1],J=Er(V,p,f,X,b),ot=this.collisionIndex.placeCollisionBox(Dt(c,J.x,J.y,L,E,this.transform.angle),_,H,h,I.predicate,P);if((!N||this.collisionIndex.placeCollisionBox(Dt(N,J.x,J.y,L,E,this.transform.angle),_,H,h,I.predicate,P).box.length!==0)&&ot.box.length>0){let pt;if(this.prevPlacement&&this.prevPlacement.variableOffsets[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID].text&&(pt=this.prevPlacement.variableOffsets[F.crossTileID].anchor),F.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[F.crossTileID]={textOffset:X,width:p,height:f,anchor:V,textBoxScale:b,prevAnchor:pt},this.markUsedJustification(R,V,F,Z),R.allowVerticalPlacement&&(this.markUsedOrientation(R,Z,F),this.placedOrientations[F.crossTileID]=Z),{shift:J,placedGlyphBoxes:ot}}}placeLayerBucketPart(n,c,p){let{bucket:f,layout:b,posMatrix:L,textLabelPlaneMatrix:E,labelToScreenMatrix:H,textPixelRatio:h,holdingForFade:I,collisionBoxArray:_,partiallyEvaluatedTextSize:F,collisionGroup:R}=n.parameters,Z=b.get("text-optional"),N=b.get("icon-optional"),P=o.aq(b,"text-overlap","text-allow-overlap"),V=P==="always",X=o.aq(b,"icon-overlap","icon-allow-overlap"),J=X==="always",ot=b.get("text-rotation-alignment")==="map",pt=b.get("text-pitch-alignment")==="map",ut=b.get("icon-text-fit")!=="none",Gt=b.get("symbol-z-order")==="viewport-y",Pt=V&&(J||!f.hasIconData()||N),dt=J&&(V||!f.hasTextData()||Z);!f.collisionArrays&&_&&f.deserializeCollisionBoxes(_);let Ct=this.retainedQueryData[f.bucketInstanceId].tileID,ee=this.terrain?(jt,Fe)=>this.terrain.getElevation(Ct,jt,Fe):null,ge=(jt,Fe)=>{var ke,Ye;if(c[jt.crossTileID])return;if(I)return void(this.placements[jt.crossTileID]=new Cr(!1,!1,!1));let xe=!1,ci=!1,pi=!0,Mi=null,Si={box:null,offscreen:null},cr={box:null,offscreen:null},ji=null,Ii=null,vr=null,Yr=0,Rr=0,mn=0;Fe.textFeatureIndex?Yr=Fe.textFeatureIndex:jt.useRuntimeCollisionCircles&&(Yr=jt.featureIndex),Fe.verticalTextFeatureIndex&&(Rr=Fe.verticalTextFeatureIndex);let wr=Fe.textBox;if(wr){let ur=_r=>{let Br=o.ah.horizontal;if(f.allowVerticalPlacement&&!_r&&this.prevPlacement){let pn=this.prevPlacement.placedOrientations[jt.crossTileID];pn&&(this.placedOrientations[jt.crossTileID]=pn,Br=pn,this.markUsedOrientation(f,Br,jt))}return Br},sr=(_r,Br)=>{if(f.allowVerticalPlacement&&jt.numVerticalGlyphVertices>0&&Fe.verticalTextBox){for(let pn of f.writingModes)if(pn===o.ah.vertical?(Si=Br(),cr=Si):Si=_r(),Si&&Si.box&&Si.box.length)break}else Si=_r()},Ir=jt.textAnchorOffsetStartIndex,Fn=jt.textAnchorOffsetEndIndex;if(Fn===Ir){let _r=(Br,pn)=>{let $i=this.collisionIndex.placeCollisionBox(Br,P,h,L,R.predicate,ee);return $i&&$i.box&&$i.box.length&&(this.markUsedOrientation(f,pn,jt),this.placedOrientations[jt.crossTileID]=pn),$i};sr(()=>_r(wr,o.ah.horizontal),()=>{let Br=Fe.verticalTextBox;return f.allowVerticalPlacement&&jt.numVerticalGlyphVertices>0&&Br?_r(Br,o.ah.vertical):{box:null,offscreen:null}}),ur(Si&&Si.box&&Si.box.length)}else{let _r=o.ap[(Ye=(ke=this.prevPlacement)===null||ke===void 0?void 0:ke.variableOffsets[jt.crossTileID])===null||Ye===void 0?void 0:Ye.anchor],Br=($i,ya,na)=>{let Mr=$i.x2-$i.x1,sa=$i.y2-$i.y1,dl=jt.textBoxScale,Nl=ut&&X==="never"?ya:null,Ro={box:[],offscreen:!1},EA=P==="never"?1:2,TA="never";_r&&EA++;for(let Ns=0;NsBr(wr,Fe.iconBox,o.ah.horizontal),()=>{let $i=Fe.verticalTextBox;return f.allowVerticalPlacement&&!(Si&&Si.box&&Si.box.length)&&jt.numVerticalGlyphVertices>0&&$i?Br($i,Fe.verticalIconBox,o.ah.vertical):{box:null,offscreen:null}}),Si&&(xe=Si.box,pi=Si.offscreen);let pn=ur(Si&&Si.box);if(!xe&&this.prevPlacement){let $i=this.prevPlacement.variableOffsets[jt.crossTileID];$i&&(this.variableOffsets[jt.crossTileID]=$i,this.markUsedJustification(f,$i.anchor,jt,pn))}}}if(ji=Si,xe=ji&&ji.box&&ji.box.length>0,pi=ji&&ji.offscreen,jt.useRuntimeCollisionCircles){let ur=f.text.placedSymbolArray.get(jt.centerJustifiedTextSymbolIndex),sr=o.ai(f.textSizeData,F,ur),Ir=b.get("text-padding");Ii=this.collisionIndex.placeCollisionCircles(P,ur,f.lineVertexArray,f.glyphOffsetArray,sr,L,E,H,p,pt,R.predicate,jt.collisionCircleDiameter,Ir,ee),Ii.circles.length&&Ii.collisionDetected&&!p&&o.w("Collisions detected, but collision boxes are not shown"),xe=V||Ii.circles.length>0&&!Ii.collisionDetected,pi=pi&&Ii.offscreen}if(Fe.iconFeatureIndex&&(mn=Fe.iconFeatureIndex),Fe.iconBox){let ur=sr=>{let Ir=ut&&Mi?Dt(sr,Mi.x,Mi.y,ot,pt,this.transform.angle):sr;return this.collisionIndex.placeCollisionBox(Ir,X,h,L,R.predicate,ee)};cr&&cr.box&&cr.box.length&&Fe.verticalIconBox?(vr=ur(Fe.verticalIconBox),ci=vr.box.length>0):(vr=ur(Fe.iconBox),ci=vr.box.length>0),pi=pi&&vr.offscreen}let An=Z||jt.numHorizontalGlyphVertices===0&&jt.numVerticalGlyphVertices===0,rn=N||jt.numIconVertices===0;if(An||rn?rn?An||(ci=ci&&xe):xe=ci&&xe:ci=xe=ci&&xe,xe&&ji&&ji.box&&this.collisionIndex.insertCollisionBox(ji.box,P,b.get("text-ignore-placement"),f.bucketInstanceId,cr&&cr.box&&Rr?Rr:Yr,R.ID),ci&&vr&&this.collisionIndex.insertCollisionBox(vr.box,X,b.get("icon-ignore-placement"),f.bucketInstanceId,mn,R.ID),Ii&&(xe&&this.collisionIndex.insertCollisionCircles(Ii.circles,P,b.get("text-ignore-placement"),f.bucketInstanceId,Yr,R.ID),p)){let ur=f.bucketInstanceId,sr=this.collisionCircleArrays[ur];sr===void 0&&(sr=this.collisionCircleArrays[ur]=new ki);for(let Ir=0;Ir=0;--Fe){let ke=jt[Fe];ge(f.symbolInstances.get(ke),f.collisionArrays[ke])}}else for(let jt=n.symbolInstanceStart;jt=0&&(n.text.placedSymbolArray.get(E).crossTileID=b>=0&&E!==b?0:p.crossTileID)}markUsedOrientation(n,c,p){let f=c===o.ah.horizontal||c===o.ah.horizontalOnly?c:0,b=c===o.ah.vertical?c:0,L=[p.leftJustifiedTextSymbolIndex,p.centerJustifiedTextSymbolIndex,p.rightJustifiedTextSymbolIndex];for(let E of L)n.text.placedSymbolArray.get(E).placedOrientation=f;p.verticalPlacedTextSymbolIndex&&(n.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).placedOrientation=b)}commit(n){this.commitTime=n,this.zoomAtLastRecencyCheck=this.transform.zoom;let c=this.prevPlacement,p=!1;this.prevZoomAdjustment=c?c.zoomAdjustment(this.transform.zoom):0;let f=c?c.symbolFadeChange(n):1,b=c?c.opacities:{},L=c?c.variableOffsets:{},E=c?c.placedOrientations:{};for(let H in this.placements){let h=this.placements[H],I=b[H];I?(this.opacities[H]=new zi(I,f,h.text,h.icon),p=p||h.text!==I.text.placed||h.icon!==I.icon.placed):(this.opacities[H]=new zi(null,f,h.text,h.icon,h.skipFade),p=p||h.text||h.icon)}for(let H in b){let h=b[H];if(!this.opacities[H]){let I=new zi(h,f,!1,!1);I.isHidden()||(this.opacities[H]=I,p=p||h.text.placed||h.icon.placed)}}for(let H in L)this.variableOffsets[H]||!this.opacities[H]||this.opacities[H].isHidden()||(this.variableOffsets[H]=L[H]);for(let H in E)this.placedOrientations[H]||!this.opacities[H]||this.opacities[H].isHidden()||(this.placedOrientations[H]=E[H]);if(c&&c.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");p?this.lastPlacementChangeTime=n:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=c?c.lastPlacementChangeTime:n)}updateLayerOpacities(n,c){let p={};for(let f of c){let b=f.getBucket(n);b&&f.latestFeatureIndex&&n.id===b.layerIds[0]&&this.updateBucketOpacities(b,p,f.collisionBoxArray)}}updateBucketOpacities(n,c,p){n.hasTextData()&&(n.text.opacityVertexArray.clear(),n.text.hasVisibleVertices=!1),n.hasIconData()&&(n.icon.opacityVertexArray.clear(),n.icon.hasVisibleVertices=!1),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexArray.clear(),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexArray.clear();let f=n.layers[0],b=f.layout,L=new zi(null,0,!1,!1,!0),E=b.get("text-allow-overlap"),H=b.get("icon-allow-overlap"),h=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),I=b.get("text-rotation-alignment")==="map",_=b.get("text-pitch-alignment")==="map",F=b.get("icon-text-fit")!=="none",R=new zi(null,0,E&&(H||!n.hasIconData()||b.get("icon-optional")),H&&(E||!n.hasTextData()||b.get("text-optional")),!0);!n.collisionArrays&&p&&(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData())&&n.deserializeCollisionBoxes(p);let Z=(N,P,V)=>{for(let X=0;X

0,ut=this.placedOrientations[P.crossTileID],Gt=ut===o.ah.vertical,Pt=ut===o.ah.horizontal||ut===o.ah.horizontalOnly;if(V>0||X>0){let dt=Wo(ot.text);Z(n.text,V,Gt?an:dt),Z(n.text,X,Pt?an:dt);let Ct=ot.text.isHidden();[P.rightJustifiedTextSymbolIndex,P.centerJustifiedTextSymbolIndex,P.leftJustifiedTextSymbolIndex].forEach(jt=>{jt>=0&&(n.text.placedSymbolArray.get(jt).hidden=Ct||Gt?1:0)}),P.verticalPlacedTextSymbolIndex>=0&&(n.text.placedSymbolArray.get(P.verticalPlacedTextSymbolIndex).hidden=Ct||Pt?1:0);let ee=this.variableOffsets[P.crossTileID];ee&&this.markUsedJustification(n,ee.anchor,P,ut);let ge=this.placedOrientations[P.crossTileID];ge&&(this.markUsedJustification(n,"left",P,ge),this.markUsedOrientation(n,ge,P))}if(pt){let dt=Wo(ot.icon),Ct=!(F&&P.verticalPlacedIconSymbolIndex&&Gt);P.placedIconSymbolIndex>=0&&(Z(n.icon,P.numIconVertices,Ct?dt:an),n.icon.placedSymbolArray.get(P.placedIconSymbolIndex).hidden=ot.icon.isHidden()),P.verticalPlacedIconSymbolIndex>=0&&(Z(n.icon,P.numVerticalIconVertices,Ct?an:dt),n.icon.placedSymbolArray.get(P.verticalPlacedIconSymbolIndex).hidden=ot.icon.isHidden())}if(n.hasIconCollisionBoxData()||n.hasTextCollisionBoxData()){let dt=n.collisionArrays[N];if(dt){let Ct=new o.P(0,0);if(dt.textBox||dt.verticalTextBox){let ge=!0;if(h){let jt=this.variableOffsets[J];jt?(Ct=Er(jt.anchor,jt.width,jt.height,jt.textOffset,jt.textBoxScale),I&&Ct._rotate(_?this.transform.angle:-this.transform.angle)):ge=!1}dt.textBox&&Te(n.textCollisionBox.collisionVertexArray,ot.text.placed,!ge||Gt,Ct.x,Ct.y),dt.verticalTextBox&&Te(n.textCollisionBox.collisionVertexArray,ot.text.placed,!ge||Pt,Ct.x,Ct.y)}let ee=Boolean(!Pt&&dt.verticalIconBox);dt.iconBox&&Te(n.iconCollisionBox.collisionVertexArray,ot.icon.placed,ee,F?Ct.x:0,F?Ct.y:0),dt.verticalIconBox&&Te(n.iconCollisionBox.collisionVertexArray,ot.icon.placed,!ee,F?Ct.x:0,F?Ct.y:0)}}}if(n.sortFeatures(this.transform.angle),this.retainedQueryData[n.bucketInstanceId]&&(this.retainedQueryData[n.bucketInstanceId].featureSortOrder=n.featureSortOrder),n.hasTextData()&&n.text.opacityVertexBuffer&&n.text.opacityVertexBuffer.updateData(n.text.opacityVertexArray),n.hasIconData()&&n.icon.opacityVertexBuffer&&n.icon.opacityVertexBuffer.updateData(n.icon.opacityVertexArray),n.hasIconCollisionBoxData()&&n.iconCollisionBox.collisionVertexBuffer&&n.iconCollisionBox.collisionVertexBuffer.updateData(n.iconCollisionBox.collisionVertexArray),n.hasTextCollisionBoxData()&&n.textCollisionBox.collisionVertexBuffer&&n.textCollisionBox.collisionVertexBuffer.updateData(n.textCollisionBox.collisionVertexArray),n.text.opacityVertexArray.length!==n.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${n.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${n.text.layoutVertexArray.length}) / 4`);if(n.icon.opacityVertexArray.length!==n.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${n.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${n.icon.layoutVertexArray.length}) / 4`);if(n.bucketInstanceId in this.collisionCircleArrays){let N=this.collisionCircleArrays[n.bucketInstanceId];n.placementInvProjMatrix=N.invProjMatrix,n.placementViewportMatrix=N.viewportMatrix,n.collisionCircleArray=N.circles,delete this.collisionCircleArrays[n.bucketInstanceId]}}symbolFadeChange(n){return this.fadeDuration===0?1:(n-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(n){return Math.max(0,(this.transform.zoom-n)/1.5)}hasTransitions(n){return this.stale||n-this.lastPlacementChangeTimen}setStale(){this.stale=!0}}function Te(y,n,c,p,f){y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0),y.emplaceBack(n?1:0,c?1:0,p||0,f||0)}let or=Math.pow(2,25),Lr=Math.pow(2,24),Ji=Math.pow(2,17),Zr=Math.pow(2,16),bs=Math.pow(2,9),Sr=Math.pow(2,8),xr=Math.pow(2,1);function Wo(y){if(y.opacity===0&&!y.placed)return 0;if(y.opacity===1&&y.placed)return 4294967295;let n=y.placed?1:0,c=Math.floor(127*y.opacity);return c*or+n*Lr+c*Ji+n*Zr+c*bs+n*Sr+c*xr+n}let an=0;class Kn{constructor(n){this._sortAcrossTiles=n.layout.get("symbol-z-order")!=="viewport-y"&&!n.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(n,c,p,f,b){let L=this._bucketParts;for(;this._currentTileIndexE.sortKey-H.sortKey));this._currentPartIndex!this._forceFullPlacement&&v.now()-f>2;for(;this._currentPlacementIndex>=0;){let L=c[n[this._currentPlacementIndex]],E=this.placement.collisionIndex.transform.zoom;if(L.type==="symbol"&&(!L.minzoom||L.minzoom<=E)&&(!L.maxzoom||L.maxzoom>E)){if(this._inProgressLayer||(this._inProgressLayer=new Kn(L)),this._inProgressLayer.continuePlacement(p[L.source],this.placement,this._showCollisionBoxes,L,b))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(n){return this.placement.commit(n),this.placement}}let Gs=512/o.W/2;class Tr{constructor(n,c,p){this.tileID=n,this.bucketInstanceId=p,this._symbolsByKey={};let f=new Map;for(let b=0;b({x:Math.floor(H.anchorX*Gs),y:Math.floor(H.anchorY*Gs)})),crossTileIDs:L.map(H=>H.crossTileID)};if(E.positions.length>128){let H=new o.au(E.positions.length,16,Uint16Array);for(let{x:h,y:I}of E.positions)H.add(h,I);H.finish(),delete E.positions,E.index=H}this._symbolsByKey[b]=E}}getScaledCoordinates(n,c){let{x:p,y:f,z:b}=this.tileID.canonical,{x:L,y:E,z:H}=c.canonical,h=Gs/Math.pow(2,H-b),I=(E*o.W+n.anchorY)*h,_=f*o.W*Gs;return{x:Math.floor((L*o.W+n.anchorX)*h-p*o.W*Gs),y:Math.floor(I-_)}}findMatches(n,c,p){let f=this.tileID.canonical.zn)}}class zo{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ur{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(n){let c=Math.round((n-this.lng)/360);if(c!==0)for(let p in this.indexes){let f=this.indexes[p],b={};for(let L in f){let E=f[L];E.tileID=E.tileID.unwrapTo(E.tileID.wrap+c),b[E.tileID.key]=E}this.indexes[p]=b}this.lng=n}addBucket(n,c,p){if(this.indexes[n.overscaledZ]&&this.indexes[n.overscaledZ][n.key]){if(this.indexes[n.overscaledZ][n.key].bucketInstanceId===c.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(n.overscaledZ,this.indexes[n.overscaledZ][n.key])}for(let b=0;bn.overscaledZ)for(let E in L){let H=L[E];H.tileID.isChildOf(n)&&H.findMatches(c.symbolInstances,n,f)}else{let E=L[n.scaledTo(Number(b)).key];E&&E.findMatches(c.symbolInstances,n,f)}}for(let b=0;b{c[p]=!0});for(let p in this.layerIndexes)c[p]||delete this.layerIndexes[p]}}let vs=(y,n)=>o.t(y,n&&n.filter(c=>c.identifier!=="source.canvas")),_n=o.av();class Bo extends o.E{constructor(n,c={}){super(),this._rtlPluginLoaded=()=>{for(let p in this.sourceCaches){let f=this.sourceCaches[p].getSource().type;f!=="vector"&&f!=="geojson"||this.sourceCaches[p].reload()}},this.map=n,this.dispatcher=new Ae(Ot(),n._getMapId()),this.dispatcher.registerMessageHandler("getGlyphs",(p,f)=>this.getGlyphs(p,f)),this.dispatcher.registerMessageHandler("getImages",(p,f)=>this.getImages(p,f)),this.imageManager=new lt,this.imageManager.setEventedParent(this),this.glyphManager=new ie(n._requestManager,c.localIdeographFontFamily),this.lineAtlas=new Qt(256,512),this.crossTileSymbolIndex=new Qr,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new o.aw,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",o.ax()),Oi().on(Ei,this._rtlPluginLoaded),this.on("data",p=>{if(p.dataType!=="source"||p.sourceDataType!=="metadata")return;let f=this.sourceCaches[p.sourceId];if(!f)return;let b=f.getSource();if(b&&b.vectorLayerIds)for(let L in this._layers){let E=this._layers[L];E.source===b.id&&this._validateLayer(E)}})}loadURL(n,c={},p){this.fire(new o.k("dataloading",{dataType:"style"})),c.validate=typeof c.validate!="boolean"||c.validate;let f=this.map._requestManager.transformRequest(n,tt.Style);this._loadStyleRequest=new AbortController,o.h(f,this._loadStyleRequest).then(b=>{this._loadStyleRequest=null,this._load(b.data,c,p)}).catch(b=>{this._loadStyleRequest=null,b&&this.fire(new o.j(b))})}loadJSON(n,c={},p){this.fire(new o.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,c.validate=c.validate!==!1,this._load(n,c,p)}).catch(()=>{})}loadEmpty(){this.fire(new o.k("dataloading",{dataType:"style"})),this._load(_n,{validate:!1})}_load(n,c,p){var f;let b=c.transformStyle?c.transformStyle(p,n):n;if(!c.validate||!vs(this,o.x(b))){this._loaded=!0,this.stylesheet=b;for(let L in b.sources)this.addSource(L,b.sources[L],{validate:!1});b.sprite?this._loadSprite(b.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(b.glyphs),this._createLayers(),this.light=new wt(this.stylesheet.light),this.map.setTerrain((f=this.stylesheet.terrain)!==null&&f!==void 0?f:null),this.fire(new o.k("data",{dataType:"style"})),this.fire(new o.k("style.load"))}}_createLayers(){let n=o.ay(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",n),this._order=n.map(c=>c.id),this._layers={},this._serializedLayers=null;for(let c of n){let p=o.az(c);p.setEventedParent(this,{layer:{id:c.id}}),this._layers[c.id]=p}}_loadSprite(n,c=!1,p=void 0){let f;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(b,L,E,H){return o._(this,void 0,void 0,function*(){let h=Jt(b),I=E>1?"@2x":"",_={},F={};for(let{id:R,url:Z}of h){let N=L.transformRequest(L.normalizeSpriteURL(Z,I,".json"),tt.SpriteJSON);_[R]=o.h(N,H);let P=L.transformRequest(L.normalizeSpriteURL(Z,I,".png"),tt.SpriteImage);F[R]=O.getImage(P,H)}return yield Promise.all([...Object.values(_),...Object.values(F)]),function(R,Z){return o._(this,void 0,void 0,function*(){let N={};for(let P in R){N[P]={};let V=v.getImageCanvasContext((yield Z[P]).data),X=(yield R[P]).data;for(let J in X){let{width:ot,height:pt,x:ut,y:Gt,sdf:Pt,pixelRatio:dt,stretchX:Ct,stretchY:ee,content:ge}=X[J];N[P][J]={data:null,pixelRatio:dt,sdf:Pt,stretchX:Ct,stretchY:ee,content:ge,spriteData:{width:ot,height:pt,x:ut,y:Gt,context:V}}}}return N})}(_,F)})}(n,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(b=>{if(this._spriteRequest=null,b)for(let L in b){this._spritesImagesIds[L]=[];let E=this._spritesImagesIds[L]?this._spritesImagesIds[L].filter(H=>!(H in b)):[];for(let H of E)this.imageManager.removeImage(H),this._changedImages[H]=!0;for(let H in b[L]){let h=L==="default"?H:`${L}:${H}`;this._spritesImagesIds[L].push(h),h in this.imageManager.images?this.imageManager.updateImage(h,b[L][H],!1):this.imageManager.addImage(h,b[L][H]),c&&(this._changedImages[h]=!0)}}}).catch(b=>{this._spriteRequest=null,f=b,this.fire(new o.j(f))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),c&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"})),p&&p(f)})}_unloadSprite(){for(let n of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(n),this._changedImages[n]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}_validateLayer(n){let c=this.sourceCaches[n.source];if(!c)return;let p=n.sourceLayer;if(!p)return;let f=c.getSource();(f.type==="geojson"||f.vectorLayerIds&&f.vectorLayerIds.indexOf(p)===-1)&&this.fire(new o.j(new Error(`Source layer "${p}" does not exist on source "${f.id}" as specified by style layer "${n.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let n in this.sourceCaches)if(!this.sourceCaches[n].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(n){let c=this._serializedAllLayers();if(!n||n.length===0)return Object.values(c);let p=[];for(let f of n)c[f]&&p.push(c[f]);return p}_serializedAllLayers(){let n=this._serializedLayers;if(n)return n;n=this._serializedLayers={};let c=Object.keys(this._layers);for(let p of c){let f=this._layers[p];f.type!=="custom"&&(n[p]=f.serialize())}return n}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(let n in this.sourceCaches)if(this.sourceCaches[n].hasTransition())return!0;for(let n in this._layers)if(this._layers[n].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(n){if(!this._loaded)return;let c=this._changed;if(this._changed){let f=Object.keys(this._updatedLayers),b=Object.keys(this._removedLayers);(f.length||b.length)&&this._updateWorkerLayers(f,b);for(let L in this._updatedSources){let E=this._updatedSources[L];if(E==="reload")this._reloadSource(L);else{if(E!=="clear")throw new Error(`Invalid action ${E}`);this._clearSource(L)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let L in this._updatedPaintProps)this._layers[L].updateTransitions(n);this.light.updateTransitions(n),this._resetUpdates()}let p={};for(let f in this.sourceCaches){let b=this.sourceCaches[f];p[f]=b.used,b.used=!1}for(let f of this._order){let b=this._layers[f];b.recalculate(n,this._availableImages),!b.isHidden(n.zoom)&&b.source&&(this.sourceCaches[b.source].used=!0)}for(let f in p){let b=this.sourceCaches[f];p[f]!==b.used&&b.fire(new o.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:f}))}this.light.recalculate(n),this.z=n.zoom,c&&this.fire(new o.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){let n=Object.keys(this._changedImages);if(n.length){for(let c in this.sourceCaches)this.sourceCaches[c].reloadTilesForDependencies(["icons","patterns"],n);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(n,c){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(n),removedIds:c})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(n,c={}){var p;this._checkLoaded();let f=this.serialize();if(n=c.transformStyle?c.transformStyle(f,n):n,((p=c.validate)===null||p===void 0||p)&&vs(this,o.x(n)))return!1;(n=o.aA(n)).layers=o.ay(n.layers);let b=o.aB(f,n),L=this._getOperationsToPerform(b);if(L.unimplemented.length>0)throw new Error(`Unimplemented: ${L.unimplemented.join(", ")}.`);if(L.operations.length===0)return!1;for(let E of L.operations)E();return this.stylesheet=n,this._serializedLayers=null,!0}_getOperationsToPerform(n){let c=[],p=[];for(let f of n)switch(f.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":c.push(()=>this.addLayer.apply(this,f.args));break;case"removeLayer":c.push(()=>this.removeLayer.apply(this,f.args));break;case"setPaintProperty":c.push(()=>this.setPaintProperty.apply(this,f.args));break;case"setLayoutProperty":c.push(()=>this.setLayoutProperty.apply(this,f.args));break;case"setFilter":c.push(()=>this.setFilter.apply(this,f.args));break;case"addSource":c.push(()=>this.addSource.apply(this,f.args));break;case"removeSource":c.push(()=>this.removeSource.apply(this,f.args));break;case"setLayerZoomRange":c.push(()=>this.setLayerZoomRange.apply(this,f.args));break;case"setLight":c.push(()=>this.setLight.apply(this,f.args));break;case"setGeoJSONSourceData":c.push(()=>this.setGeoJSONSourceData.apply(this,f.args));break;case"setGlyphs":c.push(()=>this.setGlyphs.apply(this,f.args));break;case"setSprite":c.push(()=>this.setSprite.apply(this,f.args));break;case"setTerrain":c.push(()=>this.map.setTerrain.apply(this,f.args));break;case"setTransition":c.push(()=>{});break;default:p.push(f.command)}return{operations:c,unimplemented:p}}addImage(n,c){if(this.getImage(n))return this.fire(new o.j(new Error(`An image named "${n}" already exists.`)));this.imageManager.addImage(n,c),this._afterImageUpdated(n)}updateImage(n,c){this.imageManager.updateImage(n,c)}getImage(n){return this.imageManager.getImage(n)}removeImage(n){if(!this.getImage(n))return this.fire(new o.j(new Error(`An image named "${n}" does not exist.`)));this.imageManager.removeImage(n),this._afterImageUpdated(n)}_afterImageUpdated(n){this._availableImages=this.imageManager.listImages(),this._changedImages[n]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(n,c,p={}){if(this._checkLoaded(),this.sourceCaches[n]!==void 0)throw new Error(`Source "${n}" already exists.`);if(!c.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(c).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(c.type)>=0&&this._validate(o.x.source,`sources.${n}`,c,null,p))return;this.map&&this.map._collectResourceTiming&&(c.collectResourceTiming=!0);let f=this.sourceCaches[n]=new Se(n,c,this.dispatcher);f.style=this,f.setEventedParent(this,()=>({isSourceLoaded:f.loaded(),source:f.serialize(),sourceId:n})),f.onAdd(this.map),this._changed=!0}removeSource(n){if(this._checkLoaded(),this.sourceCaches[n]===void 0)throw new Error("There is no source with this ID");for(let p in this._layers)if(this._layers[p].source===n)return this.fire(new o.j(new Error(`Source "${n}" cannot be removed while layer "${p}" is using it.`)));let c=this.sourceCaches[n];delete this.sourceCaches[n],delete this._updatedSources[n],c.fire(new o.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:n})),c.setEventedParent(null),c.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(n,c){if(this._checkLoaded(),this.sourceCaches[n]===void 0)throw new Error(`There is no source with this ID=${n}`);let p=this.sourceCaches[n].getSource();if(p.type!=="geojson")throw new Error(`geojsonSource.type is ${p.type}, which is !== 'geojson`);p.setData(c),this._changed=!0}getSource(n){return this.sourceCaches[n]&&this.sourceCaches[n].getSource()}addLayer(n,c,p={}){this._checkLoaded();let f=n.id;if(this.getLayer(f))return void this.fire(new o.j(new Error(`Layer "${f}" already exists on this map.`)));let b;if(n.type==="custom"){if(vs(this,o.aC(n)))return;b=o.az(n)}else{if("source"in n&&typeof n.source=="object"&&(this.addSource(f,n.source),n=o.aA(n),n=o.e(n,{source:f})),this._validate(o.x.layer,`layers.${f}`,n,{arrayIndex:-1},p))return;b=o.az(n),this._validateLayer(b),b.setEventedParent(this,{layer:{id:f}})}let L=c?this._order.indexOf(c):this._order.length;if(c&&L===-1)this.fire(new o.j(new Error(`Cannot add layer "${f}" before non-existing layer "${c}".`)));else{if(this._order.splice(L,0,f),this._layerOrderChanged=!0,this._layers[f]=b,this._removedLayers[f]&&b.source&&b.type!=="custom"){let E=this._removedLayers[f];delete this._removedLayers[f],E.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",this.sourceCaches[b.source].pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map)}}moveLayer(n,c){if(this._checkLoaded(),this._changed=!0,!this._layers[n])return void this.fire(new o.j(new Error(`The layer '${n}' does not exist in the map's style and cannot be moved.`)));if(n===c)return;let p=this._order.indexOf(n);this._order.splice(p,1);let f=c?this._order.indexOf(c):this._order.length;c&&f===-1?this.fire(new o.j(new Error(`Cannot move layer "${n}" before non-existing layer "${c}".`))):(this._order.splice(f,0,n),this._layerOrderChanged=!0)}removeLayer(n){this._checkLoaded();let c=this._layers[n];if(!c)return void this.fire(new o.j(new Error(`Cannot remove non-existing layer "${n}".`)));c.setEventedParent(null);let p=this._order.indexOf(n);this._order.splice(p,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[n]=c,delete this._layers[n],this._serializedLayers&&delete this._serializedLayers[n],delete this._updatedLayers[n],delete this._updatedPaintProps[n],c.onRemove&&c.onRemove(this.map)}getLayer(n){return this._layers[n]}getLayersOrder(){return[...this._order]}hasLayer(n){return n in this._layers}setLayerZoomRange(n,c,p){this._checkLoaded();let f=this.getLayer(n);f?f.minzoom===c&&f.maxzoom===p||(c!=null&&(f.minzoom=c),p!=null&&(f.maxzoom=p),this._updateLayer(f)):this.fire(new o.j(new Error(`Cannot set the zoom range of non-existing layer "${n}".`)))}setFilter(n,c,p={}){this._checkLoaded();let f=this.getLayer(n);if(f){if(!o.aD(f.filter,c))return c==null?(f.filter=void 0,void this._updateLayer(f)):void(this._validate(o.x.filter,`layers.${f.id}.filter`,c,null,p)||(f.filter=o.aA(c),this._updateLayer(f)))}else this.fire(new o.j(new Error(`Cannot filter non-existing layer "${n}".`)))}getFilter(n){return o.aA(this.getLayer(n).filter)}setLayoutProperty(n,c,p,f={}){this._checkLoaded();let b=this.getLayer(n);b?o.aD(b.getLayoutProperty(c),p)||(b.setLayoutProperty(c,p,f),this._updateLayer(b)):this.fire(new o.j(new Error(`Cannot style non-existing layer "${n}".`)))}getLayoutProperty(n,c){let p=this.getLayer(n);if(p)return p.getLayoutProperty(c);this.fire(new o.j(new Error(`Cannot get style of non-existing layer "${n}".`)))}setPaintProperty(n,c,p,f={}){this._checkLoaded();let b=this.getLayer(n);b?o.aD(b.getPaintProperty(c),p)||(b.setPaintProperty(c,p,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new o.j(new Error(`Cannot style non-existing layer "${n}".`)))}getPaintProperty(n,c){return this.getLayer(n).getPaintProperty(c)}setFeatureState(n,c){this._checkLoaded();let p=n.source,f=n.sourceLayer,b=this.sourceCaches[p];if(b===void 0)return void this.fire(new o.j(new Error(`The source '${p}' does not exist in the map's style.`)));let L=b.getSource().type;L==="geojson"&&f?this.fire(new o.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):L!=="vector"||f?(n.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),b.setFeatureState(f,n.id,c)):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(n,c){this._checkLoaded();let p=n.source,f=this.sourceCaches[p];if(f===void 0)return void this.fire(new o.j(new Error(`The source '${p}' does not exist in the map's style.`)));let b=f.getSource().type,L=b==="vector"?n.sourceLayer:void 0;b!=="vector"||L?c&&typeof n.id!="string"&&typeof n.id!="number"?this.fire(new o.j(new Error("A feature id is required to remove its specific state property."))):f.removeFeatureState(L,n.id,c):this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(n){this._checkLoaded();let c=n.source,p=n.sourceLayer,f=this.sourceCaches[c];if(f!==void 0)return f.getSource().type!=="vector"||p?(n.id===void 0&&this.fire(new o.j(new Error("The feature id parameter must be provided."))),f.getFeatureState(p,n.id)):void this.fire(new o.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new o.j(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return o.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let n=o.aE(this.sourceCaches,b=>b.serialize()),c=this._serializeByIds(this._order),p=this.map.getTerrain()||void 0,f=this.stylesheet;return o.aF({version:f.version,name:f.name,metadata:f.metadata,light:f.light,center:f.center,zoom:f.zoom,bearing:f.bearing,pitch:f.pitch,sprite:f.sprite,glyphs:f.glyphs,transition:f.transition,sources:n,layers:c,terrain:p},b=>b!==void 0)}_updateLayer(n){this._updatedLayers[n.id]=!0,n.source&&!this._updatedSources[n.source]&&this.sourceCaches[n.source].getSource().type!=="raster"&&(this._updatedSources[n.source]="reload",this.sourceCaches[n.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(n){let c=L=>this._layers[L].type==="fill-extrusion",p={},f=[];for(let L=this._order.length-1;L>=0;L--){let E=this._order[L];if(c(E)){p[E]=L;for(let H of n){let h=H[E];if(h)for(let I of h)f.push(I)}}}f.sort((L,E)=>E.intersectionZ-L.intersectionZ);let b=[];for(let L=this._order.length-1;L>=0;L--){let E=this._order[L];if(c(E))for(let H=f.length-1;H>=0;H--){let h=f[H].feature;if(p[h.layer.id]{let Pt=V.featureSortOrder;if(Pt){let dt=Pt.indexOf(ut.featureIndex);return Pt.indexOf(Gt.featureIndex)-dt}return Gt.featureIndex-ut.featureIndex});for(let ut of pt)ot.push(ut)}}for(let V in Z)Z[V].forEach(X=>{let J=X.feature,ot=h[E[V].source].getFeatureState(J.layer["source-layer"],J.id);J.source=J.layer.source,J.layer["source-layer"]&&(J.sourceLayer=J.layer["source-layer"]),J.state=ot});return Z}(this._layers,L,this.sourceCaches,n,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(b)}querySourceFeatures(n,c){c&&c.filter&&this._validate(o.x.filter,"querySourceFeatures.filter",c.filter,null,c);let p=this.sourceCaches[n];return p?function(f,b){let L=f.getRenderableIds().map(h=>f.getTileByID(h)),E=[],H={};for(let h=0;hF.getTileByID(R)).sort((R,Z)=>Z.tileID.overscaledZ-R.tileID.overscaledZ||(R.tileID.isLessThan(Z.tileID)?-1:1))}let _=this.crossTileSymbolIndex.addLayer(I,H[I.source],n.center.lng);L=L||_}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((b=b||this._layerOrderChanged||p===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(v.now(),n.zoom))&&(this.pauseablePlacement=new Oo(n,this.map.terrain,this._order,b,c,p,f,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,H),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(v.now()),E=!0),L&&this.pauseablePlacement.placement.setStale()),E||L)for(let h of this._order){let I=this._layers[h];I.type==="symbol"&&this.placement.updateLayerOpacities(I,H[I.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(v.now())}_releaseSymbolFadeTiles(){for(let n in this.sourceCaches)this.sourceCaches[n].releaseSymbolFadeTiles()}getImages(n,c){return o._(this,void 0,void 0,function*(){let p=yield this.imageManager.getImages(c.icons);this._updateTilesForChangedImages();let f=this.sourceCaches[c.source];return f&&f.setDependencies(c.tileID.key,c.type,c.icons),p})}getGlyphs(n,c){return o._(this,void 0,void 0,function*(){let p=yield this.glyphManager.getGlyphs(c.stacks),f=this.sourceCaches[c.source];return f&&f.setDependencies(c.tileID.key,c.type,[""]),p})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(n,c={}){this._checkLoaded(),n&&this._validate(o.x.glyphs,"glyphs",n,null,c)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=n,this.glyphManager.entries={},this.glyphManager.setURL(n))}addSprite(n,c,p={},f){this._checkLoaded();let b=[{id:n,url:c}],L=[...Jt(this.stylesheet.sprite),...b];this._validate(o.x.sprite,"sprite",L,null,p)||(this.stylesheet.sprite=L,this._loadSprite(b,!0,f))}removeSprite(n){this._checkLoaded();let c=Jt(this.stylesheet.sprite);if(c.find(p=>p.id===n)){if(this._spritesImagesIds[n])for(let p of this._spritesImagesIds[n])this.imageManager.removeImage(p),this._changedImages[p]=!0;c.splice(c.findIndex(p=>p.id===n),1),this.stylesheet.sprite=c.length>0?c:void 0,delete this._spritesImagesIds[n],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new o.k("data",{dataType:"style"}))}else this.fire(new o.j(new Error(`Sprite "${n}" doesn't exists on this map.`)))}getSprite(){return Jt(this.stylesheet.sprite)}setSprite(n,c={},p){this._checkLoaded(),n&&this._validate(o.x.sprite,"sprite",n,null,c)||(this.stylesheet.sprite=n,n?this._loadSprite(n,!0,p):(this._unloadSprite(),p&&p(null)))}}var gt=o.X([{name:"a_pos",type:"Int16",components:2}]),bt="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";let ct={prelude:Bt(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) @@ -523,7 +523,7 @@ void main() { #pragma mapbox: initialize lowp float halo_blur vec2 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 ? camera_to_anchor_distance/u_camera_to_center_distance : -u_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:Bt("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",yt),terrainDepth:Bt("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);}",yt),terrainCoords:Bt("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);}",yt)};function Bt(y,n){let c=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,p=n.match(/attribute ([\w]+) ([\w]+)/g),f=y.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),b=n.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),L=b?b.concat(f):f,E={};return{fragmentSource:y=y.replace(c,(H,h,I,_,F)=>(E[F]=!0,h==="define"?` +u_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:Bt("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",bt),terrainDepth:Bt("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);}",bt),terrainCoords:Bt("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);}",bt)};function Bt(y,n){let c=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,p=n.match(/attribute ([\w]+) ([\w]+)/g),f=y.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),b=n.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),L=b?b.concat(f):f,E={};return{fragmentSource:y=y.replace(c,(H,h,I,_,F)=>(E[F]=!0,h==="define"?` #ifndef HAS_UNIFORM_u_${F} varying ${I} ${_} ${F}; #else @@ -574,52 +574,52 @@ uniform ${I} ${_} u_${F}; #endif `}),staticAttributes:p,staticUniforms:L}}class Kt{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(n,c,p,f,b,L,E,H,h){this.context=n;let I=this.boundPaintVertexBuffers.length!==f.length;for(let _=0;!I&&_({u_depth:new o.aG(ut,Gt.u_depth),u_terrain:new o.aG(ut,Gt.u_terrain),u_terrain_dim:new o.aH(ut,Gt.u_terrain_dim),u_terrain_matrix:new o.aI(ut,Gt.u_terrain_matrix),u_terrain_unpack:new o.aJ(ut,Gt.u_terrain_unpack),u_terrain_exaggeration:new o.aH(ut,Gt.u_terrain_exaggeration)}))(n,dt),this.binderUniforms=p?p.getUniforms(n,dt):[]}draw(n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N,P,V,X){let J=n.gl;if(this.failedToCreate)return;if(n.program.set(this.program),n.setDepthMode(p),n.setStencilMode(f),n.setColorMode(b),n.setCullFace(L),H){n.activeTexture.set(J.TEXTURE2),J.bindTexture(J.TEXTURE_2D,H.depthTexture),n.activeTexture.set(J.TEXTURE3),J.bindTexture(J.TEXTURE_2D,H.texture);for(let dt in this.terrainUniforms)this.terrainUniforms[dt].set(H[dt])}for(let dt in this.fixedUniforms)this.fixedUniforms[dt].set(E[dt]);N&&N.setUniforms(n,this.binderUniforms,R,{zoom:Z});let ot=0;switch(c){case J.LINES:ot=2;break;case J.TRIANGLES:ot=3;break;case J.LINE_STRIP:ot=1}for(let dt of F.get()){let ut=dt.vaos||(dt.vaos={});(ut[h]||(ut[h]=new Kt)).bind(n,this,I,N?N.getPaintVertexBuffers():[],_,dt.vertexOffset,P,V,X),J.drawElements(c,dt.primitiveLength*ot,J.UNSIGNED_SHORT,dt.primitiveOffset*ot*2)}}}function Be(y,n,c){let p=1/Qi(c,1,n.transform.tileZoom),f=Math.pow(2,c.tileID.overscaledZ),b=c.tileSize*Math.pow(2,n.transform.tileZoom)/f,L=b*(c.tileID.canonical.x+c.tileID.wrap*f),E=b*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[p,y.fromScale,y.toScale],u_fade:y.t,u_pixel_coord_upper:[L>>16,E>>16],u_pixel_coord_lower:[65535&L,65535&E]}}let _e=(y,n,c,p)=>{let f=n.style.light,b=f.properties.get("position"),L=[b.x,b.y,b.z],E=function(){var h=new o.A(9);return o.A!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1,h}();f.properties.get("anchor")==="viewport"&&function(h,I){var _=Math.sin(I),F=Math.cos(I);h[0]=F,h[1]=_,h[2]=0,h[3]=-_,h[4]=F,h[5]=0,h[6]=0,h[7]=0,h[8]=1}(E,-n.transform.angle),function(h,I,_){var F=I[0],R=I[1],Z=I[2];h[0]=F*_[0]+R*_[3]+Z*_[6],h[1]=F*_[1]+R*_[4]+Z*_[7],h[2]=F*_[2]+R*_[5]+Z*_[8]}(L,L,E);let H=f.properties.get("color");return{u_matrix:y,u_lightpos:L,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[H.r,H.g,H.b],u_vertical_gradient:+c,u_opacity:p}},Ce=(y,n,c,p,f,b,L)=>o.e(_e(y,n,c,p),Be(b,n,L),{u_height_factor:-Math.pow(2,f.overscaledZ)/L.tileSize/8}),se=y=>({u_matrix:y}),ye=(y,n,c,p)=>o.e(se(y),Be(c,n,p)),be=(y,n)=>({u_matrix:y,u_world:n}),Ge=(y,n,c,p,f)=>o.e(ye(y,n,c,p),{u_world:f}),Ui=(y,n,c,p)=>{let f=y.transform,b,L;if(p.paint.get("circle-pitch-alignment")==="map"){let E=Qi(c,1,f.zoom);b=!0,L=[E,E]}else b=!1,L=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+(p.paint.get("circle-pitch-scale")==="map"),u_matrix:y.translatePosMatrix(n.posMatrix,c,p.paint.get("circle-translate"),p.paint.get("circle-translate-anchor")),u_pitch_with_map:+b,u_device_pixel_ratio:y.pixelRatio,u_extrude_scale:L}},Ri=(y,n,c)=>{let p=Qi(c,1,n.zoom),f=Math.pow(2,n.zoom-c.tileID.overscaledZ),b=c.tileID.overscaleFactor();return{u_matrix:y,u_camera_to_center_distance:n.cameraToCenterDistance,u_pixels_to_tile_units:p,u_extrude_scale:[n.pixelsToGLUnits[0]/(p*f),n.pixelsToGLUnits[1]/(p*f)],u_overscale_factor:b}},Pe=(y,n,c=1)=>({u_matrix:y,u_color:n,u_overlay:0,u_overlay_scale:c}),Qe=y=>({u_matrix:y}),Ai=(y,n,c,p)=>({u_matrix:y,u_extrude_scale:Qi(n,1,c),u_intensity:p});function Fi(y,n){let c=Math.pow(2,n.canonical.z),p=n.canonical.y;return[new o.Y(0,p/c).toLngLat().lat,new o.Y(0,(p+1)/c).toLngLat().lat]}let Wi=(y,n,c,p)=>{let f=y.transform;return{u_matrix:Ur(y,n,c,p),u_ratio:1/Qi(n,1,f.zoom),u_device_pixel_ratio:y.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},nr=(y,n,c,p,f)=>o.e(Wi(y,n,c,f),{u_image:0,u_image_height:p}),ai=(y,n,c,p,f)=>{let b=y.transform,L=Or(n,b);return{u_matrix:Ur(y,n,c,f),u_texsize:n.imageAtlasTexture.size,u_ratio:1/Qi(n,1,b.zoom),u_device_pixel_ratio:y.pixelRatio,u_image:0,u_scale:[L,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/b.pixelsToGLUnits[0],1/b.pixelsToGLUnits[1]]}},dr=(y,n,c,p,f,b)=>{let L=y.lineAtlas,E=Or(n,y.transform),H=c.layout.get("line-cap")==="round",h=L.getDash(p.from,H),I=L.getDash(p.to,H),_=h.width*f.fromScale,F=I.width*f.toScale;return o.e(Wi(y,n,c,b),{u_patternscale_a:[E/_,-h.height/2],u_patternscale_b:[E/F,-I.height/2],u_sdfgamma:L.width/(256*Math.min(_,F)*y.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:I.y,u_mix:f.t})};function Or(y,n){return 1/Qi(y,1,n.tileZoom)}function Ur(y,n,c,p){return y.translatePosMatrix(p?p.posMatrix:n.tileID.posMatrix,n,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}let _n=(y,n,c,p,f)=>{return{u_matrix:y,u_tl_parent:n,u_scale_parent:c,u_buffer_scale:1,u_fade_t:p.mix,u_opacity:p.opacity*f.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:f.paint.get("raster-brightness-min"),u_brightness_high:f.paint.get("raster-brightness-max"),u_saturation_factor:(L=f.paint.get("raster-saturation"),L>0?1-1/(1.001-L):-L),u_contrast_factor:(b=f.paint.get("raster-contrast"),b>0?1/(1-b):1+b),u_spin_weights:vn(f.paint.get("raster-hue-rotate"))};var b,L};function vn(y){y*=Math.PI/180;let n=Math.sin(y),c=Math.cos(y);return[(2*c+1)/3,(-Math.sqrt(3)*n-c+1)/3,(Math.sqrt(3)*n-c+1)/3]}let ws=(y,n,c,p,f,b,L,E,H,h)=>{let I=f.transform;return{u_is_size_zoom_constant:+(y==="constant"||y==="source"),u_is_size_feature_constant:+(y==="constant"||y==="camera"),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:I.width/I.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:b,u_label_plane_matrix:L,u_coord_matrix:E,u_is_text:+H,u_pitch_with_map:+p,u_texsize:h,u_texture:0}},_o=(y,n,c,p,f,b,L,E,H,h,I)=>{let _=f.transform;return o.e(ws(y,n,c,p,f,b,L,E,H,h),{u_gamma_scale:p?Math.cos(_._pitch)*_.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:+I})},Ic=(y,n,c,p,f,b,L,E,H,h)=>o.e(_o(y,n,c,p,f,b,L,E,!0,H,!0),{u_texsize_icon:h,u_texture_icon:1}),yc=(y,n,c)=>({u_matrix:y,u_opacity:n,u_color:c}),El=(y,n,c,p,f,b)=>o.e(function(L,E,H,h){let I=H.imageManager.getPattern(L.from.toString()),_=H.imageManager.getPattern(L.to.toString()),{width:F,height:R}=H.imageManager.getPixelSize(),Z=Math.pow(2,h.tileID.overscaledZ),N=h.tileSize*Math.pow(2,H.transform.tileZoom)/Z,P=N*(h.tileID.canonical.x+h.tileID.wrap*Z),V=N*h.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:I.tl,u_pattern_br_a:I.br,u_pattern_tl_b:_.tl,u_pattern_br_b:_.br,u_texsize:[F,R],u_mix:E.t,u_pattern_size_a:I.displaySize,u_pattern_size_b:_.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/Qi(h,1,H.transform.tileZoom),u_pixel_coord_upper:[P>>16,V>>16],u_pixel_coord_lower:[65535&P,65535&V]}}(p,b,c,f),{u_matrix:y,u_opacity:n}),el={fillExtrusion:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_lightpos:new o.aK(y,n.u_lightpos),u_lightintensity:new o.aH(y,n.u_lightintensity),u_lightcolor:new o.aK(y,n.u_lightcolor),u_vertical_gradient:new o.aH(y,n.u_vertical_gradient),u_opacity:new o.aH(y,n.u_opacity)}),fillExtrusionPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_lightpos:new o.aK(y,n.u_lightpos),u_lightintensity:new o.aH(y,n.u_lightintensity),u_lightcolor:new o.aK(y,n.u_lightcolor),u_vertical_gradient:new o.aH(y,n.u_vertical_gradient),u_height_factor:new o.aH(y,n.u_height_factor),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade),u_opacity:new o.aH(y,n.u_opacity)}),fill:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix)}),fillPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),fillOutline:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world)}),fillOutlinePattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),circle:(y,n)=>({u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_scale_with_map:new o.aG(y,n.u_scale_with_map),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_extrude_scale:new o.aL(y,n.u_extrude_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_matrix:new o.aI(y,n.u_matrix)}),collisionBox:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pixels_to_tile_units:new o.aH(y,n.u_pixels_to_tile_units),u_extrude_scale:new o.aL(y,n.u_extrude_scale),u_overscale_factor:new o.aH(y,n.u_overscale_factor)}),collisionCircle:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_inv_matrix:new o.aI(y,n.u_inv_matrix),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_viewport_size:new o.aL(y,n.u_viewport_size)}),debug:(y,n)=>({u_color:new o.aM(y,n.u_color),u_matrix:new o.aI(y,n.u_matrix),u_overlay:new o.aG(y,n.u_overlay),u_overlay_scale:new o.aH(y,n.u_overlay_scale)}),clippingMask:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix)}),heatmap:(y,n)=>({u_extrude_scale:new o.aH(y,n.u_extrude_scale),u_intensity:new o.aH(y,n.u_intensity),u_matrix:new o.aI(y,n.u_matrix)}),heatmapTexture:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world),u_image:new o.aG(y,n.u_image),u_color_ramp:new o.aG(y,n.u_color_ramp),u_opacity:new o.aH(y,n.u_opacity)}),hillshade:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_latrange:new o.aL(y,n.u_latrange),u_light:new o.aL(y,n.u_light),u_shadow:new o.aM(y,n.u_shadow),u_highlight:new o.aM(y,n.u_highlight),u_accent:new o.aM(y,n.u_accent)}),hillshadePrepare:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_dimension:new o.aL(y,n.u_dimension),u_zoom:new o.aH(y,n.u_zoom),u_unpack:new o.aJ(y,n.u_unpack)}),line:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels)}),lineGradient:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_image:new o.aG(y,n.u_image),u_image_height:new o.aH(y,n.u_image_height)}),linePattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texsize:new o.aL(y,n.u_texsize),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_image:new o.aG(y,n.u_image),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),lineSDF:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_patternscale_a:new o.aL(y,n.u_patternscale_a),u_patternscale_b:new o.aL(y,n.u_patternscale_b),u_sdfgamma:new o.aH(y,n.u_sdfgamma),u_image:new o.aG(y,n.u_image),u_tex_y_a:new o.aH(y,n.u_tex_y_a),u_tex_y_b:new o.aH(y,n.u_tex_y_b),u_mix:new o.aH(y,n.u_mix)}),raster:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_tl_parent:new o.aL(y,n.u_tl_parent),u_scale_parent:new o.aH(y,n.u_scale_parent),u_buffer_scale:new o.aH(y,n.u_buffer_scale),u_fade_t:new o.aH(y,n.u_fade_t),u_opacity:new o.aH(y,n.u_opacity),u_image0:new o.aG(y,n.u_image0),u_image1:new o.aG(y,n.u_image1),u_brightness_low:new o.aH(y,n.u_brightness_low),u_brightness_high:new o.aH(y,n.u_brightness_high),u_saturation_factor:new o.aH(y,n.u_saturation_factor),u_contrast_factor:new o.aH(y,n.u_contrast_factor),u_spin_weights:new o.aK(y,n.u_spin_weights)}),symbolIcon:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texture:new o.aG(y,n.u_texture)}),symbolSDF:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texture:new o.aG(y,n.u_texture),u_gamma_scale:new o.aH(y,n.u_gamma_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_is_halo:new o.aG(y,n.u_is_halo)}),symbolTextAndIcon:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texsize_icon:new o.aL(y,n.u_texsize_icon),u_texture:new o.aG(y,n.u_texture),u_texture_icon:new o.aG(y,n.u_texture_icon),u_gamma_scale:new o.aH(y,n.u_gamma_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_is_halo:new o.aG(y,n.u_is_halo)}),background:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_opacity:new o.aH(y,n.u_opacity),u_color:new o.aM(y,n.u_color)}),backgroundPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_opacity:new o.aH(y,n.u_opacity),u_image:new o.aG(y,n.u_image),u_pattern_tl_a:new o.aL(y,n.u_pattern_tl_a),u_pattern_br_a:new o.aL(y,n.u_pattern_br_a),u_pattern_tl_b:new o.aL(y,n.u_pattern_tl_b),u_pattern_br_b:new o.aL(y,n.u_pattern_br_b),u_texsize:new o.aL(y,n.u_texsize),u_mix:new o.aH(y,n.u_mix),u_pattern_size_a:new o.aL(y,n.u_pattern_size_a),u_pattern_size_b:new o.aL(y,n.u_pattern_size_b),u_scale_a:new o.aH(y,n.u_scale_a),u_scale_b:new o.aH(y,n.u_scale_b),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aH(y,n.u_tile_units_to_pixels)}),terrain:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texture:new o.aG(y,n.u_texture),u_ele_delta:new o.aH(y,n.u_ele_delta)}),terrainDepth:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ele_delta:new o.aH(y,n.u_ele_delta)}),terrainCoords:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texture:new o.aG(y,n.u_texture),u_terrain_coords_id:new o.aH(y,n.u_terrain_coords_id),u_ele_delta:new o.aH(y,n.u_ele_delta)})};class Bs{constructor(n,c,p){this.context=n;let f=n.gl;this.buffer=f.createBuffer(),this.dynamicDraw=Boolean(p),this.context.unbindVAO(),n.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(n){let c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,n.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let eo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class qn{constructor(n,c,p,f){this.length=c.length,this.attributes=p,this.itemSize=c.bytesPerElement,this.dynamicDraw=f,this.context=n;let b=n.gl;this.buffer=b.createBuffer(),n.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(n){if(n.length!==this.length)throw new Error(`Length of new data is ${n.length}, which doesn't match current length of ${this.length}`);let c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,n.arrayBuffer)}enableAttributes(n,c){for(let p=0;p0){let Ct=o.F(),ee=Gt;o.aP(Ct,ut.placementInvProjMatrix,y.transform.glCoordMatrix),o.aP(Ct,Ct,ut.placementViewportMatrix),I.push({circleArray:gt,circleOffset:F,transform:ee,invTransform:Ct,coord:ot}),_+=gt.length/4,F=_}Pt&&h.draw(E,H.LINES,Ci.disabled,Xi.disabled,y.colorModeForRenderPass(),Yi.disabled,Ri(Gt,y.transform,dt),y.style.map.terrain&&y.style.map.terrain.getTerrainData(ot),c.id,Pt.layoutVertexBuffer,Pt.indexBuffer,Pt.segments,null,y.transform.zoom,null,null,Pt.collisionVertexBuffer)}if(!L||!I.length)return;let R=y.useProgram("collisionCircle"),Z=new o.aQ;Z.resize(4*_),Z._trim();let N=0;for(let J of I)for(let ot=0;ot=0&&(Z[P.associatedIconIndex]={shiftedAnchor:ge,angle:jt})}else Xe(P.numGlyphs,F)}if(h){R.clear();let N=y.icon.placedSymbolArray;for(let P=0;Py.style.map.terrain.getElevation(Pt,pn,$i):null,Br=c.layout.get("text-rotation-alignment")==="map";rt(Ct,Pt.posMatrix,y,f,Yr,Gr,P,h,Br,_r)}let An=y.translatePosMatrix(Pt.posMatrix,gt,b,L),rn=V||f&&ut||wr?Hs:Yr,ur=y.translatePosMatrix(Gr,gt,b,L,!0),sr=jt&&c.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1)!==0,Ir;Ir=jt?Ct.iconsInText?Ic(Fe.kind,xe,X,P,y,An,rn,ur,pi,ji):_o(Fe.kind,xe,X,P,y,An,rn,ur,f,pi,!0):ws(Fe.kind,xe,X,P,y,An,rn,ur,f,pi);let Sn={program:Ye,buffers:ee,uniformValues:Ir,atlasTexture:Mi,atlasTextureIcon:Ii,atlasInterpolation:Si,atlasInterpolationIcon:cr,isSDF:jt,hasHalo:sr};if(J&&Ct.canOverlap){ot=!0;let _r=ee.segments.get();for(let Br of _r)Gt.push({segments:new o.$([Br]),sortKey:Br.sortKey,state:Sn,terrainData:ci})}else Gt.push({segments:ee.segments,sortKey:0,state:Sn,terrainData:ci})}ot&&Gt.sort((Pt,gt)=>Pt.sortKey-gt.sortKey);for(let Pt of Gt){let gt=Pt.state;if(F.activeTexture.set(R.TEXTURE0),gt.atlasTexture.bind(gt.atlasInterpolation,R.CLAMP_TO_EDGE),gt.atlasTextureIcon&&(F.activeTexture.set(R.TEXTURE1),gt.atlasTextureIcon&>.atlasTextureIcon.bind(gt.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),gt.isSDF){let Ct=gt.uniformValues;gt.hasHalo&&(Ct.u_is_halo=1,ga(gt.buffers,Pt.segments,c,y,gt.program,dt,I,_,Ct,Pt.terrainData)),Ct.u_is_halo=0}ga(gt.buffers,Pt.segments,c,y,gt.program,dt,I,_,gt.uniformValues,Pt.terrainData)}}function ga(y,n,c,p,f,b,L,E,H,h){let I=p.context;f.draw(I,I.gl.TRIANGLES,b,L,E,Yi.disabled,H,h,c.id,y.layoutVertexBuffer,y.indexBuffer,n,c.paint,p.transform.zoom,y.programConfigurations.get(c.id),y.dynamicLayoutVertexBuffer,y.opacityVertexBuffer)}function Qa(y,n,c,p,f){if(!c||!p||!p.imageAtlas)return;let b=p.imageAtlas.patternPositions,L=b[c.to.toString()],E=b[c.from.toString()];if(!L&&E&&(L=E),!E&&L&&(E=L),!L||!E){let H=f.getPaintProperty(n);L=b[H],E=b[H]}L&&E&&y.setConstantPatternPositions(L,E)}function Ua(y,n,c,p,f,b,L){let E=y.context.gl,H="fill-pattern",h=c.paint.get(H),I=h&&h.constantOr(1),_=c.getCrossfadeParameters(),F,R,Z,N,P;L?(R=I&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",F=E.LINES):(R=I?"fillPattern":"fill",F=E.TRIANGLES);let V=h.constantOr(null);for(let X of p){let J=n.getTile(X);if(I&&!J.patternsLoaded())continue;let ot=J.getBucket(c);if(!ot)continue;let dt=ot.programConfigurations.get(c.id),ut=y.useProgram(R,dt),Gt=y.style.map.terrain&&y.style.map.terrain.getTerrainData(X);I&&(y.context.activeTexture.set(E.TEXTURE0),J.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),dt.updatePaintBuffers(_)),Qa(dt,H,V,J,c);let Pt=Gt?X:null,gt=y.translatePosMatrix(Pt?Pt.posMatrix:X.posMatrix,J,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(L){N=ot.indexBuffer2,P=ot.segments2;let Ct=[E.drawingBufferWidth,E.drawingBufferHeight];Z=R==="fillOutlinePattern"&&I?Ge(gt,y,_,J,Ct):be(gt,Ct)}else N=ot.indexBuffer,P=ot.segments,Z=I?ye(gt,y,_,J):se(gt);ut.draw(y.context,F,f,y.stencilModeForClipping(X),b,Yi.disabled,Z,Gt,c.id,ot.layoutVertexBuffer,N,P,c.paint,y.transform.zoom,dt)}}function Lo(y,n,c,p,f,b,L){let E=y.context,H=E.gl,h="fill-extrusion-pattern",I=c.paint.get(h),_=I.constantOr(1),F=c.getCrossfadeParameters(),R=c.paint.get("fill-extrusion-opacity"),Z=I.constantOr(null);for(let N of p){let P=n.getTile(N),V=P.getBucket(c);if(!V)continue;let X=y.style.map.terrain&&y.style.map.terrain.getTerrainData(N),J=V.programConfigurations.get(c.id),ot=y.useProgram(_?"fillExtrusionPattern":"fillExtrusion",J);_&&(y.context.activeTexture.set(H.TEXTURE0),P.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),J.updatePaintBuffers(F)),Qa(J,h,Z,P,c);let dt=y.translatePosMatrix(N.posMatrix,P,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),ut=c.paint.get("fill-extrusion-vertical-gradient"),Gt=_?Ce(dt,y,ut,R,N,F,P):_e(dt,y,ut,R);ot.draw(E,E.gl.TRIANGLES,f,b,L,Yi.backCCW,Gt,X,c.id,V.layoutVertexBuffer,V.indexBuffer,V.segments,c.paint,y.transform.zoom,J,y.style.map.terrain&&V.centroidVertexBuffer)}}function da(y,n,c,p,f,b,L){let E=y.context,H=E.gl,h=c.fbo;if(!h)return;let I=y.useProgram("hillshade"),_=y.style.map.terrain&&y.style.map.terrain.getTerrainData(n);E.activeTexture.set(H.TEXTURE0),H.bindTexture(H.TEXTURE_2D,h.colorAttachment.get()),I.draw(E,H.TRIANGLES,f,b,L,Yi.disabled,((F,R,Z,N)=>{let P=Z.paint.get("hillshade-shadow-color"),V=Z.paint.get("hillshade-highlight-color"),X=Z.paint.get("hillshade-accent-color"),J=Z.paint.get("hillshade-illumination-direction")*(Math.PI/180);Z.paint.get("hillshade-illumination-anchor")==="viewport"&&(J-=F.transform.angle);let ot=!F.options.moving;return{u_matrix:N?N.posMatrix:F.transform.calculatePosMatrix(R.tileID.toUnwrapped(),ot),u_image:0,u_latrange:Fi(0,R.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),J],u_shadow:P,u_highlight:V,u_accent:X}})(y,c,p,_?n:null),_,p.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}function ts(y,n,c,p,f,b){let L=y.context,E=L.gl,H=n.dem;if(H&&H.data){let h=H.dim,I=H.stride,_=H.getPixels();if(L.activeTexture.set(E.TEXTURE1),L.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||y.getTileTexture(I),n.demTexture){let R=n.demTexture;R.update(_,{premultiply:!1}),R.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else n.demTexture=new qt(L,_,E.RGBA,{premultiply:!1}),n.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);L.activeTexture.set(E.TEXTURE0);let F=n.fbo;if(!F){let R=new qt(L,{width:h,height:h,data:null},E.RGBA);R.bind(E.LINEAR,E.CLAMP_TO_EDGE),F=n.fbo=L.createFramebuffer(h,h,!0,!1),F.colorAttachment.set(R.texture)}L.bindFramebuffer.set(F.framebuffer),L.viewport.set([0,0,h,h]),y.useProgram("hillshadePrepare").draw(L,E.TRIANGLES,p,f,b,Yi.disabled,((R,Z)=>{let N=Z.stride,P=o.F();return o.aN(P,0,o.W,-o.W,0,0,1),o.H(P,P,[0,-o.W,0]),{u_matrix:P,u_image:1,u_dimension:[N,N],u_zoom:R.overscaledZ,u_unpack:Z.getUnpackVector()}})(n.tileID,H),null,c.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments),n.needsHillshadePrepare=!1}}function Ga(y,n,c,p,f,b){let L=p.paint.get("raster-fade-duration");if(!b&&L>0){let E=v.now(),H=(E-y.timeAdded)/L,h=n?(E-n.timeAdded)/L:-1,I=c.getSource(),_=f.coveringZoomLevel({tileSize:I.tileSize,roundZoom:I.roundZoom}),F=!n||Math.abs(n.tileID.overscaledZ-_)>Math.abs(y.tileID.overscaledZ-_),R=F&&y.refreshedUponExpiration?1:o.ac(F?H:1-h,0,1);return y.refreshedUponExpiration&&H>=1&&(y.refreshedUponExpiration=!1),n?{opacity:1,mix:1-R}:{opacity:R,mix:0}}return{opacity:1,mix:0}}let $o=new o.aO(1,0,0,1),pa=new o.aO(0,1,0,1),nl=new o.aO(0,0,1,1),es=new o.aO(1,0,1,1),zr=new o.aO(0,1,1,1);function Ps(y,n,c,p){On(y,0,n+c/2,y.transform.width,c,p)}function Wn(y,n,c,p){On(y,n-c/2,0,c,y.transform.height,p)}function On(y,n,c,p,f,b){let L=y.context,E=L.gl;E.enable(E.SCISSOR_TEST),E.scissor(n*y.pixelRatio,c*y.pixelRatio,p*y.pixelRatio,f*y.pixelRatio),L.clear({color:b}),E.disable(E.SCISSOR_TEST)}function Ra(y,n,c){let p=y.context,f=p.gl,b=c.posMatrix,L=y.useProgram("debug"),E=Ci.disabled,H=Xi.disabled,h=y.colorModeForRenderPass(),I="$debug",_=y.style.map.terrain&&y.style.map.terrain.getTerrainData(c);p.activeTexture.set(f.TEXTURE0);let F=n.getTileByID(c.key).latestRawTileData,R=Math.floor((F&&F.byteLength||0)/1024),Z=n.getTile(c).tileSize,N=512/Math.min(Z,512)*(c.overscaledZ/y.transform.zoom)*.5,P=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(P+=` => ${c.overscaledZ}`),function(V,X){V.initDebugOverlayCanvas();let J=V.debugOverlayCanvas,ot=V.context.gl,dt=V.debugOverlayCanvas.getContext("2d");dt.clearRect(0,0,J.width,J.height),dt.shadowColor="white",dt.shadowBlur=2,dt.lineWidth=1.5,dt.strokeStyle="white",dt.textBaseline="top",dt.font="bold 36px Open Sans, sans-serif",dt.fillText(X,5,5),dt.strokeText(X,5,5),V.debugOverlayTexture.update(J),V.debugOverlayTexture.bind(ot.LINEAR,ot.CLAMP_TO_EDGE)}(y,`${P} ${R}kB`),L.draw(p,f.TRIANGLES,E,H,xi.alphaBlended,Yi.disabled,Pe(b,o.aO.transparent,N),null,I,y.debugBuffer,y.quadTriangleIndexBuffer,y.debugSegments),L.draw(p,f.LINE_STRIP,E,H,h,Yi.disabled,Pe(b,o.aO.red),_,I,y.debugBuffer,y.tileBorderIndexBuffer,y.debugSegments)}function sl(y,n,c){let p=y.context,f=p.gl,b=y.colorModeForRenderPass(),L=new Ci(f.LEQUAL,Ci.ReadWrite,y.depthRangeFor3D),E=y.useProgram("terrain"),H=n.getTerrainMesh();p.bindFramebuffer.set(null),p.viewport.set([0,0,y.width,y.height]);for(let h of c){let I=y.renderToTexture.getTexture(h),_=n.getTerrainData(h.tileID);p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,I.texture);let F={u_matrix:y.transform.calculatePosMatrix(h.tileID.toUnwrapped()),u_texture:0,u_ele_delta:n.getMeshFrameDelta(y.transform.zoom)};E.draw(p,f.TRIANGLES,L,Xi.disabled,b,Yi.backCCW,F,_,"terrain",H.vertexBuffer,H.indexBuffer,H.segments)}}class fa{constructor(n,c){this.context=new ar(n),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Se.maxUnderzooming+Se.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Nr}resize(n,c,p){if(this.width=Math.floor(n*p),this.height=Math.floor(c*p),this.pixelRatio=p,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let f of this.style._order)this.style._layers[f].resize()}setup(){let n=this.context,c=new o.aV;c.emplaceBack(0,0),c.emplaceBack(o.W,0),c.emplaceBack(0,o.W),c.emplaceBack(o.W,o.W),this.tileExtentBuffer=n.createVertexBuffer(c,pt.members),this.tileExtentSegments=o.$.simpleSegment(0,0,4,2);let p=new o.aV;p.emplaceBack(0,0),p.emplaceBack(o.W,0),p.emplaceBack(0,o.W),p.emplaceBack(o.W,o.W),this.debugBuffer=n.createVertexBuffer(p,pt.members),this.debugSegments=o.$.simpleSegment(0,0,4,5);let f=new o.Z;f.emplaceBack(0,0,0,0),f.emplaceBack(o.W,0,o.W,0),f.emplaceBack(0,o.W,0,o.W),f.emplaceBack(o.W,o.W,o.W,o.W),this.rasterBoundsBuffer=n.createVertexBuffer(f,Ee.members),this.rasterBoundsSegments=o.$.simpleSegment(0,0,4,2);let b=new o.aV;b.emplaceBack(0,0),b.emplaceBack(1,0),b.emplaceBack(0,1),b.emplaceBack(1,1),this.viewportBuffer=n.createVertexBuffer(b,pt.members),this.viewportSegments=o.$.simpleSegment(0,0,4,2);let L=new o.aW;L.emplaceBack(0),L.emplaceBack(1),L.emplaceBack(3),L.emplaceBack(2),L.emplaceBack(0),this.tileBorderIndexBuffer=n.createIndexBuffer(L);let E=new o.aX;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=n.createIndexBuffer(E);let H=this.context.gl;this.stencilClearMode=new Xi({func:H.ALWAYS,mask:0},0,255,H.ZERO,H.ZERO,H.ZERO)}clearStencil(){let n=this.context,c=n.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let p=o.F();o.aN(p,0,this.width,this.height,0,0,1),o.J(p,p,[c.drawingBufferWidth,c.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(n,c.TRIANGLES,Ci.disabled,this.stencilClearMode,xi.disabled,Yi.disabled,Qe(p),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(n,c){if(this.currentStencilSource===n.source||!n.isTileClipped()||!c||!c.length)return;this.currentStencilSource=n.source;let p=this.context,f=p.gl;this.nextStencilID+c.length>256&&this.clearStencil(),p.setColorMode(xi.disabled),p.setDepthMode(Ci.disabled);let b=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let L of c){let E=this._tileClippingMaskIDs[L.key]=this.nextStencilID++,H=this.style.map.terrain&&this.style.map.terrain.getTerrainData(L);b.draw(p,f.TRIANGLES,Ci.disabled,new Xi({func:f.ALWAYS,mask:0},E,255,f.KEEP,f.KEEP,f.REPLACE),xi.disabled,Yi.disabled,Qe(L.posMatrix),H,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let n=this.nextStencilID++,c=this.context.gl;return new Xi({func:c.NOTEQUAL,mask:255},n,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(n){let c=this.context.gl;return new Xi({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[n.key],0,c.KEEP,c.KEEP,c.REPLACE)}stencilConfigForOverlap(n){let c=this.context.gl,p=n.sort((L,E)=>E.overscaledZ-L.overscaledZ),f=p[p.length-1].overscaledZ,b=p[0].overscaledZ-f+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();let L={};for(let E=0;E=0;this.currentLayer--){let H=this.style._layers[p[this.currentLayer]],h=f[H.source],I=b[H.source];this._renderTileClippingMasks(H,I),this.renderLayer(this,h,H,I)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerP.source&&!P.isHidden(I)?[h.sourceCaches[P.source]]:[]),R=F.filter(P=>P.getSource().type==="vector"),Z=F.filter(P=>P.getSource().type!=="vector"),N=P=>{(!_||_.getSource().maxzoomN(P)),_||Z.forEach(P=>N(P)),_}(this.style,this.transform.zoom);H&&function(h,I,_){for(let F=0;F<_.length;F++)Ra(h,I,_[F])}(this,H,H.getVisibleCoordinates())}this.options.showPadding&&function(H){let h=H.transform.padding;Ps(H,H.transform.height-(h.top||0),3,$o),Ps(H,h.bottom||0,3,pa),Wn(H,h.left||0,3,nl),Wn(H,H.transform.width-(h.right||0),3,es);let I=H.transform.centerPoint;(function(_,F,R,Z){On(_,F-1,R-10,2,20,Z),On(_,F-10,R-1,20,2,Z)})(H,I.x,H.transform.height-I.y,zr)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(n){if(!this.style||!this.style.map||!this.style.map.terrain)return;let c=this.terrainFacilitator.matrix,p=this.transform.projMatrix,f=this.terrainFacilitator.dirty;f||(f=n?!o.aY(c,p):!o.aZ(c,p)),f||(f=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),f&&(o.a_(c,p),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(b,L){let E=b.context,H=E.gl,h=xi.unblended,I=new Ci(H.LEQUAL,Ci.ReadWrite,[0,1]),_=L.getTerrainMesh(),F=L.sourceCache.getRenderableTiles(),R=b.useProgram("terrainDepth");E.bindFramebuffer.set(L.getFramebuffer("depth").framebuffer),E.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),E.clear({color:o.aO.transparent,depth:1});for(let Z of F){let N=L.getTerrainData(Z.tileID),P={u_matrix:b.transform.calculatePosMatrix(Z.tileID.toUnwrapped()),u_ele_delta:L.getMeshFrameDelta(b.transform.zoom)};R.draw(E,H.TRIANGLES,I,Xi.disabled,h,Yi.backCCW,P,N,"terrain",_.vertexBuffer,_.indexBuffer,_.segments)}E.bindFramebuffer.set(null),E.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain),function(b,L){let E=b.context,H=E.gl,h=xi.unblended,I=new Ci(H.LEQUAL,Ci.ReadWrite,[0,1]),_=L.getTerrainMesh(),F=L.getCoordsTexture(),R=L.sourceCache.getRenderableTiles(),Z=b.useProgram("terrainCoords");E.bindFramebuffer.set(L.getFramebuffer("coords").framebuffer),E.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),E.clear({color:o.aO.transparent,depth:1}),L.coordsIndex=[];for(let N of R){let P=L.getTerrainData(N.tileID);E.activeTexture.set(H.TEXTURE0),H.bindTexture(H.TEXTURE_2D,F.texture);let V={u_matrix:b.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-L.coordsIndex.length)/255,u_texture:0,u_ele_delta:L.getMeshFrameDelta(b.transform.zoom)};Z.draw(E,H.TRIANGLES,I,Xi.disabled,h,Yi.backCCW,V,P,"terrain",_.vertexBuffer,_.indexBuffer,_.segments),L.coordsIndex.push(N.tileID.key)}E.bindFramebuffer.set(null),E.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain))}renderLayer(n,c,p,f){if(!p.isHidden(this.transform.zoom)&&(p.type==="background"||p.type==="custom"||(f||[]).length))switch(this.id=p.id,p.type){case"symbol":(function(b,L,E,H,h){if(b.renderPass!=="translucent")return;let I=Xi.disabled,_=b.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(F,R,Z,N,P,V,X){let J=R.transform,ot=P==="map",dt=V==="map";for(let ut of F){let Gt=N.getTile(ut),Pt=Gt.getBucket(Z);if(!Pt||!Pt.text||!Pt.text.segments.get().length)continue;let gt=o.ag(Pt.textSizeData,J.zoom),Ct=Qi(Gt,1,R.transform.zoom),ee=tr(ut.posMatrix,dt,ot,R.transform,Ct),ge=Z.layout.get("icon-text-fit")!=="none"&&Pt.hasIconData();if(gt){let jt=Math.pow(2,J.zoom-Gt.tileID.overscaledZ);Zs(Pt,ot,dt,X,J,ee,ut.posMatrix,jt,gt,ge,R.style.map.terrain?(Fe,ke)=>R.style.map.terrain.getElevation(ut,Fe,ke):null)}}}(H,b,E,L,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),h),E.paint.get("icon-opacity").constantOr(1)!==0&&bA(b,L,E,H,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),I,_),E.paint.get("text-opacity").constantOr(1)!==0&&bA(b,L,E,H,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),I,_),L.map.showCollisionBoxes&&(hn(b,L,E,H,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),!0),hn(b,L,E,H,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),!1))})(n,c,p,f,this.style.placement.variableOffsets);break;case"circle":(function(b,L,E,H){if(b.renderPass!=="translucent")return;let h=E.paint.get("circle-opacity"),I=E.paint.get("circle-stroke-width"),_=E.paint.get("circle-stroke-opacity"),F=!E.layout.get("circle-sort-key").isConstant();if(h.constantOr(1)===0&&(I.constantOr(1)===0||_.constantOr(1)===0))return;let R=b.context,Z=R.gl,N=b.depthModeForSublayer(0,Ci.ReadOnly),P=Xi.disabled,V=b.colorModeForRenderPass(),X=[];for(let J=0;JJ.sortKey-ot.sortKey);for(let J of X){let{programConfiguration:ot,program:dt,layoutVertexBuffer:ut,indexBuffer:Gt,uniformValues:Pt,terrainData:gt}=J.state;dt.draw(R,Z.TRIANGLES,N,P,V,Yi.disabled,Pt,gt,E.id,ut,Gt,J.segments,E.paint,b.transform.zoom,ot)}})(n,c,p,f);break;case"heatmap":(function(b,L,E,H){if(E.paint.get("heatmap-opacity")!==0)if(b.renderPass==="offscreen"){let h=b.context,I=h.gl,_=Xi.disabled,F=new xi([I.ONE,I.ONE],o.aO.transparent,[!0,!0,!0,!0]);(function(R,Z,N){let P=R.gl;R.activeTexture.set(P.TEXTURE1),R.viewport.set([0,0,Z.width/4,Z.height/4]);let V=N.heatmapFbo;if(V)P.bindTexture(P.TEXTURE_2D,V.colorAttachment.get()),R.bindFramebuffer.set(V.framebuffer);else{let X=P.createTexture();P.bindTexture(P.TEXTURE_2D,X),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MIN_FILTER,P.LINEAR),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MAG_FILTER,P.LINEAR),V=N.heatmapFbo=R.createFramebuffer(Z.width/4,Z.height/4,!1,!1),function(J,ot,dt,ut){var Gt,Pt;let gt=J.gl,Ct=(Gt=J.HALF_FLOAT)!==null&&Gt!==void 0?Gt:gt.UNSIGNED_BYTE,ee=(Pt=J.RGBA16F)!==null&&Pt!==void 0?Pt:gt.RGBA;gt.texImage2D(gt.TEXTURE_2D,0,ee,ot.width/4,ot.height/4,0,gt.RGBA,Ct,null),ut.colorAttachment.set(dt)}(R,Z,X,V)}})(h,b,E),h.clear({color:o.aO.transparent});for(let R=0;R{let J=o.F();o.aN(J,0,N.width,N.height,0,0,1);let ot=N.context.gl;return{u_matrix:J,u_world:[ot.drawingBufferWidth,ot.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:P.paint.get("heatmap-opacity")}})(h,I),null,I.id,h.viewportBuffer,h.quadTriangleIndexBuffer,h.viewportSegments,I.paint,h.transform.zoom)}(b,E))})(n,c,p,f);break;case"line":(function(b,L,E,H){if(b.renderPass!=="translucent")return;let h=E.paint.get("line-opacity"),I=E.paint.get("line-width");if(h.constantOr(1)===0||I.constantOr(1)===0)return;let _=b.depthModeForSublayer(0,Ci.ReadOnly),F=b.colorModeForRenderPass(),R=E.paint.get("line-dasharray"),Z=E.paint.get("line-pattern"),N=Z.constantOr(1),P=E.paint.get("line-gradient"),V=E.getCrossfadeParameters(),X=N?"linePattern":R?"lineSDF":P?"lineGradient":"line",J=b.context,ot=J.gl,dt=!0;for(let ut of H){let Gt=L.getTile(ut);if(N&&!Gt.patternsLoaded())continue;let Pt=Gt.getBucket(E);if(!Pt)continue;let gt=Pt.programConfigurations.get(E.id),Ct=b.context.program.get(),ee=b.useProgram(X,gt),ge=dt||ee.program!==Ct,jt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(ut),Fe=Z.constantOr(null);if(Fe&&Gt.imageAtlas){let xe=Gt.imageAtlas,ci=xe.patternPositions[Fe.to.toString()],pi=xe.patternPositions[Fe.from.toString()];ci&&pi&>.setConstantPatternPositions(ci,pi)}let ke=jt?ut:null,Ye=N?ai(b,Gt,E,V,ke):R?dr(b,Gt,E,R,V,ke):P?nr(b,Gt,E,Pt.lineClipsArray.length,ke):Wi(b,Gt,E,ke);if(N)J.activeTexture.set(ot.TEXTURE0),Gt.imageAtlasTexture.bind(ot.LINEAR,ot.CLAMP_TO_EDGE),gt.updatePaintBuffers(V);else if(R&&(ge||b.lineAtlas.dirty))J.activeTexture.set(ot.TEXTURE0),b.lineAtlas.bind(J);else if(P){let xe=Pt.gradients[E.id],ci=xe.texture;if(E.gradientVersion!==xe.version){let pi=256;if(E.stepInterpolant){let Mi=L.getSource().maxzoom,Si=ut.canonical.z===Mi?Math.ceil(1<0?c.pop():null}isPatternMissing(n){if(!n)return!1;if(!n.from||!n.to)return!0;let c=this.imageManager.getPattern(n.from.toString()),p=this.imageManager.getPattern(n.to.toString());return!c||!p}useProgram(n,c){this.cache=this.cache||{};let p=n+(c?c.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[p]||(this.cache[p]=new ae(this.context,ct[n],c,el[n],this._showOverdrawInspector,this.style.map.terrain)),this.cache[p]}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(){let n=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(n.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new qt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:n,drawingBufferHeight:c}=this.context.gl;return this.width!==n||this.height!==c}}class ls{constructor(n,c){this.points=n,this.planes=c}static fromInvProjectionMatrix(n,c,p){let f=Math.pow(2,p),b=[[-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(E=>{let H=1/(E=o.af([],E,n))[3]/c*f;return o.a$(E,E,[H,H,1/E[3],H])}),L=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let H=function(F,R){var Z=R[0],N=R[1],P=R[2],V=Z*Z+N*N+P*P;return V>0&&(V=1/Math.sqrt(V)),F[0]=R[0]*V,F[1]=R[1]*V,F[2]=R[2]*V,F}([],function(F,R,Z){var N=R[0],P=R[1],V=R[2],X=Z[0],J=Z[1],ot=Z[2];return F[0]=P*ot-V*J,F[1]=V*X-N*ot,F[2]=N*J-P*X,F}([],Ft([],b[E[0]],b[E[1]]),Ft([],b[E[2]],b[E[1]]))),h=-((I=H)[0]*(_=b[E[1]])[0]+I[1]*_[1]+I[2]*_[2]);var I,_;return H.concat(h)});return new ls(b,L)}}class xn{constructor(n,c){this.min=n,this.max=c,this.center=function(p,f,b){return p[0]=.5*f[0],p[1]=.5*f[1],p[2]=.5*f[2],p}([],function(p,f,b){return p[0]=f[0]+b[0],p[1]=f[1]+b[1],p[2]=f[2]+b[2],p}([],this.min,this.max))}quadrant(n){let c=[n%2==0,n<2],p=Tt(this.min),f=Tt(this.max);for(let b=0;b=0&&L++;if(L===0)return 0;L!==c.length&&(p=!1)}if(p)return 2;for(let f=0;f<3;f++){let b=Number.MAX_VALUE,L=-Number.MAX_VALUE;for(let E=0;Ethis.max[f]-this.min[f])return 0}return 1}}class is{constructor(n=0,c=0,p=0,f=0){if(isNaN(n)||n<0||isNaN(c)||c<0||isNaN(p)||p<0||isNaN(f)||f<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=n,this.bottom=c,this.left=p,this.right=f}interpolate(n,c,p){return c.top!=null&&n.top!=null&&(this.top=o.z.number(n.top,c.top,p)),c.bottom!=null&&n.bottom!=null&&(this.bottom=o.z.number(n.bottom,c.bottom,p)),c.left!=null&&n.left!=null&&(this.left=o.z.number(n.left,c.left,p)),c.right!=null&&n.right!=null&&(this.right=o.z.number(n.right,c.right,p)),this}getCenter(n,c){let p=o.ac((this.left+n-this.right)/2,0,n),f=o.ac((this.top+c-this.bottom)/2,0,c);return new o.P(p,f)}equals(n){return this.top===n.top&&this.bottom===n.bottom&&this.left===n.left&&this.right===n.right}clone(){return new is(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let Eo=85.051129;class _s{constructor(n,c,p,f,b){this.tileSize=512,this._renderWorldCopies=b===void 0||!!b,this._minZoom=n||0,this._maxZoom=c||22,this._minPitch=p??0,this._maxPitch=f??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new is,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let n=new _s(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return n.apply(this),n}apply(n){this.tileSize=n.tileSize,this.latRange=n.latRange,this.width=n.width,this.height=n.height,this._center=n._center,this._elevation=n._elevation,this.minElevationForCurrentTile=n.minElevationForCurrentTile,this.zoom=n.zoom,this.angle=n.angle,this._fov=n._fov,this._pitch=n._pitch,this._unmodified=n._unmodified,this._edgeInsets=n._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(n){this._minZoom!==n&&(this._minZoom=n,this.zoom=Math.max(this.zoom,n))}get maxZoom(){return this._maxZoom}set maxZoom(n){this._maxZoom!==n&&(this._maxZoom=n,this.zoom=Math.min(this.zoom,n))}get minPitch(){return this._minPitch}set minPitch(n){this._minPitch!==n&&(this._minPitch=n,this.pitch=Math.max(this.pitch,n))}get maxPitch(){return this._maxPitch}set maxPitch(n){this._maxPitch!==n&&(this._maxPitch=n,this.pitch=Math.min(this.pitch,n))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(n){n===void 0?n=!0:n===null&&(n=!1),this._renderWorldCopies=n}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(n){let c=-o.b1(n,-180,180)*Math.PI/180;this.angle!==c&&(this._unmodified=!1,this.angle=c,this._calcMatrices(),this.rotationMatrix=function(){var p=new o.A(4);return o.A!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p}(),function(p,f,b){var L=f[0],E=f[1],H=f[2],h=f[3],I=Math.sin(b),_=Math.cos(b);p[0]=L*_+H*I,p[1]=E*_+h*I,p[2]=L*-I+H*_,p[3]=E*-I+h*_}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(n){let c=o.ac(n,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==c&&(this._unmodified=!1,this._pitch=c,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(n){n=Math.max(.01,Math.min(60,n)),this._fov!==n&&(this._unmodified=!1,this._fov=n/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(n){let c=Math.min(Math.max(n,this.minZoom),this.maxZoom);this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this.tileZoom=Math.max(0,Math.floor(c)),this.scale=this.zoomScale(c),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(n){n.lat===this._center.lat&&n.lng===this._center.lng||(this._unmodified=!1,this._center=n,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(n){n!==this._elevation&&(this._elevation=n,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(n){this._edgeInsets.equals(n)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,n,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(n){return this._edgeInsets.equals(n)}interpolatePadding(n,c,p){this._unmodified=!1,this._edgeInsets.interpolate(n,c,p),this._constrain(),this._calcMatrices()}coveringZoomLevel(n){let c=(n.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/n.tileSize));return Math.max(0,c)}getVisibleUnwrappedCoordinates(n){let c=[new o.b2(0,n)];if(this._renderWorldCopies){let p=this.pointCoordinate(new o.P(0,0)),f=this.pointCoordinate(new o.P(this.width,0)),b=this.pointCoordinate(new o.P(this.width,this.height)),L=this.pointCoordinate(new o.P(0,this.height)),E=Math.floor(Math.min(p.x,f.x,b.x,L.x)),H=Math.floor(Math.max(p.x,f.x,b.x,L.x)),h=1;for(let I=E-h;I<=H+h;I++)I!==0&&c.push(new o.b2(I,n))}return c}coveringTiles(n){var c,p;let f=this.coveringZoomLevel(n),b=f;if(n.minzoom!==void 0&&fn.maxzoom&&(f=n.maxzoom);let L=this.pointCoordinate(this.getCameraPoint()),E=o.Y.fromLngLat(this.center),H=Math.pow(2,f),h=[H*L.x,H*L.y,0],I=[H*E.x,H*E.y,0],_=ls.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,f),F=n.minzoom||0;!n.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(F=f);let R=n.terrain?2/Math.min(this.tileSize,n.tileSize)*this.tileSize:3,Z=J=>({aabb:new xn([J*H,0,0],[(J+1)*H,H,0]),zoom:0,x:0,y:0,wrap:J,fullyVisible:!1}),N=[],P=[],V=f,X=n.reparseOverscaled?b:f;if(this._renderWorldCopies)for(let J=1;J<=3;J++)N.push(Z(-J)),N.push(Z(J));for(N.push(Z(0));N.length>0;){let J=N.pop(),ot=J.x,dt=J.y,ut=J.fullyVisible;if(!ut){let ee=J.aabb.intersects(_);if(ee===0)continue;ut=ee===2}let Gt=n.terrain?h:I,Pt=J.aabb.distanceX(Gt),gt=J.aabb.distanceY(Gt),Ct=Math.max(Math.abs(Pt),Math.abs(gt));if(J.zoom===V||Ct>R+(1<=F){let ee=V-J.zoom,ge=h[0]-.5-(ot<>1),Fe=J.zoom+1,ke=J.aabb.quadrant(ee);if(n.terrain){let Ye=new o.Q(Fe,J.wrap,Fe,ge,jt),xe=n.terrain.getMinMaxElevation(Ye),ci=(c=xe.minElevation)!==null&&c!==void 0?c:this.elevation,pi=(p=xe.maxElevation)!==null&&p!==void 0?p:this.elevation;ke=new xn([ke.min[0],ke.min[1],ci],[ke.max[0],ke.max[1],pi])}N.push({aabb:ke,zoom:Fe,x:ge,y:jt,wrap:J.wrap,fullyVisible:ut})}}return P.sort((J,ot)=>J.distanceSq-ot.distanceSq).map(J=>J.tileID)}resize(n,c){this.width=n,this.height=c,this.pixelsToGLUnits=[2/n,-2/c],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(n){return Math.pow(2,n)}scaleZoom(n){return Math.log(n)/Math.LN2}project(n){let c=o.ac(n.lat,-85.051129,Eo);return new o.P(o.N(n.lng)*this.worldSize,o.O(c)*this.worldSize)}unproject(n){return new o.Y(n.x/this.worldSize,n.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(n){let c=this.elevation,p=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,f=this.pointLocation(this.centerPoint,n),b=n.getElevationForLngLatZoom(f,this.tileZoom);if(!(this.elevation-b))return;let L=p+c-b,E=Math.cos(this._pitch)*this.cameraToCenterDistance/L/o.b3(1,f.lat),H=this.scaleZoom(E/this.tileSize);this._elevation=b,this._center=f,this.zoom=H}setLocationAtPoint(n,c){let p=this.pointCoordinate(c),f=this.pointCoordinate(this.centerPoint),b=this.locationCoordinate(n),L=new o.Y(b.x-(p.x-f.x),b.y-(p.y-f.y));this.center=this.coordinateLocation(L),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(n,c){return c?this.coordinatePoint(this.locationCoordinate(n),c.getElevationForLngLatZoom(n,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(n))}pointLocation(n,c){return this.coordinateLocation(this.pointCoordinate(n,c))}locationCoordinate(n){return o.Y.fromLngLat(n)}coordinateLocation(n){return n&&n.toLngLat()}pointCoordinate(n,c){if(c){let F=c.pointCoordinate(n);if(F!=null)return F}let p=[n.x,n.y,0,1],f=[n.x,n.y,1,1];o.af(p,p,this.pixelMatrixInverse),o.af(f,f,this.pixelMatrixInverse);let b=p[3],L=f[3],E=p[1]/b,H=f[1]/L,h=p[2]/b,I=f[2]/L,_=h===I?0:(0-h)/(I-h);return new o.Y(o.z.number(p[0]/b,f[0]/L,_)/this.worldSize,o.z.number(E,H,_)/this.worldSize)}coordinatePoint(n,c=0,p=this.pixelMatrix){let f=[n.x*this.worldSize,n.y*this.worldSize,c,1];return o.af(f,f,p),new o.P(f[0]/f[3],f[1]/f[3])}getBounds(){let n=Math.max(0,this.height/2-this.getHorizon());return new Me().extend(this.pointLocation(new o.P(0,n))).extend(this.pointLocation(new o.P(this.width,n))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Me([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(n){n?(this.lngRange=[n.getWest(),n.getEast()],this.latRange=[n.getSouth(),n.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Eo])}calculatePosMatrix(n,c=!1){let p=n.key,f=c?this._alignedPosMatrixCache:this._posMatrixCache;if(f[p])return f[p];let b=n.canonical,L=this.worldSize/this.zoomScale(b.z),E=b.x+Math.pow(2,b.z)*n.wrap,H=o.an(new Float64Array(16));return o.H(H,H,[E*L,b.y*L,0]),o.J(H,H,[L/o.W,L/o.W,1]),o.K(H,c?this.alignedProjMatrix:this.projMatrix,H),f[p]=new Float32Array(H),f[p]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(n,c){c=o.ac(+c,this.minZoom,this.maxZoom);let p={center:new o.M(n.lng,n.lat),zoom:c},f=this.lngRange;if(!this._renderWorldCopies&&f===null){let J=179.9999999999;f=[-J,J]}let b=this.tileSize*this.zoomScale(p.zoom),L=0,E=b,H=0,h=b,I=0,_=0,{x:F,y:R}=this.size;if(this.latRange){let J=this.latRange;L=o.O(J[1])*b,E=o.O(J[0])*b,E-LE&&(V=E-J)}if(f){let J=(H+h)/2,ot=Z;this._renderWorldCopies&&(ot=o.b1(Z,J-b/2,J+b/2));let dt=F/2;ot-dth&&(P=h-dt)}if(P!==void 0||V!==void 0){let J=new o.P(P??Z,V??N);p.center=this.unproject.call({worldSize:b},J).wrap()}return p}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let n=this._unmodified,{center:c,zoom:p}=this.getConstrained(this.center,this.zoom);this.center=c,this.zoom=p,this._unmodified=n,this._constraining=!1}_calcMatrices(){if(!this.height)return;let n=this.centerOffset,c=this.point.x,p=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b3(1,this.center.lat)*this.worldSize;let f=o.an(new Float64Array(16));o.J(f,f,[this.width/2,-this.height/2,1]),o.H(f,f,[1,-1,0]),this.labelPlaneMatrix=f,f=o.an(new Float64Array(16)),o.J(f,f,[1,-1,1]),o.H(f,f,[-1,-1,0]),o.J(f,f,[2/this.width,2/this.height,1]),this.glCoordMatrix=f;let b=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),L=Math.min(this.elevation,this.minElevationForCurrentTile),E=b-L*this._pixelPerMeter/Math.cos(this._pitch),H=L<0?E:b,h=Math.PI/2+this._pitch,I=this._fov*(.5+n.y/this.height),_=Math.sin(I)*H/Math.sin(o.ac(Math.PI-h-I,.01,Math.PI-.01)),F=this.getHorizon(),R=2*Math.atan(F/this.cameraToCenterDistance)*(.5+n.y/(2*F)),Z=Math.sin(R)*H/Math.sin(o.ac(Math.PI-h-R,.01,Math.PI-.01)),N=Math.min(_,Z),P=1.01*(Math.cos(Math.PI/2-this._pitch)*N+H),V=this.height/50;f=new Float64Array(16),o.b4(f,this._fov,this.width/this.height,V,P),f[8]=2*-n.x/this.width,f[9]=2*n.y/this.height,o.J(f,f,[1,-1,1]),o.H(f,f,[0,0,-this.cameraToCenterDistance]),o.b5(f,f,this._pitch),o.ad(f,f,this.angle),o.H(f,f,[-c,-p,0]),this.mercatorMatrix=o.J([],f,[this.worldSize,this.worldSize,this.worldSize]),o.J(f,f,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.K(new Float64Array(16),this.labelPlaneMatrix,f),o.H(f,f,[0,0,-this.elevation]),this.projMatrix=f,this.invProjMatrix=o.ar([],f),this.pixelMatrix3D=o.K(new Float64Array(16),this.labelPlaneMatrix,f);let X=this.width%2/2,J=this.height%2/2,ot=Math.cos(this.angle),dt=Math.sin(this.angle),ut=c-Math.round(c)+ot*X+dt*J,Gt=p-Math.round(p)+ot*J+dt*X,Pt=new Float64Array(f);if(o.H(Pt,Pt,[ut>.5?ut-1:ut,Gt>.5?Gt-1:Gt,0]),this.alignedProjMatrix=Pt,f=o.ar(new Float64Array(16),this.pixelMatrix),!f)throw new Error("failed to invert matrix");this.pixelMatrixInverse=f,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let n=this.pointCoordinate(new o.P(0,0)),c=[n.x*this.worldSize,n.y*this.worldSize,0,1];return o.af(c,c,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let n=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,n))}getCameraQueryGeometry(n){let c=this.getCameraPoint();if(n.length===1)return[n[0],c];{let p=c.x,f=c.y,b=c.x,L=c.y;for(let E of n)p=Math.min(p,E.x),f=Math.min(f,E.y),b=Math.max(b,E.x),L=Math.max(L,E.y);return[new o.P(p,f),new o.P(b,f),new o.P(b,L),new o.P(p,L),new o.P(p,f)]}}lngLatToCameraDepth(n,c){let p=this.locationCoordinate(n),f=[p.x*this.worldSize,p.y*this.worldSize,c,1];return o.af(f,f,this.projMatrix),f[2]/f[3]}}function no(y,n){let c,p=!1,f=null,b=null,L=()=>{f=null,p&&(y.apply(b,c),f=setTimeout(L,n),p=!1)};return(...E)=>(p=!0,b=this,c=E,f||L(),f)}class ma{constructor(n){this._getCurrentHash=()=>{let c=window.location.hash.replace("#","");if(this._hashName){let p;return c.split("&").map(f=>f.split("=")).forEach(f=>{f[0]===this._hashName&&(p=f)}),(p&&p[1]||"").split("/")}return c.split("/")},this._onHashChange=()=>{let c=this._getCurrentHash();if(c.length>=3&&!c.some(p=>isNaN(p))){let p=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(c[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+c[2],+c[1]],zoom:+c[0],bearing:p,pitch:+(c[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let c=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,c)}catch{}},this._updateHash=no(this._updateHashUnthrottled,300),this._hashName=n&&encodeURIComponent(n)}addTo(n){return this._map=n,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(n){let c=this._map.getCenter(),p=Math.round(100*this._map.getZoom())/100,f=Math.ceil((p*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.pow(10,f),L=Math.round(c.lng*b)/b,E=Math.round(c.lat*b)/b,H=this._map.getBearing(),h=this._map.getPitch(),I="";if(I+=n?`/${L}/${E}/${p}`:`${p}/${E}/${L}`,(H||h)&&(I+="/"+Math.round(10*H)/10),h&&(I+=`/${Math.round(h)}`),this._hashName){let _=this._hashName,F=!1,R=window.location.hash.slice(1).split("&").map(Z=>{let N=Z.split("=")[0];return N===_?(F=!0,`${N}=${I}`):Z}).filter(Z=>Z);return F||R.push(`${_}=${I}`),`#${R.join("&")}`}return`#${I}`}}let fn={linearity:.3,easing:o.b6(0,0,.3,1)},Ha=o.e({deceleration:2500,maxSpeed:1400},fn),vA=o.e({deceleration:20,maxSpeed:1400},fn),ta=o.e({deceleration:1e3,maxSpeed:360},fn),Ms=o.e({deceleration:1e3,maxSpeed:90},fn);class To{constructor(n){this._map=n,this.clear()}clear(){this._inertiaBuffer=[]}record(n){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:v.now(),settings:n})}_drainInertiaBuffer(){let n=this._inertiaBuffer,c=v.now();for(;n.length>0&&c-n[0].time>160;)n.shift()}_onMoveEnd(n){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let c={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:b}of this._inertiaBuffer)c.zoom+=b.zoomDelta||0,c.bearing+=b.bearingDelta||0,c.pitch+=b.pitchDelta||0,b.panDelta&&c.pan._add(b.panDelta),b.around&&(c.around=b.around),b.pinchAround&&(c.pinchAround=b.pinchAround);let p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){let b=Qo(c.pan.mag(),p,o.e({},Ha,n||{}));f.offset=c.pan.mult(b.amount/c.pan.mag()),f.center=this._map.transform.center,so(f,b)}if(c.zoom){let b=Qo(c.zoom,p,vA);f.zoom=this._map.transform.zoom+b.amount,so(f,b)}if(c.bearing){let b=Qo(c.bearing,p,ta);f.bearing=this._map.transform.bearing+o.ac(b.amount,-179,179),so(f,b)}if(c.pitch){let b=Qo(c.pitch,p,Ms);f.pitch=this._map.transform.pitch+b.amount,so(f,b)}if(f.zoom||f.bearing){let b=c.pinchAround===void 0?c.around:c.pinchAround;f.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),o.e(f,{noMoveStart:!0})}}function so(y,n){(!y.duration||y.durationc.unproject(H)),E=b.reduce((H,h,I,_)=>H.add(h.div(_.length)),new o.P(0,0));super(n,{points:b,point:E,lngLats:L,lngLat:c.unproject(E),originalEvent:p}),this._defaultPrevented=!1}}class zn extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(n,c,p){super(n,{originalEvent:p}),this._defaultPrevented=!1}}class gn{constructor(n,c){this._map=n,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(n){return this._firePreventable(new zn(n.type,this._map,n))}mousedown(n,c){return this._mousedownPos=c,this._firePreventable(new Jr(n.type,this._map,n))}mouseup(n){this._map.fire(new Jr(n.type,this._map,n))}click(n,c){this._mousedownPos&&this._mousedownPos.dist(c)>=this._clickTolerance||this._map.fire(new Jr(n.type,this._map,n))}dblclick(n){return this._firePreventable(new Jr(n.type,this._map,n))}mouseover(n){this._map.fire(new Jr(n.type,this._map,n))}mouseout(n){this._map.fire(new Jr(n.type,this._map,n))}touchstart(n){return this._firePreventable(new xs(n.type,this._map,n))}touchmove(n){this._map.fire(new xs(n.type,this._map,n))}touchend(n){this._map.fire(new xs(n.type,this._map,n))}touchcancel(n){this._map.fire(new xs(n.type,this._map,n))}_firePreventable(n){if(this._map.fire(n),n.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Uo{constructor(n){this._map=n}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(n){this._map.fire(new Jr(n.type,this._map,n))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(n){this._delayContextMenu?this._contextMenuEvent=n:this._ignoreContextMenu||this._map.fire(new Jr(n.type,this._map,n)),this._map.listens("contextmenu")&&n.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{constructor(n){this._map=n}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(n){return this.transform.pointLocation(o.P.convert(n),this._map.terrain)}}class kr{constructor(n,c){this._map=n,this._tr=new pr(n),this._el=n.getCanvasContainer(),this._container=n.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(n,c){this.isEnabled()&&n.shiftKey&&n.button===0&&(x.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(n,c){if(!this._active)return;let p=c;if(this._lastPos.equals(p)||!this._box&&p.dist(this._startPos)b.fitScreenCoordinates(p,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",n)}keydown(n){this._active&&n.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",n))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(x.remove(this._box),this._box=null),x.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(n,c){return this._map.fire(new o.k(n,{originalEvent:c}))}}function en(y,n){if(y.length!==n.length)throw new Error(`The number of touches and points are not equal - touches ${y.length}, points ${n.length}`);let c={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=n.timeStamp),p.length===this.numTouches&&(this.centroid=function(f){let b=new o.P(0,0);for(let L of f)b._add(L);return b.div(f.length)}(c),this.touches=en(p,c)))}touchmove(n,c,p){if(this.aborted||!this.centroid)return;let f=en(p,c);for(let b in this.touches){let L=f[b];(!L||L.dist(this.touches[b])>30)&&(this.aborted=!0)}}touchend(n,c,p){if((!this.centroid||n.timeStamp-this.startTime>500)&&(this.aborted=!0),p.length===0){let f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class oo{constructor(n){this.singleTap=new yn(n),this.numTaps=n.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(n,c,p){this.singleTap.touchstart(n,c,p)}touchmove(n,c,p){this.singleTap.touchmove(n,c,p)}touchend(n,c,p){let f=this.singleTap.touchend(n,c,p);if(f){let b=n.timeStamp-this.lastTime<500,L=!this.lastTap||this.lastTap.dist(f)<30;if(b&&L||this.reset(),this.count++,this.lastTime=n.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class ea{constructor(n){this._tr=new pr(n),this._zoomIn=new oo({numTouches:1,numTaps:2}),this._zoomOut=new oo({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(n,c,p){this._zoomIn.touchstart(n,c,p),this._zoomOut.touchstart(n,c,p)}touchmove(n,c,p){this._zoomIn.touchmove(n,c,p),this._zoomOut.touchmove(n,c,p)}touchend(n,c,p){let f=this._zoomIn.touchend(n,c,p),b=this._zoomOut.touchend(n,c,p),L=this._tr;return f?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:L.zoom+1,around:L.unproject(f)},{originalEvent:n})}):b?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:L.zoom-1,around:L.unproject(b)},{originalEvent:n})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class cs{constructor(n){this._enabled=!!n.enable,this._moveStateManager=n.moveStateManager,this._clickTolerance=n.clickTolerance||1,this._moveFunction=n.move,this._activateOnStart=!!n.activateOnStart,n.assignEvents(this),this.reset()}reset(n){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(n)}_move(...n){let c=this._moveFunction(...n);if(c.bearingDelta||c.pitchDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(n,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(n)&&(this._moveStateManager.startMove(n),this._lastPoint=c.length?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(n,c){if(!this.isEnabled())return;let p=this._lastPoint;if(!p)return;if(n.preventDefault(),!this._moveStateManager.isValidMoveEvent(n))return void this.reset(n);let f=c.length?c[0]:c;return!this._moved&&f.dist(p){y.mousedown=y.dragStart,y.mousemoveWindow=y.dragMove,y.mouseup=y.dragEnd,y.contextmenu=function(n){n.preventDefault()}},Za=({enable:y,clickTolerance:n,bearingDegreesPerPixelMoved:c=.8})=>{let p=new si({checkCorrectEvent:f=>x.mouseButton(f)===0&&f.ctrlKey||x.mouseButton(f)===2});return new cs({clickTolerance:n,move:(f,b)=>({bearingDelta:(b.x-f.x)*c}),moveStateManager:p,enable:y,assignEvents:Ca})},Ul=({enable:y,clickTolerance:n,pitchDegreesPerPixelMoved:c=-.5})=>{let p=new si({checkCorrectEvent:f=>x.mouseButton(f)===0&&f.ctrlKey||x.mouseButton(f)===2});return new cs({clickTolerance:n,move:(f,b)=>({pitchDelta:(b.y-f.y)*c}),moveStateManager:p,enable:y,assignEvents:Ca})};class ei{constructor(n,c){this._clickTolerance=n.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(n,c,p){return this._calculateTransform(n,c,p)}touchmove(n,c,p){if(this._active&&!(p.length0&&(this._active=!0);let f=en(p,c),b=new o.P(0,0),L=new o.P(0,0),E=0;for(let h in f){let I=f[h],_=this._touches[h];_&&(b._add(I),L._add(I.sub(_)),E++,f[h]=I)}if(this._touches=f,EMath.abs(y.x)}class ol extends Pa{constructor(n){super(),this._currentTouchCount=0,this._map=n}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(n,c,p){super.touchstart(n,c,p),this._currentTouchCount=p.length}_start(n){this._lastPoints=n,Gl(n[0].sub(n[1]))&&(this._valid=!1)}_move(n,c,p){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let f=n[0].sub(this._lastPoints[0]),b=n[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(f,b,p.timeStamp),this._valid?(this._lastPoints=n,this._active=!0,{pitchDelta:(f.y+b.y)/2*-.5}):void 0}gestureBeginsVertically(n,c,p){if(this._valid!==void 0)return this._valid;let f=n.mag()>=2,b=c.mag()>=2;if(!f&&!b)return;if(!f||!b)return this._firstMove===void 0&&(this._firstMove=p),p-this._firstMove<100&&void 0;let L=n.y>0==c.y>0;return Gl(n)&&Gl(c)&&L}}let Go={panStep:100,bearingStep:15,pitchStep:10};class Hr{constructor(n){this._tr=new pr(n);let c=Go;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(n){if(n.altKey||n.ctrlKey||n.metaKey)return;let c=0,p=0,f=0,b=0,L=0;switch(n.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:n.shiftKey?p=-1:(n.preventDefault(),b=-1);break;case 39:n.shiftKey?p=1:(n.preventDefault(),b=1);break;case 38:n.shiftKey?f=1:(n.preventDefault(),L=-1);break;case 40:n.shiftKey?f=-1:(n.preventDefault(),L=1);break;default:return}return this._rotationDisabled&&(p=0,f=0),{cameraAnimation:E=>{let H=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:c?Math.round(H.zoom)+c*(n.shiftKey?2:1):H.zoom,bearing:H.bearing+p*this._bearingStep,pitch:H.pitch+f*this._pitchStep,offset:[-b*this._panStep,-L*this._panStep],center:H.center},{originalEvent:n})}}}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 al(y){return y*(2-y)}let _A=4.000244140625;class Al{constructor(n,c){this._onTimeout=p=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(p)},this._map=n,this._tr=new pr(n),this._triggerRenderFrame=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(n){this._defaultZoomRate=n}setWheelZoomRate(n){this._wheelZoomRate=n}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(n){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!n&&n.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(n){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!n[this._map.cooperativeGestures._bypassKey])return;let c=n.deltaMode===WheelEvent.DOM_DELTA_LINE?40*n.deltaY:n.deltaY,p=v.now(),f=p-(this._lastWheelEventTime||0);this._lastWheelEventTime=p,c!==0&&c%_A==0?this._type="wheel":c!==0&&Math.abs(c)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,n)):this._type||(this._type=Math.abs(f*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),n.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=n,this._delta-=c,this._active||this._start(n)),n.preventDefault()}_start(n){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);let c=x.mousePos(this._map.getCanvas(),n),p=this._tr;this._around=c.y>p.transform.height/2-p.transform.getHorizon()?o.M.convert(this._aroundCenter?p.center:p.unproject(c)):o.M.convert(p.center),this._aroundPoint=p.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let n=this._tr.transform;if(this._delta!==0){let E=this._type==="wheel"&&Math.abs(this._delta)>_A?this._wheelZoomRate:this._defaultZoomRate,H=2/(1+Math.exp(-Math.abs(this._delta*E)));this._delta<0&&H!==0&&(H=1/H);let h=typeof this._targetZoom=="number"?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(h*H))),this._type==="wheel"&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:n.zoom,p=this._startZoom,f=this._easing,b,L=!1;if(this._type==="wheel"&&p&&f){let E=Math.min((v.now()-this._lastWheelEventTime)/200,1),H=f(E);b=o.z.number(p,c,H),E<1?this._frameId||(this._frameId=!0):L=!0}else b=c,L=!0;return this._active=!0,L&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!L,zoomDelta:b-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(n){let c=o.b7;if(this._prevEase){let p=this._prevEase,f=(v.now()-p.start)/p.duration,b=p.easing(f+.01)-p.easing(f),L=.27/Math.sqrt(b*b+1e-4)*.01,E=Math.sqrt(.0729-L*L);c=o.b6(L,E,.25,1)}return this._prevEase={start:v.now(),duration:n,easing:c},c}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class xA{constructor(n,c){this._clickZoom=n,this._tapZoom=c}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 Rl{constructor(n){this._tr=new pr(n),this.reset()}reset(){this._active=!1}dblclick(n,c){return n.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:this._tr.zoom+(n.shiftKey?-1:1),around:this._tr.unproject(c)},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dh{constructor(){this._tap=new oo({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(n,c,p){if(!this._swipePoint)if(this._tapTime){let f=c[0],b=n.timeStamp-this._tapTime<500,L=this._tapPoint.dist(f)<30;b&&L?p.length>0&&(this._swipePoint=f,this._swipeTouch=p[0].identifier):this.reset()}else this._tap.touchstart(n,c,p)}touchmove(n,c,p){if(this._tapTime){if(this._swipePoint){if(p[0].identifier!==this._swipeTouch)return;let f=c[0],b=f.y-this._swipePoint.y;return this._swipePoint=f,n.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(n,c,p)}touchend(n,c,p){if(this._tapTime)this._swipePoint&&p.length===0&&this.reset();else{let f=this._tap.touchend(n,c,p);f&&(this._tapTime=n.timeStamp,this._tapPoint=f)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ao{constructor(n,c,p){this._el=n,this._mousePan=c,this._touchPan=p}enable(n){this._inertiaOptions=n||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class SA{constructor(n,c,p){this._pitchWithRotate=n.pitchWithRotate,this._mouseRotate=c,this._mousePitch=p}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 wi{constructor(n,c,p,f){this._el=n,this._touchZoom=c,this._touchRotate=p,this._tapDragZoom=f,this._rotationDisabled=!1,this._enabled=!0}enable(n){this._touchZoom.enable(n),this._rotationDisabled||this._touchRotate.enable(n),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Hi{constructor(n,c){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=n,this._options=c,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let n=this._map.getCanvasContainer();n.classList.add("maplibregl-cooperative-gestures"),this._container=x.create("div","maplibregl-cooperative-gesture-screen",n);let c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let p=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),f=document.createElement("div");f.className="maplibregl-desktop-message",f.textContent=c,this._container.appendChild(f);let b=document.createElement("div");b.className="maplibregl-mobile-message",b.textContent=p,this._container.appendChild(b),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(x.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destoryUI()}isEnabled(){return this._enabled}touchmove(n){this._onCooperativeGesture(n.touches.length===1)}wheel(n){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!n[this._bypassKey])}_onCooperativeGesture(n){this._enabled&&n&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let Na=y=>y.zoom||y.drag||y.pitch||y.rotate;class wc extends o.k{}function ll(y){return y.panDelta&&y.panDelta.mag()||y.zoomDelta||y.bearingDelta||y.pitchDelta}class Jn{constructor(n,c){this.handleWindowEvent=f=>{this.handleEvent(f,`${f.type}Window`)},this.handleEvent=(f,b)=>{if(f.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let L=f.type==="renderFrame"?void 0:f,E={needsRenderFrame:!1},H={},h={},I=f.touches,_=I?this._getMapTouches(I):void 0,F=_?x.touchPos(this._map.getCanvas(),_):x.mousePos(this._map.getCanvas(),f);for(let{handlerName:N,handler:P,allowed:V}of this._handlers){if(!P.isEnabled())continue;let X;this._blockedByActive(h,V,N)?P.reset():P[b||f.type]&&(X=P[b||f.type](f,F,_),this.mergeHandlerResult(E,H,X,N,L),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||P.isActive())&&(h[N]=P)}let R={};for(let N in this._previousActiveHandlers)h[N]||(R[N]=L);this._previousActiveHandlers=h,(Object.keys(R).length||ll(E))&&(this._changes.push([E,H,R]),this._triggerRenderFrame()),(Object.keys(h).length||ll(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:Z}=E;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))},this._map=n,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new To(n),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);let p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[window,"blur",void 0]];for(let[f,b,L]of this._listeners)x.addEventListener(f,b,f===document?this.handleWindowEvent:this.handleEvent,L)}destroy(){for(let[n,c,p]of this._listeners)x.removeEventListener(n,c,n===document?this.handleWindowEvent:this.handleEvent,p)}_addDefaultHandlers(n){let c=this._map,p=c.getCanvasContainer();this._add("mapEvent",new gn(c,n));let f=c.boxZoom=new kr(c,n);this._add("boxZoom",f),n.interactive&&n.boxZoom&&f.enable();let b=c.cooperativeGestures=new Hi(c,n.cooperativeGestures);this._add("cooperativeGestures",b),n.cooperativeGestures&&b.enable();let L=new ea(c),E=new Rl(c);c.doubleClickZoom=new xA(E,L),this._add("tapZoom",L),this._add("clickZoom",E),n.interactive&&n.doubleClickZoom&&c.doubleClickZoom.enable();let H=new dh;this._add("tapDragZoom",H);let h=c.touchPitch=new ol(c);this._add("touchPitch",h),n.interactive&&n.touchPitch&&c.touchPitch.enable(n.touchPitch);let I=Za(n),_=Ul(n);c.dragRotate=new SA(n,I,_),this._add("mouseRotate",I,["mousePitch"]),this._add("mousePitch",_,["mouseRotate"]),n.interactive&&n.dragRotate&&c.dragRotate.enable();let F=(({enable:X,clickTolerance:J})=>{let ot=new si({checkCorrectEvent:dt=>x.mouseButton(dt)===0&&!dt.ctrlKey});return new cs({clickTolerance:J,move:(dt,ut)=>({around:ut,panDelta:ut.sub(dt)}),activateOnStart:!0,moveStateManager:ot,enable:X,assignEvents:Ca})})(n),R=new ei(n,c);c.dragPan=new Ao(p,F,R),this._add("mousePan",F),this._add("touchPan",R,["touchZoom","touchRotate"]),n.interactive&&n.dragPan&&c.dragPan.enable(n.dragPan);let Z=new BA,N=new rs;c.touchZoomRotate=new wi(p,N,Z,H),this._add("touchRotate",Z,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),n.interactive&&n.touchZoomRotate&&c.touchZoomRotate.enable(n.touchZoomRotate);let P=c.scrollZoom=new Al(c,()=>this._triggerRenderFrame());this._add("scrollZoom",P,["mousePan"]),n.interactive&&n.scrollZoom&&c.scrollZoom.enable(n.scrollZoom);let V=c.keyboard=new Hr(c);this._add("keyboard",V),n.interactive&&n.keyboard&&c.keyboard.enable(),this._add("blockableMapEvent",new Uo(c))}_add(n,c,p){this._handlers.push({handlerName:n,handler:c,allowed:p}),this._handlersById[n]=c}stop(n){if(!this._updatingCamera){for(let{handler:c}of this._handlers)c.reset();this._inertia.clear(),this._fireEvents({},{},n),this._changes=[]}}isActive(){for(let{handler:n}of this._handlers)if(n.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Na(this._eventsInProgress))||this.isZooming()}_blockedByActive(n,c,p){for(let f in n)if(f!==p&&(!c||c.indexOf(f)<0))return!0;return!1}_getMapTouches(n){let c=[];for(let p of n)this._el.contains(p.target)&&c.push(p);return c}mergeHandlerResult(n,c,p,f,b){if(!p)return;o.e(n,p);let L={handlerName:f,originalEvent:p.originalEvent||b};p.zoomDelta!==void 0&&(c.zoom=L),p.panDelta!==void 0&&(c.drag=L),p.pitchDelta!==void 0&&(c.pitch=L),p.bearingDelta!==void 0&&(c.rotate=L)}_applyChanges(){let n={},c={},p={};for(let[f,b,L]of this._changes)f.panDelta&&(n.panDelta=(n.panDelta||new o.P(0,0))._add(f.panDelta)),f.zoomDelta&&(n.zoomDelta=(n.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(n.bearingDelta=(n.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(n.pitchDelta=(n.pitchDelta||0)+f.pitchDelta),f.around!==void 0&&(n.around=f.around),f.pinchAround!==void 0&&(n.pinchAround=f.pinchAround),f.noInertia&&(n.noInertia=f.noInertia),o.e(c,b),o.e(p,L);this._updateMapTransform(n,c,p),this._changes=[]}_updateMapTransform(n,c,p){let f=this._map,b=f._getTransformForUpdate(),L=f.terrain;if(!(ll(n)||L&&this._terrainMovement))return this._fireEvents(c,p,!0);let{panDelta:E,zoomDelta:H,bearingDelta:h,pitchDelta:I,around:_,pinchAround:F}=n;F!==void 0&&(_=F),f._stop(!0),_=_||f.transform.centerPoint;let R=b.pointLocation(E?_.sub(E):_);h&&(b.bearing+=h),I&&(b.pitch+=I),H&&(b.zoom+=H),L?this._terrainMovement||!c.drag&&!c.zoom?c.drag&&this._terrainMovement?b.center=b.pointLocation(b.centerPoint.sub(E)):b.setLocationAtPoint(R,_):(this._terrainMovement=!0,this._map._elevationFreeze=!0,b.setLocationAtPoint(R,_),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,b.recalculateZoom(f.terrain)})):b.setLocationAtPoint(R,_),f._applyUpdatedTransform(b),this._map._update(),n.noInertia||this._inertia.record(n),this._fireEvents(c,p,!0)}_fireEvents(n,c,p){let f=Na(this._eventsInProgress),b=Na(n),L={};for(let I in n){let{originalEvent:_}=n[I];this._eventsInProgress[I]||(L[`${I}start`]=_),this._eventsInProgress[I]=n[I]}!f&&b&&this._fireEvent("movestart",b.originalEvent);for(let I in L)this._fireEvent(I,L[I]);b&&this._fireEvent("move",b.originalEvent);for(let I in n){let{originalEvent:_}=n[I];this._fireEvent(I,_)}let E={},H;for(let I in this._eventsInProgress){let{handlerName:_,originalEvent:F}=this._eventsInProgress[I];this._handlersById[_].isActive()||(delete this._eventsInProgress[I],H=c[_]||F,E[`${I}end`]=H)}for(let I in E)this._fireEvent(I,E[I]);let h=Na(this._eventsInProgress);if(p&&(f||b)&&!h){this._updatingCamera=!0;let I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),_=F=>F!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new wc("renderFrame",{timeStamp:n})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Hl extends o.E{constructor(n,c){super(),this._renderFrameCallback=()=>{let p=Math.min((v.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(p)),p<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=c.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.M(this.transform.center.lng,this.transform.center.lat)}setCenter(n,c){return this.jumpTo({center:n},c)}panBy(n,c,p){return n=o.P.convert(n).mult(-1),this.panTo(this.transform.center,o.e({offset:n},c),p)}panTo(n,c,p){return this.easeTo(o.e({center:n},c),p)}getZoom(){return this.transform.zoom}setZoom(n,c){return this.jumpTo({zoom:n},c),this}zoomTo(n,c,p){return this.easeTo(o.e({zoom:n},c),p)}zoomIn(n,c){return this.zoomTo(this.getZoom()+1,n,c),this}zoomOut(n,c){return this.zoomTo(this.getZoom()-1,n,c),this}getBearing(){return this.transform.bearing}setBearing(n,c){return this.jumpTo({bearing:n},c),this}getPadding(){return this.transform.padding}setPadding(n,c){return this.jumpTo({padding:n},c),this}rotateTo(n,c,p){return this.easeTo(o.e({bearing:n},c),p)}resetNorth(n,c){return this.rotateTo(0,o.e({duration:1e3},n),c),this}resetNorthPitch(n,c){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},n),c),this}snapToNorth(n,c){return Math.abs(this.getBearing()){if(this._zooming&&(f.zoom=o.z.number(b,P,Gt)),this._rotating&&(f.bearing=o.z.number(L,h,Gt)),this._pitching&&(f.pitch=o.z.number(E,I,Gt)),this._padding&&(f.interpolatePadding(H,_,Gt),R=f.centerPoint.add(F)),this.terrain&&!n.freezeElevation&&this._updateElevation(Gt),ot)f.setLocationAtPoint(ot,dt);else{let Pt=f.zoomScale(f.zoom-b),gt=P>b?Math.min(2,J):Math.max(.5,J),Ct=Math.pow(gt,1-Gt),ee=f.unproject(V.add(X.mult(Gt*Ct)).mult(Pt));f.setLocationAtPoint(f.renderWorldCopies?ee.wrap():ee,R)}this._applyUpdatedTransform(f),this._fireMoveEvents(c)},Gt=>{this.terrain&&this._finalizeElevation(),this._afterEase(c,Gt)},n),this}_prepareEase(n,c,p={}){this._moving=!0,c||p.moving||this.fire(new o.k("movestart",n)),this._zooming&&!p.zooming&&this.fire(new o.k("zoomstart",n)),this._rotating&&!p.rotating&&this.fire(new o.k("rotatestart",n)),this._pitching&&!p.pitching&&this.fire(new o.k("pitchstart",n))}_prepareElevation(n){this._elevationCenter=n,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(n){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(n<1&&c!==this._elevationTarget){let p=this._elevationTarget-this._elevationStart;this._elevationStart+=n*(p-(c-(p*n+this._elevationStart))/(1-n)),this._elevationTarget=c}this.transform.elevation=o.z.number(this._elevationStart,this._elevationTarget,n)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(n){if(!this.transformCameraUpdate)return;let c=n.clone(),{center:p,zoom:f,pitch:b,bearing:L,elevation:E}=this.transformCameraUpdate(c);p&&(c.center=p),f!==void 0&&(c.zoom=f),b!==void 0&&(c.pitch=b),L!==void 0&&(c.bearing=L),E!==void 0&&(c.elevation=E),this.transform.apply(c)}_fireMoveEvents(n){this.fire(new o.k("move",n)),this._zooming&&this.fire(new o.k("zoom",n)),this._rotating&&this.fire(new o.k("rotate",n)),this._pitching&&this.fire(new o.k("pitch",n))}_afterEase(n,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;let p=this._zooming,f=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,p&&this.fire(new o.k("zoomend",n)),f&&this.fire(new o.k("rotateend",n)),b&&this.fire(new o.k("pitchend",n)),this.fire(new o.k("moveend",n))}flyTo(n,c){var p;if(!n.essential&&v.prefersReducedMotion){let Ye=o.L(n,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ye,c)}this.stop(),n=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b7},n);let f=this._getTransformForUpdate(),b=this.getZoom(),L=this.getBearing(),E=this.getPitch(),H=this.getPadding(),h="bearing"in n?this._normalizeBearing(n.bearing,L):L,I="pitch"in n?+n.pitch:E,_="padding"in n?n.padding:f.padding,F=o.P.convert(n.offset),R=f.centerPoint.add(F),Z=f.pointLocation(R),{center:N,zoom:P}=f.getConstrained(o.M.convert(n.center||Z),(p=n.zoom)!==null&&p!==void 0?p:b);this._normalizeCenter(N);let V=f.zoomScale(P-b),X=f.project(Z),J=f.project(N).sub(X),ot=n.curve,dt=Math.max(f.width,f.height),ut=dt/V,Gt=J.mag();if("minZoom"in n){let Ye=o.ac(Math.min(n.minZoom,b,P),f.minZoom,f.maxZoom),xe=dt/f.zoomScale(Ye-b);ot=Math.sqrt(xe/Gt*2)}let Pt=ot*ot;function gt(Ye){let xe=(ut*ut-dt*dt+(Ye?-1:1)*Pt*Pt*Gt*Gt)/(2*(Ye?ut:dt)*Pt*Gt);return Math.log(Math.sqrt(xe*xe+1)-xe)}function Ct(Ye){return(Math.exp(Ye)-Math.exp(-Ye))/2}function ee(Ye){return(Math.exp(Ye)+Math.exp(-Ye))/2}let ge=gt(!1),jt=function(Ye){return ee(ge)/ee(ge+ot*Ye)},Fe=function(Ye){return dt*((ee(ge)*(Ct(xe=ge+ot*Ye)/ee(xe))-Ct(ge))/Pt)/Gt;var xe},ke=(gt(!0)-ge)/ot;if(Math.abs(Gt)<1e-6||!isFinite(ke)){if(Math.abs(dt-ut)<1e-6)return this.easeTo(n,c);let Ye=utn.maxDuration&&(n.duration=0),this._zooming=!0,this._rotating=L!==h,this._pitching=I!==E,this._padding=!f.isPaddingEqual(_),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(N),this._ease(Ye=>{let xe=Ye*ke,ci=1/jt(xe);f.zoom=Ye===1?P:b+f.scaleZoom(ci),this._rotating&&(f.bearing=o.z.number(L,h,Ye)),this._pitching&&(f.pitch=o.z.number(E,I,Ye)),this._padding&&(f.interpolatePadding(H,_,Ye),R=f.centerPoint.add(F)),this.terrain&&!n.freezeElevation&&this._updateElevation(Ye);let pi=Ye===1?N:f.unproject(X.add(J.mult(Fe(xe))).mult(ci));f.setLocationAtPoint(f.renderWorldCopies?pi.wrap():pi,R),this._applyUpdatedTransform(f),this._fireMoveEvents(c)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(c)},n),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(n,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let p=this._onEaseEnd;delete this._onEaseEnd,p.call(this,c)}if(!n){let p=this.handlers;p&&p.stop(!1)}return this}_ease(n,c,p){p.animate===!1||p.duration===0?(n(1),c()):(this._easeStart=v.now(),this._easeOptions=p,this._onEaseFrame=n,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(n,c){n=o.b1(n,-180,180);let p=Math.abs(n-c);return Math.abs(n-360-c)180?-360:p<-180?360:0}queryTerrainElevation(n){return this.terrain?this.terrain.getElevationForLngLatZoom(o.M.convert(n),this.transform.tileZoom)-this.transform.elevation:null}}let ns={compact:!0,customAttribution:'MapLibre'};class ou{constructor(n=ns){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=c=>{!c||c.sourceDataType!=="metadata"&&c.sourceDataType!=="visibility"&&c.dataType!=="style"&&c.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=n}getDefaultPosition(){return"bottom-right"}onAdd(n){return this._map=n,this._compact=this.options.compact,this._container=x.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=x.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=x.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){x.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(n,c){let p=this._map._getUIString(`AttributionControl.${c}`);n.title=p,n.setAttribute("aria-label",p)}_updateAttributions(){if(!this._map.style)return;let n=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?n=n.concat(this.options.customAttribution.map(f=>typeof f!="string"?"":f)):typeof this.options.customAttribution=="string"&&n.push(this.options.customAttribution)),this._map.style.stylesheet){let f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}let c=this._map.style.sourceCaches;for(let f in c){let b=c[f];if(b.used||b.usedForTerrain){let L=b.getSource();L.attribution&&n.indexOf(L.attribution)<0&&n.push(L.attribution)}}n=n.filter(f=>String(f).trim()),n.sort((f,b)=>f.length-b.length),n=n.filter((f,b)=>{for(let L=b+1;L=0)return!1;return!0});let p=n.join(" | ");p!==this._attribHTML&&(this._attribHTML=p,n.length?(this._innerContainer.innerHTML=p,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class FA{constructor(n={}){this._updateCompact=()=>{let c=this._container.children;if(c.length){let p=c[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&p.classList.add("maplibregl-compact"):p.classList.remove("maplibregl-compact")}},this.options=n}getDefaultPosition(){return"bottom-left"}onAdd(n){this._map=n,this._compact=this.options&&this.options.compact,this._container=x.create("div","maplibregl-ctrl");let c=x.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){x.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Xr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(n){let c=++this._id;return this._queue.push({callback:n,id:c,cancelled:!1}),c}remove(n){let c=this._currentlyRunning,p=c?this._queue.concat(c):this._queue;for(let f of p)if(f.id===n)return void(f.cancelled=!0)}run(n=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let c=this._currentlyRunning=this._queue;this._queue=[];for(let p of c)if(!p.cancelled&&(p.callback(n),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var dn=o.X([{name:"a_pos3d",type:"Int16",components:3}]);class au extends o.E{constructor(n){super(),this.sourceCache=n,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,n.usedForTerrain=!0,n.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(n,c){this.sourceCache.update(n,c),this._renderableTilesKeys=[];let p={};for(let f of n.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c}))p[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.posMatrix=new Float64Array(16),o.aN(f.posMatrix,0,o.W,0,o.W,0,1),this._tiles[f.key]=new mi(f,this.tileSize));for(let f in this._tiles)p[f]||delete this._tiles[f]}freeRtt(n){for(let c in this._tiles){let p=this._tiles[c];(!n||p.tileID.equals(n)||p.tileID.isChildOf(n)||n.isChildOf(p.tileID))&&(p.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(n=>this.getTileByID(n))}getTileByID(n){return this._tiles[n]}getTerrainCoords(n){let c={};for(let p of this._renderableTilesKeys){let f=this._tiles[p].tileID;if(f.canonical.equals(n.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16),o.aN(b.posMatrix,0,o.W,0,o.W,0,1),c[p]=b}else if(f.canonical.isChildOf(n.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16);let L=f.canonical.z-n.canonical.z,E=f.canonical.x-(f.canonical.x>>L<>L<>L;o.aN(b.posMatrix,0,h,0,h,0,1),o.H(b.posMatrix,b.posMatrix,[-E*h,-H*h,0]),c[p]=b}else if(n.canonical.isChildOf(f.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16);let L=n.canonical.z-f.canonical.z,E=n.canonical.x-(n.canonical.x>>L<>L<>L;o.aN(b.posMatrix,0,o.W,0,o.W,0,1),o.H(b.posMatrix,b.posMatrix,[E*h,H*h,0]),o.J(b.posMatrix,b.posMatrix,[1/2**L,1/2**L,0]),c[p]=b}}return c}getSourceTile(n,c){let p=this.sourceCache._source,f=n.overscaledZ-this.deltaZoom;if(f>p.maxzoom&&(f=p.maxzoom),f=p.minzoom&&(!b||!b.dem);)b=this.sourceCache.getTileByID(n.scaledTo(f--).key);return b}tilesAfterTime(n=Date.now()){return Object.values(this._tiles).filter(c=>c.timeAdded>=n)}}class cl{constructor(n,c,p){this.painter=n,this.sourceCache=new au(c),this.options=p,this.exaggeration=typeof p.exaggeration=="number"?p.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(n,c,p,f=o.W){var b;if(!(c>=0&&c=0&&pn.canonical.z&&(n.canonical.z>=f?b=n.canonical.z-f:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let L=n.canonical.x-(n.canonical.x>>b<>b<>8<<4|b>>8,c[L+3]=0;let p=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new qt(n,p,n.gl.RGBA,{premultiply:!1});return f.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(n){this.painter.maybeDrawDepthAndCoords(!0);let c=new Uint8Array(4),p=this.painter.context,f=p.gl;p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(n.x,this.painter.height/devicePixelRatio-n.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),p.bindFramebuffer.set(null);let b=c[0]+(c[2]>>4<<8),L=c[1]+((15&c[2])<<8),E=this.coordsIndex[255-c[3]],H=E&&this.sourceCache.getTileByID(E);if(!H)return null;let h=this._coordsTextureSize,I=(1<n.id!==c),this._recentlyUsed.push(n.id)}stampObject(n){n.stamp=++this._stamp}getOrCreateFreeObject(){for(let c of this._recentlyUsed)if(!this._objects[c].inUse)return this._objects[c];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let n=this._createObject(this._objects.length);return this._objects.push(n),n}freeObject(n){n.inUse=!1}freeAllObjects(){for(let n of this._objects)this.freeObject(n)}isFull(){return!(this._objects.length!n.inUse)===!1}}let ss={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ss{constructor(n,c){this.painter=n,this.terrain=c,this.pool=new Zl(n.context,30,c.sourceCache.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(n){return this.pool.getObjectForId(n.rtt[this._stacks.length-1].id).texture}prepareForRender(n,c){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=n._order.filter(p=>!n._layers[p].isHidden(c)),this._coordsDescendingInv={};for(let p in n.sourceCaches){this._coordsDescendingInv[p]={};let f=n.sourceCaches[p].getVisibleCoordinates();for(let b of f){let L=this.terrain.sourceCache.getTerrainCoords(b);for(let E in L)this._coordsDescendingInv[p][E]||(this._coordsDescendingInv[p][E]=[]),this._coordsDescendingInv[p][E].push(L[E])}}this._coordsDescendingInvStr={};for(let p of n._order){let f=n._layers[p],b=f.source;if(ss[f.type]&&!this._coordsDescendingInvStr[b]){this._coordsDescendingInvStr[b]={};for(let L in this._coordsDescendingInv[b])this._coordsDescendingInvStr[b][L]=this._coordsDescendingInv[b][L].map(E=>E.key).sort().join()}}for(let p of this._renderableTiles)for(let f in this._coordsDescendingInvStr){let b=this._coordsDescendingInvStr[f][p.tileID.key];b&&b!==p.rttCoords[f]&&(p.rtt=[])}}renderLayer(n){if(n.isHidden(this.painter.transform.zoom))return!1;let c=n.type,p=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===n.id;if(ss[c]&&(this._prevType&&ss[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(n.id),!f))return!0;if(ss[this._prevType]||ss[c]&&f){this._prevType=c;let b=this._stacks.length-1,L=this._stacks[b]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(sl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[b]){let h=this.pool.getObjectForId(E.rtt[b].id);if(h.stamp===E.rtt[b].stamp){this.pool.useObject(h);continue}}let H=this.pool.getOrCreateFreeObject();this.pool.useObject(H),this.pool.stampObject(H),E.rtt[b]={id:H.id,stamp:H.stamp},p.context.bindFramebuffer.set(H.fbo.framebuffer),p.context.clear({color:o.aO.transparent,stencil:0}),p.currentStencilSource=void 0;for(let h=0;h{y.touchstart=y.dragStart,y.touchmoveWindow=y.dragMove,y.touchend=y.dragEnd},hs={showCompass:!0,showZoom:!0,visualizePitch:!1};class Bc{constructor(n,c,p=!1){this.mousedown=L=>{this.startMouse(o.e({},L,{ctrlKey:!0,preventDefault:()=>L.preventDefault()}),x.mousePos(this.element,L)),x.addEventListener(window,"mousemove",this.mousemove),x.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=L=>{this.moveMouse(L,x.mousePos(this.element,L))},this.mouseup=L=>{this.mouseRotate.dragEnd(L),this.mousePitch&&this.mousePitch.dragEnd(L),this.offTemp()},this.touchstart=L=>{L.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=x.touchPos(this.element,L.targetTouches)[0],this.startTouch(L,this._startPos),x.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.addEventListener(window,"touchend",this.touchend))},this.touchmove=L=>{L.targetTouches.length!==1?this.reset():(this._lastPos=x.touchPos(this.element,L.targetTouches)[0],this.moveTouch(L,this._lastPos))},this.touchend=L=>{L.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;let f=n.dragRotate._mouseRotate.getClickTolerance(),b=n.dragRotate._mousePitch.getClickTolerance();this.element=c,this.mouseRotate=Za({clickTolerance:f,enable:!0}),this.touchRotate=(({enable:L,clickTolerance:E,bearingDegreesPerPixelMoved:H=.8})=>{let h=new Ql;return new cs({clickTolerance:E,move:(I,_)=>({bearingDelta:(_.x-I.x)*H}),moveStateManager:h,enable:L,assignEvents:co})})({clickTolerance:f,enable:!0}),this.map=n,p&&(this.mousePitch=Ul({clickTolerance:b,enable:!0}),this.touchPitch=(({enable:L,clickTolerance:E,pitchDegreesPerPixelMoved:H=-.5})=>{let h=new Ql;return new cs({clickTolerance:E,move:(I,_)=>({pitchDelta:(_.y-I.y)*H}),moveStateManager:h,enable:L,assignEvents:co})})({clickTolerance:b,enable:!0})),x.addEventListener(c,"mousedown",this.mousedown),x.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),x.addEventListener(c,"touchcancel",this.reset)}startMouse(n,c){this.mouseRotate.dragStart(n,c),this.mousePitch&&this.mousePitch.dragStart(n,c),x.disableDrag()}startTouch(n,c){this.touchRotate.dragStart(n,c),this.touchPitch&&this.touchPitch.dragStart(n,c),x.disableDrag()}moveMouse(n,c){let p=this.map,{bearingDelta:f}=this.mouseRotate.dragMove(n,c)||{};if(f&&p.setBearing(p.getBearing()+f),this.mousePitch){let{pitchDelta:b}=this.mousePitch.dragMove(n,c)||{};b&&p.setPitch(p.getPitch()+b)}}moveTouch(n,c){let p=this.map,{bearingDelta:f}=this.touchRotate.dragMove(n,c)||{};if(f&&p.setBearing(p.getBearing()+f),this.touchPitch){let{pitchDelta:b}=this.touchPitch.dragMove(n,c)||{};b&&p.setPitch(p.getPitch()+b)}}off(){let n=this.element;x.removeEventListener(n,"mousedown",this.mousedown),x.removeEventListener(n,"touchstart",this.touchstart,{passive:!1}),x.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.removeEventListener(window,"touchend",this.touchend),x.removeEventListener(n,"touchcancel",this.reset),this.offTemp()}offTemp(){x.enableDrag(),x.removeEventListener(window,"mousemove",this.mousemove),x.removeEventListener(window,"mouseup",this.mouseup),x.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.removeEventListener(window,"touchend",this.touchend)}}let ia;function hl(y,n,c){let p=new o.M(y.lng,y.lat);if(y=new o.M(y.lng,y.lat),n){let f=new o.M(y.lng-360,y.lat),b=new o.M(y.lng+360,y.lat),L=c.locationPoint(y).distSqr(n);c.locationPoint(f).distSqr(n)180;){let f=c.locationPoint(y);if(f.x>=0&&f.y>=0&&f.x<=c.width&&f.y<=c.height)break;y.lng>c.center.lng?y.lng-=360:y.lng+=360}return y.lng!==p.lng&&c.locationPoint(y).y>c.height/2-c.getHorizon()?y:p}let kA={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 gl(y,n,c){let p=y.classList;for(let f in kA)p.remove(`maplibregl-${c}-anchor-${f}`);p.add(`maplibregl-${c}-anchor-${n}`)}class Va extends o.E{constructor(n){if(super(),this._onKeyPress=c=>{let p=c.code,f=c.charCode||c.keyCode;p!=="Space"&&p!=="Enter"&&f!==32&&f!==13||this.togglePopup()},this._onMapClick=c=>{let p=c.originalEvent.target,f=this._element;this._popup&&(p===f||f.contains(p))&&this.togglePopup()},this._update=c=>{var p;if(!this._map)return;let f=this._map.loaded()&&!this._map.isMoving();(c?.type==="terrain"||c?.type==="render"&&!f)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?hl(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let b="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?b=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(b=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let L="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?L="rotateX(0deg)":this._pitchAlignment==="map"&&(L=`rotateX(${this._map.getPitch()}deg)`),c&&c.type!=="moveend"||(this._pos=this._pos.round()),x.setTransform(this._element,`${kA[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${L} ${b}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(c&&c.type==="moveend")}).catch(()=>{})},this._onMove=c=>{if(!this._isDragging){let p=this._clickTolerance||this._map._clickTolerance;this._isDragging=c.point.dist(this._pointerdownPos)>=p}this._isDragging&&(this._pos=c.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new o.k("dragstart"))),this.fire(new o.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new o.k("dragend")),this._state="inactive"},this._addDragHandler=c=>{this._element.contains(c.originalEvent.target)&&(c.preventDefault(),this._positionDelta=c.point.sub(this._pos).add(this._offset),this._pointerdownPos=c.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._scale=n&&n.scale||1,this._draggable=n&&n.draggable||!1,this._clickTolerance=n&&n.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=n&&n.rotation||0,this._rotationAlignment=n&&n.rotationAlignment||"auto",this._pitchAlignment=n&&n.pitchAlignment&&n.pitchAlignment!=="auto"?n.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(n?.opacity,n?.opacityWhenCovered),n&&n.element)this._element=n.element,this._offset=o.P.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=x.create("div"),this._element.setAttribute("aria-label","Map marker");let c=x.createNS("http://www.w3.org/2000/svg","svg"),p=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${p}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${p}`);let b=x.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"stroke","none"),b.setAttributeNS(null,"stroke-width","1"),b.setAttributeNS(null,"fill","none"),b.setAttributeNS(null,"fill-rule","evenodd");let L=x.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"fill-rule","nonzero");let E=x.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let H=[{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(let V of H){let X=x.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",V.rx),X.setAttributeNS(null,"ry",V.ry),E.appendChild(X)}let h=x.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);let I=x.createNS("http://www.w3.org/2000/svg","path");I.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"),h.appendChild(I);let _=x.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"fill","#000000");let F=x.createNS("http://www.w3.org/2000/svg","path");F.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"),_.appendChild(F);let R=x.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(6.0, 7.0)"),R.setAttributeNS(null,"fill","#FFFFFF");let Z=x.createNS("http://www.w3.org/2000/svg","g");Z.setAttributeNS(null,"transform","translate(8.0, 8.0)");let N=x.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");let P=x.createNS("http://www.w3.org/2000/svg","circle");P.setAttributeNS(null,"fill","#FFFFFF"),P.setAttributeNS(null,"cx","5.5"),P.setAttributeNS(null,"cy","5.5"),P.setAttributeNS(null,"r","5.4999962"),Z.appendChild(N),Z.appendChild(P),L.appendChild(E),L.appendChild(h),L.appendChild(_),L.appendChild(R),L.appendChild(Z),c.appendChild(L),c.setAttributeNS(null,"height",p*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=o.P.convert(n&&n.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",c=>{c.preventDefault()}),this._element.addEventListener("mousedown",c=>{c.preventDefault()}),gl(this._element,this._anchor,"marker"),n&&n.className)for(let c of n.className.split(" "))this._element.classList.add(c);this._popup=null}addTo(n){return this.remove(),this._map=n,n.getCanvasContainer().appendChild(this._element),n.on("move",this._update),n.on("moveend",this._update),n.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("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),x.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(n){return this._lngLat=o.M.convert(n),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(n){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),n){if(!("offset"in n.options)){let f=Math.abs(13.5)/Math.SQRT2;n.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=n,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){let n=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:n?(n.isOpen()?n.remove():(n.setLngLat(this._lngLat),n.addTo(this._map)),this):this}_updateOpacity(n=!1){var c,p;if(!(!((c=this._map)===null||c===void 0)&&c.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(n)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let f=this._map,b=f.terrain.depthAtPoint(this._pos),L=f.terrain.getElevationForLngLatZoom(this._lngLat,f.transform.tileZoom);if(f.transform.lngLatToCameraDepth(this._lngLat,L)-b<.006)return void(this._element.style.opacity=this._opacity);let E=-this._offset.y/f.transform._pixelPerMeter,H=Math.sin(f.getPitch()*Math.PI/180)*E,h=f.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),I=f.transform.lngLatToCameraDepth(this._lngLat,L+H)-h>.006;((p=this._popup)===null||p===void 0?void 0:p.isOpen())&&I&&this._popup.remove(),this._element.style.opacity=I?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(n){return this._offset=o.P.convert(n),this._update(),this}addClassName(n){this._element.classList.add(n)}removeClassName(n){this._element.classList.remove(n)}toggleClassName(n){return this._element.classList.toggle(n)}setDraggable(n){return this._draggable=!!n,this._map&&(n?(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(n){return this._rotation=n||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(n){return this._rotationAlignment=n||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(n){return this._pitchAlignment=n&&n!=="auto"?n:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(n,c){return n===void 0&&c===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),n!==void 0&&(this._opacity=n),c!==void 0&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}let _c={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},ra=0,uo=!1,Da={maxWidth:100,unit:"metric"};function LA(y,n,c){let p=c&&c.maxWidth||100,f=y._container.clientHeight/2,b=y.unproject([0,f]),L=y.unproject([p,f]),E=b.distanceTo(L);if(c&&c.unit==="imperial"){let H=3.2808*E;H>5280?Ia(n,p,H/5280,y._getUIString("ScaleControl.Miles")):Ia(n,p,H,y._getUIString("ScaleControl.Feet"))}else c&&c.unit==="nautical"?Ia(n,p,E/1852,y._getUIString("ScaleControl.NauticalMiles")):E>=1e3?Ia(n,p,E/1e3,y._getUIString("ScaleControl.Kilometers")):Ia(n,p,E,y._getUIString("ScaleControl.Meters"))}function Ia(y,n,c,p){let f=function(b){let L=Math.pow(10,`${Math.floor(b)}`.length-1),E=b/L;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(H){let h=Math.pow(10,Math.ceil(-Math.log(H)/Math.LN10));return Math.round(H*h)/h}(E),L*E}(c);y.style.width=n*(f/c)+"px",y.innerHTML=`${f} ${p}`}let xc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ml=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Sc(y){if(y){if(typeof y=="number"){let n=Math.round(Math.abs(y)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,y),"top-left":new o.P(n,n),"top-right":new o.P(-n,n),bottom:new o.P(0,-y),"bottom-left":new o.P(n,-n),"bottom-right":new o.P(-n,-n),left:new o.P(y,0),right:new o.P(-y,0)}}if(y instanceof o.P||Array.isArray(y)){let n=o.P.convert(y);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:o.P.convert(y.center||[0,0]),top:o.P.convert(y.top||[0,0]),"top-left":o.P.convert(y["top-left"]||[0,0]),"top-right":o.P.convert(y["top-right"]||[0,0]),bottom:o.P.convert(y.bottom||[0,0]),"bottom-left":o.P.convert(y["bottom-left"]||[0,0]),"bottom-right":o.P.convert(y["bottom-right"]||[0,0]),left:o.P.convert(y.left||[0,0]),right:o.P.convert(y.right||[0,0])}}return Sc(new o.P(0,0))}let Au=g;A.AJAXError=o.be,A.Evented=o.E,A.LngLat=o.M,A.MercatorCoordinate=o.Y,A.Point=o.P,A.addProtocol=o.bf,A.config=o.a,A.removeProtocol=o.bg,A.AttributionControl=ou,A.BoxZoomHandler=kr,A.CanvasSource=ze,A.CooperativeGesturesHandler=Hi,A.DoubleClickZoomHandler=xA,A.DragPanHandler=Ao,A.DragRotateHandler=SA,A.EdgeInsets=is,A.FullscreenControl=class extends o.E{constructor(y={}){super(),this._onFullscreenChange=()=>{var n;let c=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((n=c?.shadowRoot)===null||n===void 0)&&n.fullscreenElement;)c=c.shadowRoot.fullscreenElement;c===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,y&&y.container&&(y.container instanceof HTMLElement?this._container=y.container:o.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(y){return this._map=y,this._container||(this._container=this._map.getContainer()),this._controlContainer=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){x.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let y=this._fullscreenButton=x.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);x.create("span","maplibregl-ctrl-icon",y).setAttribute("aria-hidden","true"),y.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let y=this._getTitle();this._fullscreenButton.setAttribute("aria-label",y),this._fullscreenButton.title=y}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},A.GeoJSONSource=Ue,A.GeolocateControl=class extends o.E{constructor(y){super(),this._onSuccess=n=>{if(this._map){if(this._isOutOfMapMaxBounds(n))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",n)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=n,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(n),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(n),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",n)),this._finish()}},this._updateCamera=n=>{let c=new o.M(n.coords.longitude,n.coords.latitude),p=n.coords.accuracy,f=this._map.getBearing(),b=o.e({bearing:f},this.options.fitBoundsOptions),L=Me.fromLngLat(c,p);this._map.fitBounds(L,b,{geolocateSource:!0})},this._updateMarker=n=>{if(n){let c=new o.M(n.coords.longitude,n.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=n.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=n=>{if(this._map){if(this.options.trackUserLocation)if(n.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(n.code===3&&uo)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",n)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=n=>{if(this._map){if(this._container.addEventListener("contextmenu",c=>c.preventDefault()),this._geolocateButton=x.create("button","maplibregl-ctrl-geolocate",this._container),x.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",n===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}else{let c=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=x.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Va({element:this._dotElement}),this._circleElement=x.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Va({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",c=>{c.geolocateSource||this._watchState!=="ACTIVE_LOCK"||c.originalEvent&&c.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new o.k("trackuserlocationend")))})}},this.options=o.e({},_c,y)}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(){return o._(this,arguments,void 0,function*(n=!1){if(ia!==void 0&&!n)return ia;if(window.navigator.permissions===void 0)return ia=!!window.navigator.geolocation,ia;try{ia=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{ia=!!window.navigator.geolocation}return ia})}().then(n=>this._setupUI(n)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),x.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,ra=0,uo=!1}_isOutOfMapMaxBounds(y){let n=this._map.getMaxBounds(),c=y.coords;return n&&(c.longituden.getEast()||c.latituden.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let y=this._map.getBounds(),n=y.getSouthEast(),c=y.getNorthEast(),p=n.distanceTo(c),f=Math.ceil(this._accuracy/(p/this._map._container.clientHeight)*2);this._circleElement.style.width=`${f}px`,this._circleElement.style.height=`${f}px`}trigger(){if(!this._setup)return o.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ra--,uo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new o.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new o.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let y;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ra++,ra>1?(y={maximumAge:6e5,timeout:0},uo=!0):(y=this.options.positionOptions,uo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,y)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},A.Hash=ma,A.ImageSource=Ne,A.KeyboardHandler=Hr,A.LngLatBounds=Me,A.LogoControl=FA,A.Map=class extends Hl{constructor(y){if(o.bc.mark(o.bd.create),(y=o.e({},Pl,y)).minZoom!=null&&y.maxZoom!=null&&y.minZoom>y.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(y.minPitch!=null&&y.maxPitch!=null&&y.minPitch>y.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(y.minPitch!=null&&y.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(y.maxPitch!=null&&y.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new _s(y.minZoom,y.maxZoom,y.minPitch,y.maxPitch,y.renderWorldCopies),{bearingSnap:y.bearingSnap}),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=y.interactive,this._maxTileCacheSize=y.maxTileCacheSize,this._maxTileCacheZoomLevels=y.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=y.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=y.preserveDrawingBuffer,this._antialias=y.antialias,this._trackResize=y.trackResize,this._bearingSnap=y.bearingSnap,this._refreshExpiredTiles=y.refreshExpiredTiles,this._fadeDuration=y.fadeDuration,this._crossSourceCollisions=y.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=y.collectResourceTiming,this._renderTaskQueue=new Xr,this._controls=[],this._mapId=o.a3(),this._locale=o.e({},lo,y.locale),this._clickTolerance=y.clickTolerance,this._overridePixelRatio=y.pixelRatio,this._maxCanvasSize=y.maxCanvasSize,this.transformCameraUpdate=y.transformCameraUpdate,this._imageQueueHandle=O.addThrottleControl(()=>this.isMoving()),this._requestManager=new at(y.transformRequest),typeof y.container=="string"){if(this._container=document.getElementById(y.container),!this._container)throw new Error(`Container '${y.container}' not found.`)}else{if(!(y.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=y.container}if(y.maxBounds&&this.setMaxBounds(y.maxBounds),this._setupContainer(),this._setupPainter(),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)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1,c=no(p=>{this._trackResize&&!this._removed&&this.resize(p)._update()},50);this._resizeObserver=new ResizeObserver(p=>{n?c(p):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jn(this,y),this._hash=y.hash&&new ma(typeof y.hash=="string"&&y.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:y.center,zoom:y.zoom,bearing:y.bearing,pitch:y.pitch}),y.bounds&&(this.resize(),this.fitBounds(y.bounds,o.e({},y.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=y.localIdeographFontFamily,this._validateStyle=y.validateStyle,y.style&&this.setStyle(y.style,{localIdeographFontFamily:y.localIdeographFontFamily}),y.attributionControl&&this.addControl(new ou(typeof y.attributionControl=="boolean"?void 0:y.attributionControl)),y.maplibreLogo&&this.addControl(new FA,y.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new o.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new o.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new o.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(y,n){if(n===void 0&&(n=y.getDefaultPosition?y.getDefaultPosition():"top-right"),!y||!y.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let c=y.onAdd(this);this._controls.push(y);let p=this._controlPositions[n];return n.indexOf("bottom")!==-1?p.insertBefore(c,p.firstChild):p.appendChild(c),this}removeControl(y){if(!y||!y.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let n=this._controls.indexOf(y);return n>-1&&this._controls.splice(n,1),y.onRemove(this),this}hasControl(y){return this._controls.indexOf(y)>-1}calculateCameraOptionsFromTo(y,n,c,p){return p==null&&this.terrain&&(p=this.terrain.getElevationForLngLatZoom(c,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(y,n,c,p)}resize(y){var n;let c=this._containerDimensions(),p=c[0],f=c[1],b=this._getClampedPixelRatio(p,f);if(this._resizeCanvas(p,f,b),this.painter.resize(p,f,b),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let H=this._getClampedPixelRatio(p,f);this._resizeCanvas(p,f,H),this.painter.resize(p,f,H)}this.transform.resize(p,f),(n=this._requestedCameraState)===null||n===void 0||n.resize(p,f);let L=!this._moving;return L&&(this.stop(),this.fire(new o.k("movestart",y)).fire(new o.k("move",y))),this.fire(new o.k("resize",y)),L&&this.fire(new o.k("moveend",y)),this}_getClampedPixelRatio(y,n){let{0:c,1:p}=this._maxCanvasSize,f=this.getPixelRatio(),b=y*f,L=n*f;return Math.min(b>c?c/b:1,L>p?p/L:1)*f}getPixelRatio(){var y;return(y=this._overridePixelRatio)!==null&&y!==void 0?y:devicePixelRatio}setPixelRatio(y){this._overridePixelRatio=y,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(y){return this.transform.setMaxBounds(Me.convert(y)),this._update()}setMinZoom(y){if((y=y??-2)>=-2&&y<=this.transform.maxZoom)return this.transform.minZoom=y,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=y,this._update(),this.getZoom()>y&&this.setZoom(y),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(y){if((y=y??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(y>=0&&y<=this.transform.maxPitch)return this.transform.minPitch=y,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(y>=this.transform.minPitch)return this.transform.maxPitch=y,this._update(),this.getPitch()>y&&this.setPitch(y),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(y){return this.transform.renderWorldCopies=y,this._update()}project(y){return this.transform.locationPoint(o.M.convert(y),this.style&&this.terrain)}unproject(y){return this.transform.pointLocation(o.P.convert(y),this.terrain)}isMoving(){var y;return this._moving||((y=this.handlers)===null||y===void 0?void 0:y.isMoving())}isZooming(){var y;return this._zooming||((y=this.handlers)===null||y===void 0?void 0:y.isZooming())}isRotating(){var y;return this._rotating||((y=this.handlers)===null||y===void 0?void 0:y.isRotating())}_createDelegatedListener(y,n,c){if(y==="mouseenter"||y==="mouseover"){let p=!1;return{layer:n,listener:c,delegates:{mousemove:b=>{let L=this.getLayer(n)?this.queryRenderedFeatures(b.point,{layers:[n]}):[];L.length?p||(p=!0,c.call(this,new Jr(y,this,b.originalEvent,{features:L}))):p=!1},mouseout:()=>{p=!1}}}}if(y==="mouseleave"||y==="mouseout"){let p=!1;return{layer:n,listener:c,delegates:{mousemove:L=>{(this.getLayer(n)?this.queryRenderedFeatures(L.point,{layers:[n]}):[]).length?p=!0:p&&(p=!1,c.call(this,new Jr(y,this,L.originalEvent)))},mouseout:L=>{p&&(p=!1,c.call(this,new Jr(y,this,L.originalEvent)))}}}}{let p=f=>{let b=this.getLayer(n)?this.queryRenderedFeatures(f.point,{layers:[n]}):[];b.length&&(f.features=b,c.call(this,f),delete f.features)};return{layer:n,listener:c,delegates:{[y]:p}}}}on(y,n,c){if(c===void 0)return super.on(y,n);let p=this._createDelegatedListener(y,n,c);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[y]=this._delegatedListeners[y]||[],this._delegatedListeners[y].push(p);for(let f in p.delegates)this.on(f,p.delegates[f]);return this}once(y,n,c){if(c===void 0)return super.once(y,n);let p=this._createDelegatedListener(y,n,c);for(let f in p.delegates)this.once(f,p.delegates[f]);return this}off(y,n,c){return c===void 0?super.off(y,n):(this._delegatedListeners&&this._delegatedListeners[y]&&(p=>{let f=this._delegatedListeners[y];for(let b=0;bthis._updateStyle(y,n));let c=this.style&&n.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!y)),y?(this.style=new to(this,n||{}),this.style.setEventedParent(this,{style:this.style}),typeof y=="string"?this.style.loadURL(y,n,c):this.style.loadJSON(y,n,c),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new to(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(y,n){if(typeof y=="string"){let c=this._requestManager.transformRequest(y,tt.Style);o.h(c,new AbortController).then(p=>{this._updateDiff(p.data,n)}).catch(p=>{p&&this.fire(new o.j(p))})}else typeof y=="object"&&this._updateDiff(y,n)}_updateDiff(y,n){try{this.style.setState(y,n)&&this._update(!0)}catch(c){o.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(y,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(y,n){return this._lazyInitEmptyStyle(),this.style.addSource(y,n),this._update(!0)}isSourceLoaded(y){let n=this.style&&this.style.sourceCaches[y];if(n!==void 0)return n.loaded();this.fire(new o.j(new Error(`There is no source with ID '${y}'`)))}setTerrain(y){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),y){let n=this.style.sourceCaches[y.source];if(!n)throw new Error(`cannot load terrain, because there exists no source with ID: ${y.source}`);this.terrain===null&&n.reload();for(let c in this.style._layers){let p=this.style._layers[c];p.type==="hillshade"&&p.source===y.source&&o.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new cl(this.painter,n,y),this.painter.renderToTexture=new Ss(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=c=>{c.dataType==="style"?this.terrain.sourceCache.freeRtt():c.dataType==="source"&&c.tile&&(c.sourceId!==y.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(c.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new o.k("terrain",{terrain:y})),this}getTerrain(){var y,n;return(n=(y=this.terrain)===null||y===void 0?void 0:y.options)!==null&&n!==void 0?n:null}areTilesLoaded(){let y=this.style&&this.style.sourceCaches;for(let n in y){let c=y[n]._tiles;for(let p in c){let f=c[p];if(f.state!=="loaded"&&f.state!=="errored")return!1}}return!0}removeSource(y){return this.style.removeSource(y),this._update(!0)}getSource(y){return this.style.getSource(y)}addImage(y,n,c={}){let{pixelRatio:p=1,sdf:f=!1,stretchX:b,stretchY:L,content:E}=c;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||o.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{let{width:H,height:h,data:I}=n,_=n;return this.style.addImage(y,{data:new o.R({width:H,height:h},new Uint8Array(I)),pixelRatio:p,stretchX:b,stretchY:L,content:E,sdf:f,version:0,userImage:_}),_.onAdd&&_.onAdd(this,y),this}}{let{width:H,height:h,data:I}=v.getImageData(n);this.style.addImage(y,{data:new o.R({width:H,height:h},I),pixelRatio:p,stretchX:b,stretchY:L,content:E,sdf:f,version:0})}}updateImage(y,n){let c=this.style.getImage(y);if(!c)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let p=n instanceof HTMLImageElement||o.b(n)?v.getImageData(n):n,{width:f,height:b,data:L}=p;if(f===void 0||b===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(f!==c.data.width||b!==c.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(n instanceof HTMLImageElement||o.b(n));return c.data.replace(L,E),this.style.updateImage(y,c),this}getImage(y){return this.style.getImage(y)}hasImage(y){return y?!!this.style.getImage(y):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(y){this.style.removeImage(y)}loadImage(y){return O.getImage(this._requestManager.transformRequest(y,tt.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(y,n){return this._lazyInitEmptyStyle(),this.style.addLayer(y,n),this._update(!0)}moveLayer(y,n){return this.style.moveLayer(y,n),this._update(!0)}removeLayer(y){return this.style.removeLayer(y),this._update(!0)}getLayer(y){return this.style.getLayer(y)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(y,n,c){return this.style.setLayerZoomRange(y,n,c),this._update(!0)}setFilter(y,n,c={}){return this.style.setFilter(y,n,c),this._update(!0)}getFilter(y){return this.style.getFilter(y)}setPaintProperty(y,n,c,p={}){return this.style.setPaintProperty(y,n,c,p),this._update(!0)}getPaintProperty(y,n){return this.style.getPaintProperty(y,n)}setLayoutProperty(y,n,c,p={}){return this.style.setLayoutProperty(y,n,c,p),this._update(!0)}getLayoutProperty(y,n){return this.style.getLayoutProperty(y,n)}setGlyphs(y,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(y,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(y,n,c={}){return this._lazyInitEmptyStyle(),this.style.addSprite(y,n,c,p=>{p||this._update(!0)}),this}removeSprite(y){return this._lazyInitEmptyStyle(),this.style.removeSprite(y),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(y,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(y,n,c=>{c||this._update(!0)}),this}setLight(y,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(y,n),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(y,n){return this.style.setFeatureState(y,n),this._update()}removeFeatureState(y,n){return this.style.removeFeatureState(y,n),this._update()}getFeatureState(y){return this.style.getFeatureState(y)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let y=0,n=0;return this._container&&(y=this._container.clientWidth||400,n=this._container.clientHeight||300),[y,n]}_setupContainer(){let y=this._container;y.classList.add("maplibregl-map");let n=this._canvasContainer=x.create("div","maplibregl-canvas-container",y);this._interactive&&n.classList.add("maplibregl-interactive"),this._canvas=x.create("canvas","maplibregl-canvas",n),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");let c=this._containerDimensions(),p=this._getClampedPixelRatio(c[0],c[1]);this._resizeCanvas(c[0],c[1],p);let f=this._controlContainer=x.create("div","maplibregl-control-container",y),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(L=>{b[L]=x.create("div",`maplibregl-ctrl-${L} `,f)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(y,n,c){this._canvas.width=Math.floor(c*y),this._canvas.height=Math.floor(c*n),this._canvas.style.width=`${y}px`,this._canvas.style.height=`${n}px`}_setupPainter(){let y={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},n=null;this._canvas.addEventListener("webglcontextcreationerror",p=>{n={requestedAttributes:y},p&&(n.statusMessage=p.statusMessage,n.type=p.type)},{once:!0});let c=this._canvas.getContext("webgl2",y)||this._canvas.getContext("webgl",y);if(!c){let p="Failed to initialize WebGL";throw n?(n.message=p,new Error(JSON.stringify(n))):new Error(p)}this.painter=new fa(c,this.transform),T.testSupport(c)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(y){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||y,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(y){return this._update(),this._renderTaskQueue.add(y)}_cancelRenderFrame(y){this._renderTaskQueue.remove(y)}_render(y){let n=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(y),this._removed)return;let c=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let f=this.transform.zoom,b=v.now();this.style.zoomHistory.update(f,b);let L=new o.a8(f,{now:b,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=L.crossFadingFactor();E===1&&E===this._crossFadingFactor||(c=!0,this._crossFadingFactor=E),this.style.update(L)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,n,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bc.mark(o.bd.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||c)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0,o.bc.mark(o.bd.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var y;this._hash&&this._hash.remove();for(let c of this._controls)c.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),O.removeThrottleControl(this._imageQueueHandle),(y=this._resizeObserver)===null||y===void 0||y.disconnect();let n=this.painter.context.gl.getExtension("WEBGL_lose_context");n&&n.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),x.remove(this._canvasContainer),x.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bc.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(y=>{o.bc.frame(y),this._frameRequest=null,this._render(y)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(y){this._showTileBoundaries!==y&&(this._showTileBoundaries=y,this._update())}get showPadding(){return!!this._showPadding}set showPadding(y){this._showPadding!==y&&(this._showPadding=y,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(y){this._showCollisionBoxes!==y&&(this._showCollisionBoxes=y,y?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(y){this._showOverdrawInspector!==y&&(this._showOverdrawInspector=y,this._update())}get repaint(){return!!this._repaint}set repaint(y){this._repaint!==y&&(this._repaint=y,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(y){this._vertices=y,this._update()}get version(){return ul}getCameraTargetElevation(){return this.transform.elevation}},A.MapMouseEvent=Jr,A.MapTouchEvent=xs,A.MapWheelEvent=zn,A.Marker=Va,A.NavigationControl=class{constructor(y){this._updateZoomButtons=()=>{let n=this._map.getZoom(),c=n===this._map.getMaxZoom(),p=n===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=p,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",p.toString())},this._rotateCompassArrow=()=>{let n=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=n},this._setButtonTitle=(n,c)=>{let p=this._map._getUIString(`NavigationControl.${c}`);n.title=p,n.setAttribute("aria-label",p)},this.options=o.e({},hs,y),this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",n=>n.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",n=>this._map.zoomIn({},{originalEvent:n})),x.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",n=>this._map.zoomOut({},{originalEvent:n})),x.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",n=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:n}):this._map.resetNorth({},{originalEvent:n})}),this._compassIcon=x.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(y){return this._map=y,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 Bc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){x.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(y,n){let c=x.create("button",y,this._container);return c.type="button",c.addEventListener("click",n),c}},A.Popup=class extends o.E{constructor(y){super(),this.remove=()=>(this._content&&x.remove(this._content),this._container&&(x.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new o.k("close"))),this),this._onMouseUp=n=>{this._update(n.point)},this._onMouseMove=n=>{this._update(n.point)},this._onDrag=n=>{this._update(n.point)},this._update=n=>{var c;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=x.create("div","maplibregl-popup",this._map.getContainer()),this._tip=x.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let E of this.options.className.split(" "))this._container.classList.add(E);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?hl(this._lngLat,this._flatPos,this._map.transform):(c=this._lngLat)===null||c===void 0?void 0:c.wrap(),this._trackPointer&&!n)return;let p=this._flatPos=this._pos=this._trackPointer&&n?n:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&n?n:this._map.transform.locationPoint(this._lngLat));let f=this.options.anchor,b=Sc(this.options.offset);if(!f){let E=this._container.offsetWidth,H=this._container.offsetHeight,h;h=p.y+b.bottom.ythis._map.transform.height-H?["bottom"]:[],p.xthis._map.transform.width-E/2&&h.push("right"),f=h.length===0?"bottom":h.join("-")}let L=p.add(b[f]);this.options.subpixelPositioning||(L=L.round()),x.setTransform(this._container,`${kA[f]} translate(${L.x}px,${L.y}px)`),gl(this._container,f,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(xc),y)}addTo(y){return this._map&&this.remove(),this._map=y,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(y){return this._lngLat=o.M.convert(y),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(y){return this.setDOMContent(document.createTextNode(y))}setHTML(y){let n=document.createDocumentFragment(),c=document.createElement("body"),p;for(c.innerHTML=y;p=c.firstChild,p;)n.appendChild(p);return this.setDOMContent(n)}getMaxWidth(){var y;return(y=this._container)===null||y===void 0?void 0:y.style.maxWidth}setMaxWidth(y){return this.options.maxWidth=y,this._update(),this}setDOMContent(y){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=x.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(y),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(y){this._container&&this._container.classList.add(y)}removeClassName(y){this._container&&this._container.classList.remove(y)}setOffset(y){return this.options.offset=y,this._update(),this}toggleClassName(y){if(this._container)return this._container.classList.toggle(y)}setSubpixelPositioning(y){this.options.subpixelPositioning=y}_createCloseButton(){this.options.closeButton&&(this._closeButton=x.create("button","maplibregl-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))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let y=this._container.querySelector(Ml);y&&y.focus()}},A.RasterDEMTileSource=Li,A.RasterTileSource=Rt,A.ScaleControl=class{constructor(y){this._onMove=()=>{LA(this._map,this._container,this.options)},this.setUnit=n=>{this.options.unit=n,LA(this._map,this._container,this.options)},this.options=o.e({},Da,y)}getDefaultPosition(){return"bottom-left"}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-scale",y.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){x.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},A.ScrollZoomHandler=Al,A.Style=to,A.TerrainControl=class{constructor(y){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=y}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=x.create("button","maplibregl-ctrl-terrain",this._container),x.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){x.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},A.TwoFingersTouchPitchHandler=ol,A.TwoFingersTouchRotateHandler=BA,A.TwoFingersTouchZoomHandler=rs,A.TwoFingersTouchZoomRotateHandler=wi,A.VectorTileSource=xt,A.VideoSource=Je,A.addSourceType=(y,n)=>o._(void 0,void 0,void 0,function*(){if(hi(y))throw new Error(`A source type called "${y}" already exists.`);((c,p)=>{ui[c]=p})(y,n)}),A.clearPrewarmedResources=function(){let y=It;y&&(y.isPreloaded()&&y.numActive()===1?(y.release(fe),It=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()"))},A.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},A.getRTLTextPluginStatus=function(){return Oi().getRTLTextPluginStatus()},A.getVersion=function(){return Au},A.getWorkerCount=function(){return j.workerCount},A.getWorkerUrl=function(){return o.a.WORKER_URL},A.importScriptInWorkers=function(y){return he().broadcast("importScript",y)},A.prewarm=function(){Ot().acquire(fe)},A.setMaxParallelImageRequests=function(y){o.a.MAX_PARALLEL_IMAGE_REQUESTS=y},A.setRTLTextPlugin=function(y,n){return Oi().setRTLTextPlugin(y,n)},A.setWorkerCount=function(y){j.workerCount=y},A.setWorkerUrl=function(y){o.a.WORKER_URL=y}});var s=r;return s})});var lb=la((fd,md)=>{(function(r,t){typeof fd=="object"&&typeof md<"u"?t(fd):typeof define=="function"&&define.amd?define(["exports"],t):t((r=typeof globalThis<"u"?globalThis:r||self).VectorTextProtocol={})})(fd,function(r){"use strict";function t(pt){return pt&&pt.__esModule&&Object.prototype.hasOwnProperty.call(pt,"default")?pt.default:pt}function i(pt){if(pt.__esModule)return pt;var yt=pt.default;if(typeof yt=="function"){var ct=function Bt(){return this instanceof Bt?Reflect.construct(yt,arguments,this.constructor):yt.apply(this,arguments)};ct.prototype=yt.prototype}else ct={};return Object.defineProperty(ct,"__esModule",{value:!0}),Object.keys(pt).forEach(function(Bt){var Kt=Object.getOwnPropertyDescriptor(pt,Bt);Object.defineProperty(ct,Bt,Kt.get?Kt:{enumerable:!0,get:function(){return pt[Bt]}})}),ct}function s(pt){return new Function("d","return {"+pt.map(function(yt,ct){return JSON.stringify(yt)+": d["+ct+"]"}).join(",")+"}")}function A(pt){var yt=new RegExp('["'+pt+` -]`),ct=pt.charCodeAt(0);function Bt(ae,Be){var _e,Ce,se={},ye={},be=[],Ge=ae.length,Ui=0,Ri=0;function Pe(){if(Ui>=Ge)return ye;if(Ce)return Ce=!1,se;var Ai,Fi=Ui;if(ae.charCodeAt(Fi)===34){for(var Wi=Fi;Wi++({u_depth:new o.aG(ut,Gt.u_depth),u_terrain:new o.aG(ut,Gt.u_terrain),u_terrain_dim:new o.aH(ut,Gt.u_terrain_dim),u_terrain_matrix:new o.aI(ut,Gt.u_terrain_matrix),u_terrain_unpack:new o.aJ(ut,Gt.u_terrain_unpack),u_terrain_exaggeration:new o.aH(ut,Gt.u_terrain_exaggeration)}))(n,pt),this.binderUniforms=p?p.getUniforms(n,pt):[]}draw(n,c,p,f,b,L,E,H,h,I,_,F,R,Z,N,P,V,X){let J=n.gl;if(this.failedToCreate)return;if(n.program.set(this.program),n.setDepthMode(p),n.setStencilMode(f),n.setColorMode(b),n.setCullFace(L),H){n.activeTexture.set(J.TEXTURE2),J.bindTexture(J.TEXTURE_2D,H.depthTexture),n.activeTexture.set(J.TEXTURE3),J.bindTexture(J.TEXTURE_2D,H.texture);for(let pt in this.terrainUniforms)this.terrainUniforms[pt].set(H[pt])}for(let pt in this.fixedUniforms)this.fixedUniforms[pt].set(E[pt]);N&&N.setUniforms(n,this.binderUniforms,R,{zoom:Z});let ot=0;switch(c){case J.LINES:ot=2;break;case J.TRIANGLES:ot=3;break;case J.LINE_STRIP:ot=1}for(let pt of F.get()){let ut=pt.vaos||(pt.vaos={});(ut[h]||(ut[h]=new Kt)).bind(n,this,I,N?N.getPaintVertexBuffers():[],_,pt.vertexOffset,P,V,X),J.drawElements(c,pt.primitiveLength*ot,J.UNSIGNED_SHORT,pt.primitiveOffset*ot*2)}}}function we(y,n,c){let p=1/Ui(c,1,n.transform.tileZoom),f=Math.pow(2,c.tileID.overscaledZ),b=c.tileSize*Math.pow(2,n.transform.tileZoom)/f,L=b*(c.tileID.canonical.x+c.tileID.wrap*f),E=b*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[p,y.fromScale,y.toScale],u_fade:y.t,u_pixel_coord_upper:[L>>16,E>>16],u_pixel_coord_lower:[65535&L,65535&E]}}let ve=(y,n,c,p)=>{let f=n.style.light,b=f.properties.get("position"),L=[b.x,b.y,b.z],E=function(){var h=new o.A(9);return o.A!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1,h}();f.properties.get("anchor")==="viewport"&&function(h,I){var _=Math.sin(I),F=Math.cos(I);h[0]=F,h[1]=_,h[2]=0,h[3]=-_,h[4]=F,h[5]=0,h[6]=0,h[7]=0,h[8]=1}(E,-n.transform.angle),function(h,I,_){var F=I[0],R=I[1],Z=I[2];h[0]=F*_[0]+R*_[3]+Z*_[6],h[1]=F*_[1]+R*_[4]+Z*_[7],h[2]=F*_[2]+R*_[5]+Z*_[8]}(L,L,E);let H=f.properties.get("color");return{u_matrix:y,u_lightpos:L,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[H.r,H.g,H.b],u_vertical_gradient:+c,u_opacity:p}},Ie=(y,n,c,p,f,b,L)=>o.e(ve(y,n,c,p),we(b,n,L),{u_height_factor:-Math.pow(2,f.overscaledZ)/L.tileSize/8}),oe=y=>({u_matrix:y}),ye=(y,n,c,p)=>o.e(oe(y),we(c,n,p)),Be=(y,n)=>({u_matrix:y,u_world:n}),Re=(y,n,c,p,f)=>o.e(ye(y,n,c,p),{u_world:f}),Qi=(y,n,c,p)=>{let f=y.transform,b,L;if(p.paint.get("circle-pitch-alignment")==="map"){let E=Ui(c,1,f.zoom);b=!0,L=[E,E]}else b=!1,L=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+(p.paint.get("circle-pitch-scale")==="map"),u_matrix:y.translatePosMatrix(n.posMatrix,c,p.paint.get("circle-translate"),p.paint.get("circle-translate-anchor")),u_pitch_with_map:+b,u_device_pixel_ratio:y.pixelRatio,u_extrude_scale:L}},Ri=(y,n,c)=>{let p=Ui(c,1,n.zoom),f=Math.pow(2,n.zoom-c.tileID.overscaledZ),b=c.tileID.overscaleFactor();return{u_matrix:y,u_camera_to_center_distance:n.cameraToCenterDistance,u_pixels_to_tile_units:p,u_extrude_scale:[n.pixelsToGLUnits[0]/(p*f),n.pixelsToGLUnits[1]/(p*f)],u_overscale_factor:b}},Pe=(y,n,c=1)=>({u_matrix:y,u_color:n,u_overlay:0,u_overlay_scale:c}),Ue=y=>({u_matrix:y}),Ai=(y,n,c,p)=>({u_matrix:y,u_extrude_scale:Ui(n,1,c),u_intensity:p});function Fi(y,n){let c=Math.pow(2,n.canonical.z),p=n.canonical.y;return[new o.Y(0,p/c).toLngLat().lat,new o.Y(0,(p+1)/c).toLngLat().lat]}let Wi=(y,n,c,p)=>{let f=y.transform;return{u_matrix:Gr(y,n,c,p),u_ratio:1/Ui(n,1,f.zoom),u_device_pixel_ratio:y.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},nr=(y,n,c,p,f)=>o.e(Wi(y,n,c,f),{u_image:0,u_image_height:p}),ai=(y,n,c,p,f)=>{let b=y.transform,L=Or(n,b);return{u_matrix:Gr(y,n,c,f),u_texsize:n.imageAtlasTexture.size,u_ratio:1/Ui(n,1,b.zoom),u_device_pixel_ratio:y.pixelRatio,u_image:0,u_scale:[L,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/b.pixelsToGLUnits[0],1/b.pixelsToGLUnits[1]]}},dr=(y,n,c,p,f,b)=>{let L=y.lineAtlas,E=Or(n,y.transform),H=c.layout.get("line-cap")==="round",h=L.getDash(p.from,H),I=L.getDash(p.to,H),_=h.width*f.fromScale,F=I.width*f.toScale;return o.e(Wi(y,n,c,b),{u_patternscale_a:[E/_,-h.height/2],u_patternscale_b:[E/F,-I.height/2],u_sdfgamma:L.width/(256*Math.min(_,F)*y.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:I.y,u_mix:f.t})};function Or(y,n){return 1/Ui(y,1,n.tileZoom)}function Gr(y,n,c,p){return y.translatePosMatrix(p?p.posMatrix:n.tileID.posMatrix,n,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}let xn=(y,n,c,p,f)=>{return{u_matrix:y,u_tl_parent:n,u_scale_parent:c,u_buffer_scale:1,u_fade_t:p.mix,u_opacity:p.opacity*f.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:f.paint.get("raster-brightness-min"),u_brightness_high:f.paint.get("raster-brightness-max"),u_saturation_factor:(L=f.paint.get("raster-saturation"),L>0?1-1/(1.001-L):-L),u_contrast_factor:(b=f.paint.get("raster-contrast"),b>0?1/(1-b):1+b),u_spin_weights:vn(f.paint.get("raster-hue-rotate"))};var b,L};function vn(y){y*=Math.PI/180;let n=Math.sin(y),c=Math.cos(y);return[(2*c+1)/3,(-Math.sqrt(3)*n-c+1)/3,(Math.sqrt(3)*n-c+1)/3]}let ws=(y,n,c,p,f,b,L,E,H,h)=>{let I=f.transform;return{u_is_size_zoom_constant:+(y==="constant"||y==="source"),u_is_size_feature_constant:+(y==="constant"||y==="camera"),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:I.width/I.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:b,u_label_plane_matrix:L,u_coord_matrix:E,u_is_text:+H,u_pitch_with_map:+p,u_texsize:h,u_texture:0}},_o=(y,n,c,p,f,b,L,E,H,h,I)=>{let _=f.transform;return o.e(ws(y,n,c,p,f,b,L,E,H,h),{u_gamma_scale:p?Math.cos(_._pitch)*_.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:+I})},Ic=(y,n,c,p,f,b,L,E,H,h)=>o.e(_o(y,n,c,p,f,b,L,E,!0,H,!0),{u_texsize_icon:h,u_texture_icon:1}),yc=(y,n,c)=>({u_matrix:y,u_opacity:n,u_color:c}),El=(y,n,c,p,f,b)=>o.e(function(L,E,H,h){let I=H.imageManager.getPattern(L.from.toString()),_=H.imageManager.getPattern(L.to.toString()),{width:F,height:R}=H.imageManager.getPixelSize(),Z=Math.pow(2,h.tileID.overscaledZ),N=h.tileSize*Math.pow(2,H.transform.tileZoom)/Z,P=N*(h.tileID.canonical.x+h.tileID.wrap*Z),V=N*h.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:I.tl,u_pattern_br_a:I.br,u_pattern_tl_b:_.tl,u_pattern_br_b:_.br,u_texsize:[F,R],u_mix:E.t,u_pattern_size_a:I.displaySize,u_pattern_size_b:_.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/Ui(h,1,H.transform.tileZoom),u_pixel_coord_upper:[P>>16,V>>16],u_pixel_coord_lower:[65535&P,65535&V]}}(p,b,c,f),{u_matrix:y,u_opacity:n}),el={fillExtrusion:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_lightpos:new o.aK(y,n.u_lightpos),u_lightintensity:new o.aH(y,n.u_lightintensity),u_lightcolor:new o.aK(y,n.u_lightcolor),u_vertical_gradient:new o.aH(y,n.u_vertical_gradient),u_opacity:new o.aH(y,n.u_opacity)}),fillExtrusionPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_lightpos:new o.aK(y,n.u_lightpos),u_lightintensity:new o.aH(y,n.u_lightintensity),u_lightcolor:new o.aK(y,n.u_lightcolor),u_vertical_gradient:new o.aH(y,n.u_vertical_gradient),u_height_factor:new o.aH(y,n.u_height_factor),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade),u_opacity:new o.aH(y,n.u_opacity)}),fill:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix)}),fillPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),fillOutline:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world)}),fillOutlinePattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world),u_image:new o.aG(y,n.u_image),u_texsize:new o.aL(y,n.u_texsize),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),circle:(y,n)=>({u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_scale_with_map:new o.aG(y,n.u_scale_with_map),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_extrude_scale:new o.aL(y,n.u_extrude_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_matrix:new o.aI(y,n.u_matrix)}),collisionBox:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pixels_to_tile_units:new o.aH(y,n.u_pixels_to_tile_units),u_extrude_scale:new o.aL(y,n.u_extrude_scale),u_overscale_factor:new o.aH(y,n.u_overscale_factor)}),collisionCircle:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_inv_matrix:new o.aI(y,n.u_inv_matrix),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_viewport_size:new o.aL(y,n.u_viewport_size)}),debug:(y,n)=>({u_color:new o.aM(y,n.u_color),u_matrix:new o.aI(y,n.u_matrix),u_overlay:new o.aG(y,n.u_overlay),u_overlay_scale:new o.aH(y,n.u_overlay_scale)}),clippingMask:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix)}),heatmap:(y,n)=>({u_extrude_scale:new o.aH(y,n.u_extrude_scale),u_intensity:new o.aH(y,n.u_intensity),u_matrix:new o.aI(y,n.u_matrix)}),heatmapTexture:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_world:new o.aL(y,n.u_world),u_image:new o.aG(y,n.u_image),u_color_ramp:new o.aG(y,n.u_color_ramp),u_opacity:new o.aH(y,n.u_opacity)}),hillshade:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_latrange:new o.aL(y,n.u_latrange),u_light:new o.aL(y,n.u_light),u_shadow:new o.aM(y,n.u_shadow),u_highlight:new o.aM(y,n.u_highlight),u_accent:new o.aM(y,n.u_accent)}),hillshadePrepare:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_image:new o.aG(y,n.u_image),u_dimension:new o.aL(y,n.u_dimension),u_zoom:new o.aH(y,n.u_zoom),u_unpack:new o.aJ(y,n.u_unpack)}),line:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels)}),lineGradient:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_image:new o.aG(y,n.u_image),u_image_height:new o.aH(y,n.u_image_height)}),linePattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texsize:new o.aL(y,n.u_texsize),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_image:new o.aG(y,n.u_image),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_scale:new o.aK(y,n.u_scale),u_fade:new o.aH(y,n.u_fade)}),lineSDF:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ratio:new o.aH(y,n.u_ratio),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_units_to_pixels:new o.aL(y,n.u_units_to_pixels),u_patternscale_a:new o.aL(y,n.u_patternscale_a),u_patternscale_b:new o.aL(y,n.u_patternscale_b),u_sdfgamma:new o.aH(y,n.u_sdfgamma),u_image:new o.aG(y,n.u_image),u_tex_y_a:new o.aH(y,n.u_tex_y_a),u_tex_y_b:new o.aH(y,n.u_tex_y_b),u_mix:new o.aH(y,n.u_mix)}),raster:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_tl_parent:new o.aL(y,n.u_tl_parent),u_scale_parent:new o.aH(y,n.u_scale_parent),u_buffer_scale:new o.aH(y,n.u_buffer_scale),u_fade_t:new o.aH(y,n.u_fade_t),u_opacity:new o.aH(y,n.u_opacity),u_image0:new o.aG(y,n.u_image0),u_image1:new o.aG(y,n.u_image1),u_brightness_low:new o.aH(y,n.u_brightness_low),u_brightness_high:new o.aH(y,n.u_brightness_high),u_saturation_factor:new o.aH(y,n.u_saturation_factor),u_contrast_factor:new o.aH(y,n.u_contrast_factor),u_spin_weights:new o.aK(y,n.u_spin_weights)}),symbolIcon:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texture:new o.aG(y,n.u_texture)}),symbolSDF:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texture:new o.aG(y,n.u_texture),u_gamma_scale:new o.aH(y,n.u_gamma_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_is_halo:new o.aG(y,n.u_is_halo)}),symbolTextAndIcon:(y,n)=>({u_is_size_zoom_constant:new o.aG(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(y,n.u_is_size_feature_constant),u_size_t:new o.aH(y,n.u_size_t),u_size:new o.aH(y,n.u_size),u_camera_to_center_distance:new o.aH(y,n.u_camera_to_center_distance),u_pitch:new o.aH(y,n.u_pitch),u_rotate_symbol:new o.aG(y,n.u_rotate_symbol),u_aspect_ratio:new o.aH(y,n.u_aspect_ratio),u_fade_change:new o.aH(y,n.u_fade_change),u_matrix:new o.aI(y,n.u_matrix),u_label_plane_matrix:new o.aI(y,n.u_label_plane_matrix),u_coord_matrix:new o.aI(y,n.u_coord_matrix),u_is_text:new o.aG(y,n.u_is_text),u_pitch_with_map:new o.aG(y,n.u_pitch_with_map),u_texsize:new o.aL(y,n.u_texsize),u_texsize_icon:new o.aL(y,n.u_texsize_icon),u_texture:new o.aG(y,n.u_texture),u_texture_icon:new o.aG(y,n.u_texture_icon),u_gamma_scale:new o.aH(y,n.u_gamma_scale),u_device_pixel_ratio:new o.aH(y,n.u_device_pixel_ratio),u_is_halo:new o.aG(y,n.u_is_halo)}),background:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_opacity:new o.aH(y,n.u_opacity),u_color:new o.aM(y,n.u_color)}),backgroundPattern:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_opacity:new o.aH(y,n.u_opacity),u_image:new o.aG(y,n.u_image),u_pattern_tl_a:new o.aL(y,n.u_pattern_tl_a),u_pattern_br_a:new o.aL(y,n.u_pattern_br_a),u_pattern_tl_b:new o.aL(y,n.u_pattern_tl_b),u_pattern_br_b:new o.aL(y,n.u_pattern_br_b),u_texsize:new o.aL(y,n.u_texsize),u_mix:new o.aH(y,n.u_mix),u_pattern_size_a:new o.aL(y,n.u_pattern_size_a),u_pattern_size_b:new o.aL(y,n.u_pattern_size_b),u_scale_a:new o.aH(y,n.u_scale_a),u_scale_b:new o.aH(y,n.u_scale_b),u_pixel_coord_upper:new o.aL(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(y,n.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aH(y,n.u_tile_units_to_pixels)}),terrain:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texture:new o.aG(y,n.u_texture),u_ele_delta:new o.aH(y,n.u_ele_delta)}),terrainDepth:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_ele_delta:new o.aH(y,n.u_ele_delta)}),terrainCoords:(y,n)=>({u_matrix:new o.aI(y,n.u_matrix),u_texture:new o.aG(y,n.u_texture),u_terrain_coords_id:new o.aH(y,n.u_terrain_coords_id),u_ele_delta:new o.aH(y,n.u_ele_delta)})};class Bs{constructor(n,c,p){this.context=n;let f=n.gl;this.buffer=f.createBuffer(),this.dynamicDraw=Boolean(p),this.context.unbindVAO(),n.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(n){let c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,n.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let to={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class qn{constructor(n,c,p,f){this.length=c.length,this.attributes=p,this.itemSize=c.bytesPerElement,this.dynamicDraw=f,this.context=n;let b=n.gl;this.buffer=b.createBuffer(),n.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(n){if(n.length!==this.length)throw new Error(`Length of new data is ${n.length}, which doesn't match current length of ${this.length}`);let c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,n.arrayBuffer)}enableAttributes(n,c){for(let p=0;p0){let Ct=o.F(),ee=Gt;o.aP(Ct,ut.placementInvProjMatrix,y.transform.glCoordMatrix),o.aP(Ct,Ct,ut.placementViewportMatrix),I.push({circleArray:dt,circleOffset:F,transform:ee,invTransform:Ct,coord:ot}),_+=dt.length/4,F=_}Pt&&h.draw(E,H.LINES,Ci.disabled,Xi.disabled,y.colorModeForRenderPass(),Yi.disabled,Ri(Gt,y.transform,pt),y.style.map.terrain&&y.style.map.terrain.getTerrainData(ot),c.id,Pt.layoutVertexBuffer,Pt.indexBuffer,Pt.segments,null,y.transform.zoom,null,null,Pt.collisionVertexBuffer)}if(!L||!I.length)return;let R=y.useProgram("collisionCircle"),Z=new o.aQ;Z.resize(4*_),Z._trim();let N=0;for(let J of I)for(let ot=0;ot=0&&(Z[P.associatedIconIndex]={shiftedAnchor:ge,angle:jt})}else Xe(P.numGlyphs,F)}if(h){R.clear();let N=y.icon.placedSymbolArray;for(let P=0;Py.style.map.terrain.getElevation(Pt,pn,$i):null,Br=c.layout.get("text-rotation-alignment")==="map";rt(Ct,Pt.posMatrix,y,f,Yr,Rr,P,h,Br,_r)}let An=y.translatePosMatrix(Pt.posMatrix,dt,b,L),rn=V||f&&ut||wr?Hs:Yr,ur=y.translatePosMatrix(Rr,dt,b,L,!0),sr=jt&&c.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1)!==0,Ir;Ir=jt?Ct.iconsInText?Ic(Fe.kind,xe,X,P,y,An,rn,ur,pi,ji):_o(Fe.kind,xe,X,P,y,An,rn,ur,f,pi,!0):ws(Fe.kind,xe,X,P,y,An,rn,ur,f,pi);let Fn={program:Ye,buffers:ee,uniformValues:Ir,atlasTexture:Mi,atlasTextureIcon:Ii,atlasInterpolation:Si,atlasInterpolationIcon:cr,isSDF:jt,hasHalo:sr};if(J&&Ct.canOverlap){ot=!0;let _r=ee.segments.get();for(let Br of _r)Gt.push({segments:new o.$([Br]),sortKey:Br.sortKey,state:Fn,terrainData:ci})}else Gt.push({segments:ee.segments,sortKey:0,state:Fn,terrainData:ci})}ot&&Gt.sort((Pt,dt)=>Pt.sortKey-dt.sortKey);for(let Pt of Gt){let dt=Pt.state;if(F.activeTexture.set(R.TEXTURE0),dt.atlasTexture.bind(dt.atlasInterpolation,R.CLAMP_TO_EDGE),dt.atlasTextureIcon&&(F.activeTexture.set(R.TEXTURE1),dt.atlasTextureIcon&&dt.atlasTextureIcon.bind(dt.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),dt.isSDF){let Ct=dt.uniformValues;dt.hasHalo&&(Ct.u_is_halo=1,ga(dt.buffers,Pt.segments,c,y,dt.program,pt,I,_,Ct,Pt.terrainData)),Ct.u_is_halo=0}ga(dt.buffers,Pt.segments,c,y,dt.program,pt,I,_,dt.uniformValues,Pt.terrainData)}}function ga(y,n,c,p,f,b,L,E,H,h){let I=p.context;f.draw(I,I.gl.TRIANGLES,b,L,E,Yi.disabled,H,h,c.id,y.layoutVertexBuffer,y.indexBuffer,n,c.paint,p.transform.zoom,y.programConfigurations.get(c.id),y.dynamicLayoutVertexBuffer,y.opacityVertexBuffer)}function Ua(y,n,c,p,f){if(!c||!p||!p.imageAtlas)return;let b=p.imageAtlas.patternPositions,L=b[c.to.toString()],E=b[c.from.toString()];if(!L&&E&&(L=E),!E&&L&&(E=L),!L||!E){let H=f.getPaintProperty(n);L=b[H],E=b[H]}L&&E&&y.setConstantPatternPositions(L,E)}function Qa(y,n,c,p,f,b,L){let E=y.context.gl,H="fill-pattern",h=c.paint.get(H),I=h&&h.constantOr(1),_=c.getCrossfadeParameters(),F,R,Z,N,P;L?(R=I&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",F=E.LINES):(R=I?"fillPattern":"fill",F=E.TRIANGLES);let V=h.constantOr(null);for(let X of p){let J=n.getTile(X);if(I&&!J.patternsLoaded())continue;let ot=J.getBucket(c);if(!ot)continue;let pt=ot.programConfigurations.get(c.id),ut=y.useProgram(R,pt),Gt=y.style.map.terrain&&y.style.map.terrain.getTerrainData(X);I&&(y.context.activeTexture.set(E.TEXTURE0),J.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),pt.updatePaintBuffers(_)),Ua(pt,H,V,J,c);let Pt=Gt?X:null,dt=y.translatePosMatrix(Pt?Pt.posMatrix:X.posMatrix,J,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(L){N=ot.indexBuffer2,P=ot.segments2;let Ct=[E.drawingBufferWidth,E.drawingBufferHeight];Z=R==="fillOutlinePattern"&&I?Re(dt,y,_,J,Ct):Be(dt,Ct)}else N=ot.indexBuffer,P=ot.segments,Z=I?ye(dt,y,_,J):oe(dt);ut.draw(y.context,F,f,y.stencilModeForClipping(X),b,Yi.disabled,Z,Gt,c.id,ot.layoutVertexBuffer,N,P,c.paint,y.transform.zoom,pt)}}function Lo(y,n,c,p,f,b,L){let E=y.context,H=E.gl,h="fill-extrusion-pattern",I=c.paint.get(h),_=I.constantOr(1),F=c.getCrossfadeParameters(),R=c.paint.get("fill-extrusion-opacity"),Z=I.constantOr(null);for(let N of p){let P=n.getTile(N),V=P.getBucket(c);if(!V)continue;let X=y.style.map.terrain&&y.style.map.terrain.getTerrainData(N),J=V.programConfigurations.get(c.id),ot=y.useProgram(_?"fillExtrusionPattern":"fillExtrusion",J);_&&(y.context.activeTexture.set(H.TEXTURE0),P.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),J.updatePaintBuffers(F)),Ua(J,h,Z,P,c);let pt=y.translatePosMatrix(N.posMatrix,P,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),ut=c.paint.get("fill-extrusion-vertical-gradient"),Gt=_?Ie(pt,y,ut,R,N,F,P):ve(pt,y,ut,R);ot.draw(E,E.gl.TRIANGLES,f,b,L,Yi.backCCW,Gt,X,c.id,V.layoutVertexBuffer,V.indexBuffer,V.segments,c.paint,y.transform.zoom,J,y.style.map.terrain&&V.centroidVertexBuffer)}}function da(y,n,c,p,f,b,L){let E=y.context,H=E.gl,h=c.fbo;if(!h)return;let I=y.useProgram("hillshade"),_=y.style.map.terrain&&y.style.map.terrain.getTerrainData(n);E.activeTexture.set(H.TEXTURE0),H.bindTexture(H.TEXTURE_2D,h.colorAttachment.get()),I.draw(E,H.TRIANGLES,f,b,L,Yi.disabled,((F,R,Z,N)=>{let P=Z.paint.get("hillshade-shadow-color"),V=Z.paint.get("hillshade-highlight-color"),X=Z.paint.get("hillshade-accent-color"),J=Z.paint.get("hillshade-illumination-direction")*(Math.PI/180);Z.paint.get("hillshade-illumination-anchor")==="viewport"&&(J-=F.transform.angle);let ot=!F.options.moving;return{u_matrix:N?N.posMatrix:F.transform.calculatePosMatrix(R.tileID.toUnwrapped(),ot),u_image:0,u_latrange:Fi(0,R.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),J],u_shadow:P,u_highlight:V,u_accent:X}})(y,c,p,_?n:null),_,p.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}function ts(y,n,c,p,f,b){let L=y.context,E=L.gl,H=n.dem;if(H&&H.data){let h=H.dim,I=H.stride,_=H.getPixels();if(L.activeTexture.set(E.TEXTURE1),L.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||y.getTileTexture(I),n.demTexture){let R=n.demTexture;R.update(_,{premultiply:!1}),R.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else n.demTexture=new qt(L,_,E.RGBA,{premultiply:!1}),n.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);L.activeTexture.set(E.TEXTURE0);let F=n.fbo;if(!F){let R=new qt(L,{width:h,height:h,data:null},E.RGBA);R.bind(E.LINEAR,E.CLAMP_TO_EDGE),F=n.fbo=L.createFramebuffer(h,h,!0,!1),F.colorAttachment.set(R.texture)}L.bindFramebuffer.set(F.framebuffer),L.viewport.set([0,0,h,h]),y.useProgram("hillshadePrepare").draw(L,E.TRIANGLES,p,f,b,Yi.disabled,((R,Z)=>{let N=Z.stride,P=o.F();return o.aN(P,0,o.W,-o.W,0,0,1),o.H(P,P,[0,-o.W,0]),{u_matrix:P,u_image:1,u_dimension:[N,N],u_zoom:R.overscaledZ,u_unpack:Z.getUnpackVector()}})(n.tileID,H),null,c.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments),n.needsHillshadePrepare=!1}}function Ga(y,n,c,p,f,b){let L=p.paint.get("raster-fade-duration");if(!b&&L>0){let E=v.now(),H=(E-y.timeAdded)/L,h=n?(E-n.timeAdded)/L:-1,I=c.getSource(),_=f.coveringZoomLevel({tileSize:I.tileSize,roundZoom:I.roundZoom}),F=!n||Math.abs(n.tileID.overscaledZ-_)>Math.abs(y.tileID.overscaledZ-_),R=F&&y.refreshedUponExpiration?1:o.ac(F?H:1-h,0,1);return y.refreshedUponExpiration&&H>=1&&(y.refreshedUponExpiration=!1),n?{opacity:1,mix:1-R}:{opacity:R,mix:0}}return{opacity:1,mix:0}}let $o=new o.aO(1,0,0,1),pa=new o.aO(0,1,0,1),nl=new o.aO(0,0,1,1),es=new o.aO(1,0,1,1),zr=new o.aO(0,1,1,1);function Ps(y,n,c,p){On(y,0,n+c/2,y.transform.width,c,p)}function Wn(y,n,c,p){On(y,n-c/2,0,c,y.transform.height,p)}function On(y,n,c,p,f,b){let L=y.context,E=L.gl;E.enable(E.SCISSOR_TEST),E.scissor(n*y.pixelRatio,c*y.pixelRatio,p*y.pixelRatio,f*y.pixelRatio),L.clear({color:b}),E.disable(E.SCISSOR_TEST)}function Ra(y,n,c){let p=y.context,f=p.gl,b=c.posMatrix,L=y.useProgram("debug"),E=Ci.disabled,H=Xi.disabled,h=y.colorModeForRenderPass(),I="$debug",_=y.style.map.terrain&&y.style.map.terrain.getTerrainData(c);p.activeTexture.set(f.TEXTURE0);let F=n.getTileByID(c.key).latestRawTileData,R=Math.floor((F&&F.byteLength||0)/1024),Z=n.getTile(c).tileSize,N=512/Math.min(Z,512)*(c.overscaledZ/y.transform.zoom)*.5,P=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(P+=` => ${c.overscaledZ}`),function(V,X){V.initDebugOverlayCanvas();let J=V.debugOverlayCanvas,ot=V.context.gl,pt=V.debugOverlayCanvas.getContext("2d");pt.clearRect(0,0,J.width,J.height),pt.shadowColor="white",pt.shadowBlur=2,pt.lineWidth=1.5,pt.strokeStyle="white",pt.textBaseline="top",pt.font="bold 36px Open Sans, sans-serif",pt.fillText(X,5,5),pt.strokeText(X,5,5),V.debugOverlayTexture.update(J),V.debugOverlayTexture.bind(ot.LINEAR,ot.CLAMP_TO_EDGE)}(y,`${P} ${R}kB`),L.draw(p,f.TRIANGLES,E,H,xi.alphaBlended,Yi.disabled,Pe(b,o.aO.transparent,N),null,I,y.debugBuffer,y.quadTriangleIndexBuffer,y.debugSegments),L.draw(p,f.LINE_STRIP,E,H,h,Yi.disabled,Pe(b,o.aO.red),_,I,y.debugBuffer,y.tileBorderIndexBuffer,y.debugSegments)}function sl(y,n,c){let p=y.context,f=p.gl,b=y.colorModeForRenderPass(),L=new Ci(f.LEQUAL,Ci.ReadWrite,y.depthRangeFor3D),E=y.useProgram("terrain"),H=n.getTerrainMesh();p.bindFramebuffer.set(null),p.viewport.set([0,0,y.width,y.height]);for(let h of c){let I=y.renderToTexture.getTexture(h),_=n.getTerrainData(h.tileID);p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,I.texture);let F={u_matrix:y.transform.calculatePosMatrix(h.tileID.toUnwrapped()),u_texture:0,u_ele_delta:n.getMeshFrameDelta(y.transform.zoom)};E.draw(p,f.TRIANGLES,L,Xi.disabled,b,Yi.backCCW,F,_,"terrain",H.vertexBuffer,H.indexBuffer,H.segments)}}class fa{constructor(n,c){this.context=new ar(n),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Se.maxUnderzooming+Se.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Qr}resize(n,c,p){if(this.width=Math.floor(n*p),this.height=Math.floor(c*p),this.pixelRatio=p,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let f of this.style._order)this.style._layers[f].resize()}setup(){let n=this.context,c=new o.aV;c.emplaceBack(0,0),c.emplaceBack(o.W,0),c.emplaceBack(0,o.W),c.emplaceBack(o.W,o.W),this.tileExtentBuffer=n.createVertexBuffer(c,gt.members),this.tileExtentSegments=o.$.simpleSegment(0,0,4,2);let p=new o.aV;p.emplaceBack(0,0),p.emplaceBack(o.W,0),p.emplaceBack(0,o.W),p.emplaceBack(o.W,o.W),this.debugBuffer=n.createVertexBuffer(p,gt.members),this.debugSegments=o.$.simpleSegment(0,0,4,5);let f=new o.Z;f.emplaceBack(0,0,0,0),f.emplaceBack(o.W,0,o.W,0),f.emplaceBack(0,o.W,0,o.W),f.emplaceBack(o.W,o.W,o.W,o.W),this.rasterBoundsBuffer=n.createVertexBuffer(f,Ee.members),this.rasterBoundsSegments=o.$.simpleSegment(0,0,4,2);let b=new o.aV;b.emplaceBack(0,0),b.emplaceBack(1,0),b.emplaceBack(0,1),b.emplaceBack(1,1),this.viewportBuffer=n.createVertexBuffer(b,gt.members),this.viewportSegments=o.$.simpleSegment(0,0,4,2);let L=new o.aW;L.emplaceBack(0),L.emplaceBack(1),L.emplaceBack(3),L.emplaceBack(2),L.emplaceBack(0),this.tileBorderIndexBuffer=n.createIndexBuffer(L);let E=new o.aX;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=n.createIndexBuffer(E);let H=this.context.gl;this.stencilClearMode=new Xi({func:H.ALWAYS,mask:0},0,255,H.ZERO,H.ZERO,H.ZERO)}clearStencil(){let n=this.context,c=n.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let p=o.F();o.aN(p,0,this.width,this.height,0,0,1),o.J(p,p,[c.drawingBufferWidth,c.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(n,c.TRIANGLES,Ci.disabled,this.stencilClearMode,xi.disabled,Yi.disabled,Ue(p),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(n,c){if(this.currentStencilSource===n.source||!n.isTileClipped()||!c||!c.length)return;this.currentStencilSource=n.source;let p=this.context,f=p.gl;this.nextStencilID+c.length>256&&this.clearStencil(),p.setColorMode(xi.disabled),p.setDepthMode(Ci.disabled);let b=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let L of c){let E=this._tileClippingMaskIDs[L.key]=this.nextStencilID++,H=this.style.map.terrain&&this.style.map.terrain.getTerrainData(L);b.draw(p,f.TRIANGLES,Ci.disabled,new Xi({func:f.ALWAYS,mask:0},E,255,f.KEEP,f.KEEP,f.REPLACE),xi.disabled,Yi.disabled,Ue(L.posMatrix),H,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let n=this.nextStencilID++,c=this.context.gl;return new Xi({func:c.NOTEQUAL,mask:255},n,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(n){let c=this.context.gl;return new Xi({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[n.key],0,c.KEEP,c.KEEP,c.REPLACE)}stencilConfigForOverlap(n){let c=this.context.gl,p=n.sort((L,E)=>E.overscaledZ-L.overscaledZ),f=p[p.length-1].overscaledZ,b=p[0].overscaledZ-f+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();let L={};for(let E=0;E=0;this.currentLayer--){let H=this.style._layers[p[this.currentLayer]],h=f[H.source],I=b[H.source];this._renderTileClippingMasks(H,I),this.renderLayer(this,h,H,I)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerP.source&&!P.isHidden(I)?[h.sourceCaches[P.source]]:[]),R=F.filter(P=>P.getSource().type==="vector"),Z=F.filter(P=>P.getSource().type!=="vector"),N=P=>{(!_||_.getSource().maxzoomN(P)),_||Z.forEach(P=>N(P)),_}(this.style,this.transform.zoom);H&&function(h,I,_){for(let F=0;F<_.length;F++)Ra(h,I,_[F])}(this,H,H.getVisibleCoordinates())}this.options.showPadding&&function(H){let h=H.transform.padding;Ps(H,H.transform.height-(h.top||0),3,$o),Ps(H,h.bottom||0,3,pa),Wn(H,h.left||0,3,nl),Wn(H,H.transform.width-(h.right||0),3,es);let I=H.transform.centerPoint;(function(_,F,R,Z){On(_,F-1,R-10,2,20,Z),On(_,F-10,R-1,20,2,Z)})(H,I.x,H.transform.height-I.y,zr)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(n){if(!this.style||!this.style.map||!this.style.map.terrain)return;let c=this.terrainFacilitator.matrix,p=this.transform.projMatrix,f=this.terrainFacilitator.dirty;f||(f=n?!o.aY(c,p):!o.aZ(c,p)),f||(f=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),f&&(o.a_(c,p),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(b,L){let E=b.context,H=E.gl,h=xi.unblended,I=new Ci(H.LEQUAL,Ci.ReadWrite,[0,1]),_=L.getTerrainMesh(),F=L.sourceCache.getRenderableTiles(),R=b.useProgram("terrainDepth");E.bindFramebuffer.set(L.getFramebuffer("depth").framebuffer),E.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),E.clear({color:o.aO.transparent,depth:1});for(let Z of F){let N=L.getTerrainData(Z.tileID),P={u_matrix:b.transform.calculatePosMatrix(Z.tileID.toUnwrapped()),u_ele_delta:L.getMeshFrameDelta(b.transform.zoom)};R.draw(E,H.TRIANGLES,I,Xi.disabled,h,Yi.backCCW,P,N,"terrain",_.vertexBuffer,_.indexBuffer,_.segments)}E.bindFramebuffer.set(null),E.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain),function(b,L){let E=b.context,H=E.gl,h=xi.unblended,I=new Ci(H.LEQUAL,Ci.ReadWrite,[0,1]),_=L.getTerrainMesh(),F=L.getCoordsTexture(),R=L.sourceCache.getRenderableTiles(),Z=b.useProgram("terrainCoords");E.bindFramebuffer.set(L.getFramebuffer("coords").framebuffer),E.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),E.clear({color:o.aO.transparent,depth:1}),L.coordsIndex=[];for(let N of R){let P=L.getTerrainData(N.tileID);E.activeTexture.set(H.TEXTURE0),H.bindTexture(H.TEXTURE_2D,F.texture);let V={u_matrix:b.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-L.coordsIndex.length)/255,u_texture:0,u_ele_delta:L.getMeshFrameDelta(b.transform.zoom)};Z.draw(E,H.TRIANGLES,I,Xi.disabled,h,Yi.backCCW,V,P,"terrain",_.vertexBuffer,_.indexBuffer,_.segments),L.coordsIndex.push(N.tileID.key)}E.bindFramebuffer.set(null),E.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain))}renderLayer(n,c,p,f){if(!p.isHidden(this.transform.zoom)&&(p.type==="background"||p.type==="custom"||(f||[]).length))switch(this.id=p.id,p.type){case"symbol":(function(b,L,E,H,h){if(b.renderPass!=="translucent")return;let I=Xi.disabled,_=b.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(F,R,Z,N,P,V,X){let J=R.transform,ot=P==="map",pt=V==="map";for(let ut of F){let Gt=N.getTile(ut),Pt=Gt.getBucket(Z);if(!Pt||!Pt.text||!Pt.text.segments.get().length)continue;let dt=o.ag(Pt.textSizeData,J.zoom),Ct=Ui(Gt,1,R.transform.zoom),ee=tr(ut.posMatrix,pt,ot,R.transform,Ct),ge=Z.layout.get("icon-text-fit")!=="none"&&Pt.hasIconData();if(dt){let jt=Math.pow(2,J.zoom-Gt.tileID.overscaledZ);Zs(Pt,ot,pt,X,J,ee,ut.posMatrix,jt,dt,ge,R.style.map.terrain?(Fe,ke)=>R.style.map.terrain.getElevation(ut,Fe,ke):null)}}}(H,b,E,L,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),h),E.paint.get("icon-opacity").constantOr(1)!==0&&bA(b,L,E,H,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),I,_),E.paint.get("text-opacity").constantOr(1)!==0&&bA(b,L,E,H,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),I,_),L.map.showCollisionBoxes&&(hn(b,L,E,H,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),!0),hn(b,L,E,H,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),!1))})(n,c,p,f,this.style.placement.variableOffsets);break;case"circle":(function(b,L,E,H){if(b.renderPass!=="translucent")return;let h=E.paint.get("circle-opacity"),I=E.paint.get("circle-stroke-width"),_=E.paint.get("circle-stroke-opacity"),F=!E.layout.get("circle-sort-key").isConstant();if(h.constantOr(1)===0&&(I.constantOr(1)===0||_.constantOr(1)===0))return;let R=b.context,Z=R.gl,N=b.depthModeForSublayer(0,Ci.ReadOnly),P=Xi.disabled,V=b.colorModeForRenderPass(),X=[];for(let J=0;JJ.sortKey-ot.sortKey);for(let J of X){let{programConfiguration:ot,program:pt,layoutVertexBuffer:ut,indexBuffer:Gt,uniformValues:Pt,terrainData:dt}=J.state;pt.draw(R,Z.TRIANGLES,N,P,V,Yi.disabled,Pt,dt,E.id,ut,Gt,J.segments,E.paint,b.transform.zoom,ot)}})(n,c,p,f);break;case"heatmap":(function(b,L,E,H){if(E.paint.get("heatmap-opacity")!==0)if(b.renderPass==="offscreen"){let h=b.context,I=h.gl,_=Xi.disabled,F=new xi([I.ONE,I.ONE],o.aO.transparent,[!0,!0,!0,!0]);(function(R,Z,N){let P=R.gl;R.activeTexture.set(P.TEXTURE1),R.viewport.set([0,0,Z.width/4,Z.height/4]);let V=N.heatmapFbo;if(V)P.bindTexture(P.TEXTURE_2D,V.colorAttachment.get()),R.bindFramebuffer.set(V.framebuffer);else{let X=P.createTexture();P.bindTexture(P.TEXTURE_2D,X),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MIN_FILTER,P.LINEAR),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MAG_FILTER,P.LINEAR),V=N.heatmapFbo=R.createFramebuffer(Z.width/4,Z.height/4,!1,!1),function(J,ot,pt,ut){var Gt,Pt;let dt=J.gl,Ct=(Gt=J.HALF_FLOAT)!==null&&Gt!==void 0?Gt:dt.UNSIGNED_BYTE,ee=(Pt=J.RGBA16F)!==null&&Pt!==void 0?Pt:dt.RGBA;dt.texImage2D(dt.TEXTURE_2D,0,ee,ot.width/4,ot.height/4,0,dt.RGBA,Ct,null),ut.colorAttachment.set(pt)}(R,Z,X,V)}})(h,b,E),h.clear({color:o.aO.transparent});for(let R=0;R{let J=o.F();o.aN(J,0,N.width,N.height,0,0,1);let ot=N.context.gl;return{u_matrix:J,u_world:[ot.drawingBufferWidth,ot.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:P.paint.get("heatmap-opacity")}})(h,I),null,I.id,h.viewportBuffer,h.quadTriangleIndexBuffer,h.viewportSegments,I.paint,h.transform.zoom)}(b,E))})(n,c,p,f);break;case"line":(function(b,L,E,H){if(b.renderPass!=="translucent")return;let h=E.paint.get("line-opacity"),I=E.paint.get("line-width");if(h.constantOr(1)===0||I.constantOr(1)===0)return;let _=b.depthModeForSublayer(0,Ci.ReadOnly),F=b.colorModeForRenderPass(),R=E.paint.get("line-dasharray"),Z=E.paint.get("line-pattern"),N=Z.constantOr(1),P=E.paint.get("line-gradient"),V=E.getCrossfadeParameters(),X=N?"linePattern":R?"lineSDF":P?"lineGradient":"line",J=b.context,ot=J.gl,pt=!0;for(let ut of H){let Gt=L.getTile(ut);if(N&&!Gt.patternsLoaded())continue;let Pt=Gt.getBucket(E);if(!Pt)continue;let dt=Pt.programConfigurations.get(E.id),Ct=b.context.program.get(),ee=b.useProgram(X,dt),ge=pt||ee.program!==Ct,jt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(ut),Fe=Z.constantOr(null);if(Fe&&Gt.imageAtlas){let xe=Gt.imageAtlas,ci=xe.patternPositions[Fe.to.toString()],pi=xe.patternPositions[Fe.from.toString()];ci&&pi&&dt.setConstantPatternPositions(ci,pi)}let ke=jt?ut:null,Ye=N?ai(b,Gt,E,V,ke):R?dr(b,Gt,E,R,V,ke):P?nr(b,Gt,E,Pt.lineClipsArray.length,ke):Wi(b,Gt,E,ke);if(N)J.activeTexture.set(ot.TEXTURE0),Gt.imageAtlasTexture.bind(ot.LINEAR,ot.CLAMP_TO_EDGE),dt.updatePaintBuffers(V);else if(R&&(ge||b.lineAtlas.dirty))J.activeTexture.set(ot.TEXTURE0),b.lineAtlas.bind(J);else if(P){let xe=Pt.gradients[E.id],ci=xe.texture;if(E.gradientVersion!==xe.version){let pi=256;if(E.stepInterpolant){let Mi=L.getSource().maxzoom,Si=ut.canonical.z===Mi?Math.ceil(1<0?c.pop():null}isPatternMissing(n){if(!n)return!1;if(!n.from||!n.to)return!0;let c=this.imageManager.getPattern(n.from.toString()),p=this.imageManager.getPattern(n.to.toString());return!c||!p}useProgram(n,c){this.cache=this.cache||{};let p=n+(c?c.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[p]||(this.cache[p]=new ae(this.context,ct[n],c,el[n],this._showOverdrawInspector,this.style.map.terrain)),this.cache[p]}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(){let n=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(n.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new qt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:n,drawingBufferHeight:c}=this.context.gl;return this.width!==n||this.height!==c}}class As{constructor(n,c){this.points=n,this.planes=c}static fromInvProjectionMatrix(n,c,p){let f=Math.pow(2,p),b=[[-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(E=>{let H=1/(E=o.af([],E,n))[3]/c*f;return o.a$(E,E,[H,H,1/E[3],H])}),L=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let H=function(F,R){var Z=R[0],N=R[1],P=R[2],V=Z*Z+N*N+P*P;return V>0&&(V=1/Math.sqrt(V)),F[0]=R[0]*V,F[1]=R[1]*V,F[2]=R[2]*V,F}([],function(F,R,Z){var N=R[0],P=R[1],V=R[2],X=Z[0],J=Z[1],ot=Z[2];return F[0]=P*ot-V*J,F[1]=V*X-N*ot,F[2]=N*J-P*X,F}([],Ft([],b[E[0]],b[E[1]]),Ft([],b[E[2]],b[E[1]]))),h=-((I=H)[0]*(_=b[E[1]])[0]+I[1]*_[1]+I[2]*_[2]);var I,_;return H.concat(h)});return new As(b,L)}}class Sn{constructor(n,c){this.min=n,this.max=c,this.center=function(p,f,b){return p[0]=.5*f[0],p[1]=.5*f[1],p[2]=.5*f[2],p}([],function(p,f,b){return p[0]=f[0]+b[0],p[1]=f[1]+b[1],p[2]=f[2]+b[2],p}([],this.min,this.max))}quadrant(n){let c=[n%2==0,n<2],p=Tt(this.min),f=Tt(this.max);for(let b=0;b=0&&L++;if(L===0)return 0;L!==c.length&&(p=!1)}if(p)return 2;for(let f=0;f<3;f++){let b=Number.MAX_VALUE,L=-Number.MAX_VALUE;for(let E=0;Ethis.max[f]-this.min[f])return 0}return 1}}class is{constructor(n=0,c=0,p=0,f=0){if(isNaN(n)||n<0||isNaN(c)||c<0||isNaN(p)||p<0||isNaN(f)||f<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=n,this.bottom=c,this.left=p,this.right=f}interpolate(n,c,p){return c.top!=null&&n.top!=null&&(this.top=o.z.number(n.top,c.top,p)),c.bottom!=null&&n.bottom!=null&&(this.bottom=o.z.number(n.bottom,c.bottom,p)),c.left!=null&&n.left!=null&&(this.left=o.z.number(n.left,c.left,p)),c.right!=null&&n.right!=null&&(this.right=o.z.number(n.right,c.right,p)),this}getCenter(n,c){let p=o.ac((this.left+n-this.right)/2,0,n),f=o.ac((this.top+c-this.bottom)/2,0,c);return new o.P(p,f)}equals(n){return this.top===n.top&&this.bottom===n.bottom&&this.left===n.left&&this.right===n.right}clone(){return new is(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let Eo=85.051129;class _s{constructor(n,c,p,f,b){this.tileSize=512,this._renderWorldCopies=b===void 0||!!b,this._minZoom=n||0,this._maxZoom=c||22,this._minPitch=p??0,this._maxPitch=f??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new is,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let n=new _s(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return n.apply(this),n}apply(n){this.tileSize=n.tileSize,this.latRange=n.latRange,this.width=n.width,this.height=n.height,this._center=n._center,this._elevation=n._elevation,this.minElevationForCurrentTile=n.minElevationForCurrentTile,this.zoom=n.zoom,this.angle=n.angle,this._fov=n._fov,this._pitch=n._pitch,this._unmodified=n._unmodified,this._edgeInsets=n._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(n){this._minZoom!==n&&(this._minZoom=n,this.zoom=Math.max(this.zoom,n))}get maxZoom(){return this._maxZoom}set maxZoom(n){this._maxZoom!==n&&(this._maxZoom=n,this.zoom=Math.min(this.zoom,n))}get minPitch(){return this._minPitch}set minPitch(n){this._minPitch!==n&&(this._minPitch=n,this.pitch=Math.max(this.pitch,n))}get maxPitch(){return this._maxPitch}set maxPitch(n){this._maxPitch!==n&&(this._maxPitch=n,this.pitch=Math.min(this.pitch,n))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(n){n===void 0?n=!0:n===null&&(n=!1),this._renderWorldCopies=n}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(n){let c=-o.b1(n,-180,180)*Math.PI/180;this.angle!==c&&(this._unmodified=!1,this.angle=c,this._calcMatrices(),this.rotationMatrix=function(){var p=new o.A(4);return o.A!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p}(),function(p,f,b){var L=f[0],E=f[1],H=f[2],h=f[3],I=Math.sin(b),_=Math.cos(b);p[0]=L*_+H*I,p[1]=E*_+h*I,p[2]=L*-I+H*_,p[3]=E*-I+h*_}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(n){let c=o.ac(n,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==c&&(this._unmodified=!1,this._pitch=c,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(n){n=Math.max(.01,Math.min(60,n)),this._fov!==n&&(this._unmodified=!1,this._fov=n/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(n){let c=Math.min(Math.max(n,this.minZoom),this.maxZoom);this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this.tileZoom=Math.max(0,Math.floor(c)),this.scale=this.zoomScale(c),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(n){n.lat===this._center.lat&&n.lng===this._center.lng||(this._unmodified=!1,this._center=n,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(n){n!==this._elevation&&(this._elevation=n,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(n){this._edgeInsets.equals(n)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,n,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(n){return this._edgeInsets.equals(n)}interpolatePadding(n,c,p){this._unmodified=!1,this._edgeInsets.interpolate(n,c,p),this._constrain(),this._calcMatrices()}coveringZoomLevel(n){let c=(n.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/n.tileSize));return Math.max(0,c)}getVisibleUnwrappedCoordinates(n){let c=[new o.b2(0,n)];if(this._renderWorldCopies){let p=this.pointCoordinate(new o.P(0,0)),f=this.pointCoordinate(new o.P(this.width,0)),b=this.pointCoordinate(new o.P(this.width,this.height)),L=this.pointCoordinate(new o.P(0,this.height)),E=Math.floor(Math.min(p.x,f.x,b.x,L.x)),H=Math.floor(Math.max(p.x,f.x,b.x,L.x)),h=1;for(let I=E-h;I<=H+h;I++)I!==0&&c.push(new o.b2(I,n))}return c}coveringTiles(n){var c,p;let f=this.coveringZoomLevel(n),b=f;if(n.minzoom!==void 0&&fn.maxzoom&&(f=n.maxzoom);let L=this.pointCoordinate(this.getCameraPoint()),E=o.Y.fromLngLat(this.center),H=Math.pow(2,f),h=[H*L.x,H*L.y,0],I=[H*E.x,H*E.y,0],_=As.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,f),F=n.minzoom||0;!n.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(F=f);let R=n.terrain?2/Math.min(this.tileSize,n.tileSize)*this.tileSize:3,Z=J=>({aabb:new Sn([J*H,0,0],[(J+1)*H,H,0]),zoom:0,x:0,y:0,wrap:J,fullyVisible:!1}),N=[],P=[],V=f,X=n.reparseOverscaled?b:f;if(this._renderWorldCopies)for(let J=1;J<=3;J++)N.push(Z(-J)),N.push(Z(J));for(N.push(Z(0));N.length>0;){let J=N.pop(),ot=J.x,pt=J.y,ut=J.fullyVisible;if(!ut){let ee=J.aabb.intersects(_);if(ee===0)continue;ut=ee===2}let Gt=n.terrain?h:I,Pt=J.aabb.distanceX(Gt),dt=J.aabb.distanceY(Gt),Ct=Math.max(Math.abs(Pt),Math.abs(dt));if(J.zoom===V||Ct>R+(1<=F){let ee=V-J.zoom,ge=h[0]-.5-(ot<>1),Fe=J.zoom+1,ke=J.aabb.quadrant(ee);if(n.terrain){let Ye=new o.Q(Fe,J.wrap,Fe,ge,jt),xe=n.terrain.getMinMaxElevation(Ye),ci=(c=xe.minElevation)!==null&&c!==void 0?c:this.elevation,pi=(p=xe.maxElevation)!==null&&p!==void 0?p:this.elevation;ke=new Sn([ke.min[0],ke.min[1],ci],[ke.max[0],ke.max[1],pi])}N.push({aabb:ke,zoom:Fe,x:ge,y:jt,wrap:J.wrap,fullyVisible:ut})}}return P.sort((J,ot)=>J.distanceSq-ot.distanceSq).map(J=>J.tileID)}resize(n,c){this.width=n,this.height=c,this.pixelsToGLUnits=[2/n,-2/c],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(n){return Math.pow(2,n)}scaleZoom(n){return Math.log(n)/Math.LN2}project(n){let c=o.ac(n.lat,-85.051129,Eo);return new o.P(o.N(n.lng)*this.worldSize,o.O(c)*this.worldSize)}unproject(n){return new o.Y(n.x/this.worldSize,n.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(n){let c=this.elevation,p=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,f=this.pointLocation(this.centerPoint,n),b=n.getElevationForLngLatZoom(f,this.tileZoom);if(!(this.elevation-b))return;let L=p+c-b,E=Math.cos(this._pitch)*this.cameraToCenterDistance/L/o.b3(1,f.lat),H=this.scaleZoom(E/this.tileSize);this._elevation=b,this._center=f,this.zoom=H}setLocationAtPoint(n,c){let p=this.pointCoordinate(c),f=this.pointCoordinate(this.centerPoint),b=this.locationCoordinate(n),L=new o.Y(b.x-(p.x-f.x),b.y-(p.y-f.y));this.center=this.coordinateLocation(L),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(n,c){return c?this.coordinatePoint(this.locationCoordinate(n),c.getElevationForLngLatZoom(n,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(n))}pointLocation(n,c){return this.coordinateLocation(this.pointCoordinate(n,c))}locationCoordinate(n){return o.Y.fromLngLat(n)}coordinateLocation(n){return n&&n.toLngLat()}pointCoordinate(n,c){if(c){let F=c.pointCoordinate(n);if(F!=null)return F}let p=[n.x,n.y,0,1],f=[n.x,n.y,1,1];o.af(p,p,this.pixelMatrixInverse),o.af(f,f,this.pixelMatrixInverse);let b=p[3],L=f[3],E=p[1]/b,H=f[1]/L,h=p[2]/b,I=f[2]/L,_=h===I?0:(0-h)/(I-h);return new o.Y(o.z.number(p[0]/b,f[0]/L,_)/this.worldSize,o.z.number(E,H,_)/this.worldSize)}coordinatePoint(n,c=0,p=this.pixelMatrix){let f=[n.x*this.worldSize,n.y*this.worldSize,c,1];return o.af(f,f,p),new o.P(f[0]/f[3],f[1]/f[3])}getBounds(){let n=Math.max(0,this.height/2-this.getHorizon());return new Me().extend(this.pointLocation(new o.P(0,n))).extend(this.pointLocation(new o.P(this.width,n))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Me([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(n){n?(this.lngRange=[n.getWest(),n.getEast()],this.latRange=[n.getSouth(),n.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Eo])}calculatePosMatrix(n,c=!1){let p=n.key,f=c?this._alignedPosMatrixCache:this._posMatrixCache;if(f[p])return f[p];let b=n.canonical,L=this.worldSize/this.zoomScale(b.z),E=b.x+Math.pow(2,b.z)*n.wrap,H=o.an(new Float64Array(16));return o.H(H,H,[E*L,b.y*L,0]),o.J(H,H,[L/o.W,L/o.W,1]),o.K(H,c?this.alignedProjMatrix:this.projMatrix,H),f[p]=new Float32Array(H),f[p]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(n,c){c=o.ac(+c,this.minZoom,this.maxZoom);let p={center:new o.M(n.lng,n.lat),zoom:c},f=this.lngRange;if(!this._renderWorldCopies&&f===null){let J=179.9999999999;f=[-J,J]}let b=this.tileSize*this.zoomScale(p.zoom),L=0,E=b,H=0,h=b,I=0,_=0,{x:F,y:R}=this.size;if(this.latRange){let J=this.latRange;L=o.O(J[1])*b,E=o.O(J[0])*b,E-LE&&(V=E-J)}if(f){let J=(H+h)/2,ot=Z;this._renderWorldCopies&&(ot=o.b1(Z,J-b/2,J+b/2));let pt=F/2;ot-pth&&(P=h-pt)}if(P!==void 0||V!==void 0){let J=new o.P(P??Z,V??N);p.center=this.unproject.call({worldSize:b},J).wrap()}return p}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let n=this._unmodified,{center:c,zoom:p}=this.getConstrained(this.center,this.zoom);this.center=c,this.zoom=p,this._unmodified=n,this._constraining=!1}_calcMatrices(){if(!this.height)return;let n=this.centerOffset,c=this.point.x,p=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b3(1,this.center.lat)*this.worldSize;let f=o.an(new Float64Array(16));o.J(f,f,[this.width/2,-this.height/2,1]),o.H(f,f,[1,-1,0]),this.labelPlaneMatrix=f,f=o.an(new Float64Array(16)),o.J(f,f,[1,-1,1]),o.H(f,f,[-1,-1,0]),o.J(f,f,[2/this.width,2/this.height,1]),this.glCoordMatrix=f;let b=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),L=Math.min(this.elevation,this.minElevationForCurrentTile),E=b-L*this._pixelPerMeter/Math.cos(this._pitch),H=L<0?E:b,h=Math.PI/2+this._pitch,I=this._fov*(.5+n.y/this.height),_=Math.sin(I)*H/Math.sin(o.ac(Math.PI-h-I,.01,Math.PI-.01)),F=this.getHorizon(),R=2*Math.atan(F/this.cameraToCenterDistance)*(.5+n.y/(2*F)),Z=Math.sin(R)*H/Math.sin(o.ac(Math.PI-h-R,.01,Math.PI-.01)),N=Math.min(_,Z),P=1.01*(Math.cos(Math.PI/2-this._pitch)*N+H),V=this.height/50;f=new Float64Array(16),o.b4(f,this._fov,this.width/this.height,V,P),f[8]=2*-n.x/this.width,f[9]=2*n.y/this.height,o.J(f,f,[1,-1,1]),o.H(f,f,[0,0,-this.cameraToCenterDistance]),o.b5(f,f,this._pitch),o.ad(f,f,this.angle),o.H(f,f,[-c,-p,0]),this.mercatorMatrix=o.J([],f,[this.worldSize,this.worldSize,this.worldSize]),o.J(f,f,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.K(new Float64Array(16),this.labelPlaneMatrix,f),o.H(f,f,[0,0,-this.elevation]),this.projMatrix=f,this.invProjMatrix=o.ar([],f),this.pixelMatrix3D=o.K(new Float64Array(16),this.labelPlaneMatrix,f);let X=this.width%2/2,J=this.height%2/2,ot=Math.cos(this.angle),pt=Math.sin(this.angle),ut=c-Math.round(c)+ot*X+pt*J,Gt=p-Math.round(p)+ot*J+pt*X,Pt=new Float64Array(f);if(o.H(Pt,Pt,[ut>.5?ut-1:ut,Gt>.5?Gt-1:Gt,0]),this.alignedProjMatrix=Pt,f=o.ar(new Float64Array(16),this.pixelMatrix),!f)throw new Error("failed to invert matrix");this.pixelMatrixInverse=f,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let n=this.pointCoordinate(new o.P(0,0)),c=[n.x*this.worldSize,n.y*this.worldSize,0,1];return o.af(c,c,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let n=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,n))}getCameraQueryGeometry(n){let c=this.getCameraPoint();if(n.length===1)return[n[0],c];{let p=c.x,f=c.y,b=c.x,L=c.y;for(let E of n)p=Math.min(p,E.x),f=Math.min(f,E.y),b=Math.max(b,E.x),L=Math.max(L,E.y);return[new o.P(p,f),new o.P(b,f),new o.P(b,L),new o.P(p,L),new o.P(p,f)]}}lngLatToCameraDepth(n,c){let p=this.locationCoordinate(n),f=[p.x*this.worldSize,p.y*this.worldSize,c,1];return o.af(f,f,this.projMatrix),f[2]/f[3]}}function ro(y,n){let c,p=!1,f=null,b=null,L=()=>{f=null,p&&(y.apply(b,c),f=setTimeout(L,n),p=!1)};return(...E)=>(p=!0,b=this,c=E,f||L(),f)}class ma{constructor(n){this._getCurrentHash=()=>{let c=window.location.hash.replace("#","");if(this._hashName){let p;return c.split("&").map(f=>f.split("=")).forEach(f=>{f[0]===this._hashName&&(p=f)}),(p&&p[1]||"").split("/")}return c.split("/")},this._onHashChange=()=>{let c=this._getCurrentHash();if(c.length>=3&&!c.some(p=>isNaN(p))){let p=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(c[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+c[2],+c[1]],zoom:+c[0],bearing:p,pitch:+(c[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let c=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,c)}catch{}},this._updateHash=ro(this._updateHashUnthrottled,300),this._hashName=n&&encodeURIComponent(n)}addTo(n){return this._map=n,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(n){let c=this._map.getCenter(),p=Math.round(100*this._map.getZoom())/100,f=Math.ceil((p*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.pow(10,f),L=Math.round(c.lng*b)/b,E=Math.round(c.lat*b)/b,H=this._map.getBearing(),h=this._map.getPitch(),I="";if(I+=n?`/${L}/${E}/${p}`:`${p}/${E}/${L}`,(H||h)&&(I+="/"+Math.round(10*H)/10),h&&(I+=`/${Math.round(h)}`),this._hashName){let _=this._hashName,F=!1,R=window.location.hash.slice(1).split("&").map(Z=>{let N=Z.split("=")[0];return N===_?(F=!0,`${N}=${I}`):Z}).filter(Z=>Z);return F||R.push(`${_}=${I}`),`#${R.join("&")}`}return`#${I}`}}let fn={linearity:.3,easing:o.b6(0,0,.3,1)},Ha=o.e({deceleration:2500,maxSpeed:1400},fn),vA=o.e({deceleration:20,maxSpeed:1400},fn),ta=o.e({deceleration:1e3,maxSpeed:360},fn),Ms=o.e({deceleration:1e3,maxSpeed:90},fn);class To{constructor(n){this._map=n,this.clear()}clear(){this._inertiaBuffer=[]}record(n){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:v.now(),settings:n})}_drainInertiaBuffer(){let n=this._inertiaBuffer,c=v.now();for(;n.length>0&&c-n[0].time>160;)n.shift()}_onMoveEnd(n){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let c={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:b}of this._inertiaBuffer)c.zoom+=b.zoomDelta||0,c.bearing+=b.bearingDelta||0,c.pitch+=b.pitchDelta||0,b.panDelta&&c.pan._add(b.panDelta),b.around&&(c.around=b.around),b.pinchAround&&(c.pinchAround=b.pinchAround);let p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){let b=Uo(c.pan.mag(),p,o.e({},Ha,n||{}));f.offset=c.pan.mult(b.amount/c.pan.mag()),f.center=this._map.transform.center,no(f,b)}if(c.zoom){let b=Uo(c.zoom,p,vA);f.zoom=this._map.transform.zoom+b.amount,no(f,b)}if(c.bearing){let b=Uo(c.bearing,p,ta);f.bearing=this._map.transform.bearing+o.ac(b.amount,-179,179),no(f,b)}if(c.pitch){let b=Uo(c.pitch,p,Ms);f.pitch=this._map.transform.pitch+b.amount,no(f,b)}if(f.zoom||f.bearing){let b=c.pinchAround===void 0?c.around:c.pinchAround;f.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),o.e(f,{noMoveStart:!0})}}function no(y,n){(!y.duration||y.durationc.unproject(H)),E=b.reduce((H,h,I,_)=>H.add(h.div(_.length)),new o.P(0,0));super(n,{points:b,point:E,lngLats:L,lngLat:c.unproject(E),originalEvent:p}),this._defaultPrevented=!1}}class zn extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(n,c,p){super(n,{originalEvent:p}),this._defaultPrevented=!1}}class gn{constructor(n,c){this._map=n,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(n){return this._firePreventable(new zn(n.type,this._map,n))}mousedown(n,c){return this._mousedownPos=c,this._firePreventable(new Jr(n.type,this._map,n))}mouseup(n){this._map.fire(new Jr(n.type,this._map,n))}click(n,c){this._mousedownPos&&this._mousedownPos.dist(c)>=this._clickTolerance||this._map.fire(new Jr(n.type,this._map,n))}dblclick(n){return this._firePreventable(new Jr(n.type,this._map,n))}mouseover(n){this._map.fire(new Jr(n.type,this._map,n))}mouseout(n){this._map.fire(new Jr(n.type,this._map,n))}touchstart(n){return this._firePreventable(new xs(n.type,this._map,n))}touchmove(n){this._map.fire(new xs(n.type,this._map,n))}touchend(n){this._map.fire(new xs(n.type,this._map,n))}touchcancel(n){this._map.fire(new xs(n.type,this._map,n))}_firePreventable(n){if(this._map.fire(n),n.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Qo{constructor(n){this._map=n}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(n){this._map.fire(new Jr(n.type,this._map,n))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(n){this._delayContextMenu?this._contextMenuEvent=n:this._ignoreContextMenu||this._map.fire(new Jr(n.type,this._map,n)),this._map.listens("contextmenu")&&n.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{constructor(n){this._map=n}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(n){return this.transform.pointLocation(o.P.convert(n),this._map.terrain)}}class Fr{constructor(n,c){this._map=n,this._tr=new pr(n),this._el=n.getCanvasContainer(),this._container=n.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(n,c){this.isEnabled()&&n.shiftKey&&n.button===0&&(x.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(n,c){if(!this._active)return;let p=c;if(this._lastPos.equals(p)||!this._box&&p.dist(this._startPos)b.fitScreenCoordinates(p,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",n)}keydown(n){this._active&&n.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",n))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(x.remove(this._box),this._box=null),x.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(n,c){return this._map.fire(new o.k(n,{originalEvent:c}))}}function en(y,n){if(y.length!==n.length)throw new Error(`The number of touches and points are not equal - touches ${y.length}, points ${n.length}`);let c={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=n.timeStamp),p.length===this.numTouches&&(this.centroid=function(f){let b=new o.P(0,0);for(let L of f)b._add(L);return b.div(f.length)}(c),this.touches=en(p,c)))}touchmove(n,c,p){if(this.aborted||!this.centroid)return;let f=en(p,c);for(let b in this.touches){let L=f[b];(!L||L.dist(this.touches[b])>30)&&(this.aborted=!0)}}touchend(n,c,p){if((!this.centroid||n.timeStamp-this.startTime>500)&&(this.aborted=!0),p.length===0){let f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class so{constructor(n){this.singleTap=new yn(n),this.numTaps=n.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(n,c,p){this.singleTap.touchstart(n,c,p)}touchmove(n,c,p){this.singleTap.touchmove(n,c,p)}touchend(n,c,p){let f=this.singleTap.touchend(n,c,p);if(f){let b=n.timeStamp-this.lastTime<500,L=!this.lastTap||this.lastTap.dist(f)<30;if(b&&L||this.reset(),this.count++,this.lastTime=n.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class ea{constructor(n){this._tr=new pr(n),this._zoomIn=new so({numTouches:1,numTaps:2}),this._zoomOut=new so({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(n,c,p){this._zoomIn.touchstart(n,c,p),this._zoomOut.touchstart(n,c,p)}touchmove(n,c,p){this._zoomIn.touchmove(n,c,p),this._zoomOut.touchmove(n,c,p)}touchend(n,c,p){let f=this._zoomIn.touchend(n,c,p),b=this._zoomOut.touchend(n,c,p),L=this._tr;return f?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:L.zoom+1,around:L.unproject(f)},{originalEvent:n})}):b?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:L.zoom-1,around:L.unproject(b)},{originalEvent:n})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ls{constructor(n){this._enabled=!!n.enable,this._moveStateManager=n.moveStateManager,this._clickTolerance=n.clickTolerance||1,this._moveFunction=n.move,this._activateOnStart=!!n.activateOnStart,n.assignEvents(this),this.reset()}reset(n){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(n)}_move(...n){let c=this._moveFunction(...n);if(c.bearingDelta||c.pitchDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(n,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(n)&&(this._moveStateManager.startMove(n),this._lastPoint=c.length?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(n,c){if(!this.isEnabled())return;let p=this._lastPoint;if(!p)return;if(n.preventDefault(),!this._moveStateManager.isValidMoveEvent(n))return void this.reset(n);let f=c.length?c[0]:c;return!this._moved&&f.dist(p){y.mousedown=y.dragStart,y.mousemoveWindow=y.dragMove,y.mouseup=y.dragEnd,y.contextmenu=function(n){n.preventDefault()}},Za=({enable:y,clickTolerance:n,bearingDegreesPerPixelMoved:c=.8})=>{let p=new si({checkCorrectEvent:f=>x.mouseButton(f)===0&&f.ctrlKey||x.mouseButton(f)===2});return new ls({clickTolerance:n,move:(f,b)=>({bearingDelta:(b.x-f.x)*c}),moveStateManager:p,enable:y,assignEvents:Ca})},Ql=({enable:y,clickTolerance:n,pitchDegreesPerPixelMoved:c=-.5})=>{let p=new si({checkCorrectEvent:f=>x.mouseButton(f)===0&&f.ctrlKey||x.mouseButton(f)===2});return new ls({clickTolerance:n,move:(f,b)=>({pitchDelta:(b.y-f.y)*c}),moveStateManager:p,enable:y,assignEvents:Ca})};class ei{constructor(n,c){this._clickTolerance=n.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(n,c,p){return this._calculateTransform(n,c,p)}touchmove(n,c,p){if(this._active&&!(p.length0&&(this._active=!0);let f=en(p,c),b=new o.P(0,0),L=new o.P(0,0),E=0;for(let h in f){let I=f[h],_=this._touches[h];_&&(b._add(I),L._add(I.sub(_)),E++,f[h]=I)}if(this._touches=f,EMath.abs(y.x)}class ol extends Pa{constructor(n){super(),this._currentTouchCount=0,this._map=n}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(n,c,p){super.touchstart(n,c,p),this._currentTouchCount=p.length}_start(n){this._lastPoints=n,Gl(n[0].sub(n[1]))&&(this._valid=!1)}_move(n,c,p){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let f=n[0].sub(this._lastPoints[0]),b=n[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(f,b,p.timeStamp),this._valid?(this._lastPoints=n,this._active=!0,{pitchDelta:(f.y+b.y)/2*-.5}):void 0}gestureBeginsVertically(n,c,p){if(this._valid!==void 0)return this._valid;let f=n.mag()>=2,b=c.mag()>=2;if(!f&&!b)return;if(!f||!b)return this._firstMove===void 0&&(this._firstMove=p),p-this._firstMove<100&&void 0;let L=n.y>0==c.y>0;return Gl(n)&&Gl(c)&&L}}let Go={panStep:100,bearingStep:15,pitchStep:10};class Pr{constructor(n){this._tr=new pr(n);let c=Go;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(n){if(n.altKey||n.ctrlKey||n.metaKey)return;let c=0,p=0,f=0,b=0,L=0;switch(n.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:n.shiftKey?p=-1:(n.preventDefault(),b=-1);break;case 39:n.shiftKey?p=1:(n.preventDefault(),b=1);break;case 38:n.shiftKey?f=1:(n.preventDefault(),L=-1);break;case 40:n.shiftKey?f=-1:(n.preventDefault(),L=1);break;default:return}return this._rotationDisabled&&(p=0,f=0),{cameraAnimation:E=>{let H=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:c?Math.round(H.zoom)+c*(n.shiftKey?2:1):H.zoom,bearing:H.bearing+p*this._bearingStep,pitch:H.pitch+f*this._pitchStep,offset:[-b*this._panStep,-L*this._panStep],center:H.center},{originalEvent:n})}}}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 al(y){return y*(2-y)}let _A=4.000244140625;class Al{constructor(n,c){this._onTimeout=p=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(p)},this._map=n,this._tr=new pr(n),this._triggerRenderFrame=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(n){this._defaultZoomRate=n}setWheelZoomRate(n){this._wheelZoomRate=n}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(n){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!n&&n.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(n){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!n[this._map.cooperativeGestures._bypassKey])return;let c=n.deltaMode===WheelEvent.DOM_DELTA_LINE?40*n.deltaY:n.deltaY,p=v.now(),f=p-(this._lastWheelEventTime||0);this._lastWheelEventTime=p,c!==0&&c%_A==0?this._type="wheel":c!==0&&Math.abs(c)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,n)):this._type||(this._type=Math.abs(f*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),n.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=n,this._delta-=c,this._active||this._start(n)),n.preventDefault()}_start(n){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);let c=x.mousePos(this._map.getCanvas(),n),p=this._tr;this._around=c.y>p.transform.height/2-p.transform.getHorizon()?o.M.convert(this._aroundCenter?p.center:p.unproject(c)):o.M.convert(p.center),this._aroundPoint=p.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let n=this._tr.transform;if(this._delta!==0){let E=this._type==="wheel"&&Math.abs(this._delta)>_A?this._wheelZoomRate:this._defaultZoomRate,H=2/(1+Math.exp(-Math.abs(this._delta*E)));this._delta<0&&H!==0&&(H=1/H);let h=typeof this._targetZoom=="number"?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(h*H))),this._type==="wheel"&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:n.zoom,p=this._startZoom,f=this._easing,b,L=!1;if(this._type==="wheel"&&p&&f){let E=Math.min((v.now()-this._lastWheelEventTime)/200,1),H=f(E);b=o.z.number(p,c,H),E<1?this._frameId||(this._frameId=!0):L=!0}else b=c,L=!0;return this._active=!0,L&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!L,zoomDelta:b-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(n){let c=o.b7;if(this._prevEase){let p=this._prevEase,f=(v.now()-p.start)/p.duration,b=p.easing(f+.01)-p.easing(f),L=.27/Math.sqrt(b*b+1e-4)*.01,E=Math.sqrt(.0729-L*L);c=o.b6(L,E,.25,1)}return this._prevEase={start:v.now(),duration:n,easing:c},c}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class xA{constructor(n,c){this._clickZoom=n,this._tapZoom=c}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 Rl{constructor(n){this._tr=new pr(n),this.reset()}reset(){this._active=!1}dblclick(n,c){return n.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:this._tr.zoom+(n.shiftKey?-1:1),around:this._tr.unproject(c)},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dh{constructor(){this._tap=new so({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(n,c,p){if(!this._swipePoint)if(this._tapTime){let f=c[0],b=n.timeStamp-this._tapTime<500,L=this._tapPoint.dist(f)<30;b&&L?p.length>0&&(this._swipePoint=f,this._swipeTouch=p[0].identifier):this.reset()}else this._tap.touchstart(n,c,p)}touchmove(n,c,p){if(this._tapTime){if(this._swipePoint){if(p[0].identifier!==this._swipeTouch)return;let f=c[0],b=f.y-this._swipePoint.y;return this._swipePoint=f,n.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(n,c,p)}touchend(n,c,p){if(this._tapTime)this._swipePoint&&p.length===0&&this.reset();else{let f=this._tap.touchend(n,c,p);f&&(this._tapTime=n.timeStamp,this._tapPoint=f)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ao{constructor(n,c,p){this._el=n,this._mousePan=c,this._touchPan=p}enable(n){this._inertiaOptions=n||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class SA{constructor(n,c,p){this._pitchWithRotate=n.pitchWithRotate,this._mouseRotate=c,this._mousePitch=p}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 wi{constructor(n,c,p,f){this._el=n,this._touchZoom=c,this._touchRotate=p,this._tapDragZoom=f,this._rotationDisabled=!1,this._enabled=!0}enable(n){this._touchZoom.enable(n),this._rotationDisabled||this._touchRotate.enable(n),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Hi{constructor(n,c){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=n,this._options=c,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let n=this._map.getCanvasContainer();n.classList.add("maplibregl-cooperative-gestures"),this._container=x.create("div","maplibregl-cooperative-gesture-screen",n);let c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let p=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),f=document.createElement("div");f.className="maplibregl-desktop-message",f.textContent=c,this._container.appendChild(f);let b=document.createElement("div");b.className="maplibregl-mobile-message",b.textContent=p,this._container.appendChild(b),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(x.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destoryUI()}isEnabled(){return this._enabled}touchmove(n){this._onCooperativeGesture(n.touches.length===1)}wheel(n){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!n[this._bypassKey])}_onCooperativeGesture(n){this._enabled&&n&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let Na=y=>y.zoom||y.drag||y.pitch||y.rotate;class wc extends o.k{}function ll(y){return y.panDelta&&y.panDelta.mag()||y.zoomDelta||y.bearingDelta||y.pitchDelta}class Jn{constructor(n,c){this.handleWindowEvent=f=>{this.handleEvent(f,`${f.type}Window`)},this.handleEvent=(f,b)=>{if(f.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let L=f.type==="renderFrame"?void 0:f,E={needsRenderFrame:!1},H={},h={},I=f.touches,_=I?this._getMapTouches(I):void 0,F=_?x.touchPos(this._map.getCanvas(),_):x.mousePos(this._map.getCanvas(),f);for(let{handlerName:N,handler:P,allowed:V}of this._handlers){if(!P.isEnabled())continue;let X;this._blockedByActive(h,V,N)?P.reset():P[b||f.type]&&(X=P[b||f.type](f,F,_),this.mergeHandlerResult(E,H,X,N,L),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||P.isActive())&&(h[N]=P)}let R={};for(let N in this._previousActiveHandlers)h[N]||(R[N]=L);this._previousActiveHandlers=h,(Object.keys(R).length||ll(E))&&(this._changes.push([E,H,R]),this._triggerRenderFrame()),(Object.keys(h).length||ll(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:Z}=E;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))},this._map=n,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new To(n),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);let p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[window,"blur",void 0]];for(let[f,b,L]of this._listeners)x.addEventListener(f,b,f===document?this.handleWindowEvent:this.handleEvent,L)}destroy(){for(let[n,c,p]of this._listeners)x.removeEventListener(n,c,n===document?this.handleWindowEvent:this.handleEvent,p)}_addDefaultHandlers(n){let c=this._map,p=c.getCanvasContainer();this._add("mapEvent",new gn(c,n));let f=c.boxZoom=new Fr(c,n);this._add("boxZoom",f),n.interactive&&n.boxZoom&&f.enable();let b=c.cooperativeGestures=new Hi(c,n.cooperativeGestures);this._add("cooperativeGestures",b),n.cooperativeGestures&&b.enable();let L=new ea(c),E=new Rl(c);c.doubleClickZoom=new xA(E,L),this._add("tapZoom",L),this._add("clickZoom",E),n.interactive&&n.doubleClickZoom&&c.doubleClickZoom.enable();let H=new dh;this._add("tapDragZoom",H);let h=c.touchPitch=new ol(c);this._add("touchPitch",h),n.interactive&&n.touchPitch&&c.touchPitch.enable(n.touchPitch);let I=Za(n),_=Ql(n);c.dragRotate=new SA(n,I,_),this._add("mouseRotate",I,["mousePitch"]),this._add("mousePitch",_,["mouseRotate"]),n.interactive&&n.dragRotate&&c.dragRotate.enable();let F=(({enable:X,clickTolerance:J})=>{let ot=new si({checkCorrectEvent:pt=>x.mouseButton(pt)===0&&!pt.ctrlKey});return new ls({clickTolerance:J,move:(pt,ut)=>({around:ut,panDelta:ut.sub(pt)}),activateOnStart:!0,moveStateManager:ot,enable:X,assignEvents:Ca})})(n),R=new ei(n,c);c.dragPan=new ao(p,F,R),this._add("mousePan",F),this._add("touchPan",R,["touchZoom","touchRotate"]),n.interactive&&n.dragPan&&c.dragPan.enable(n.dragPan);let Z=new BA,N=new rs;c.touchZoomRotate=new wi(p,N,Z,H),this._add("touchRotate",Z,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),n.interactive&&n.touchZoomRotate&&c.touchZoomRotate.enable(n.touchZoomRotate);let P=c.scrollZoom=new Al(c,()=>this._triggerRenderFrame());this._add("scrollZoom",P,["mousePan"]),n.interactive&&n.scrollZoom&&c.scrollZoom.enable(n.scrollZoom);let V=c.keyboard=new Pr(c);this._add("keyboard",V),n.interactive&&n.keyboard&&c.keyboard.enable(),this._add("blockableMapEvent",new Qo(c))}_add(n,c,p){this._handlers.push({handlerName:n,handler:c,allowed:p}),this._handlersById[n]=c}stop(n){if(!this._updatingCamera){for(let{handler:c}of this._handlers)c.reset();this._inertia.clear(),this._fireEvents({},{},n),this._changes=[]}}isActive(){for(let{handler:n}of this._handlers)if(n.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Na(this._eventsInProgress))||this.isZooming()}_blockedByActive(n,c,p){for(let f in n)if(f!==p&&(!c||c.indexOf(f)<0))return!0;return!1}_getMapTouches(n){let c=[];for(let p of n)this._el.contains(p.target)&&c.push(p);return c}mergeHandlerResult(n,c,p,f,b){if(!p)return;o.e(n,p);let L={handlerName:f,originalEvent:p.originalEvent||b};p.zoomDelta!==void 0&&(c.zoom=L),p.panDelta!==void 0&&(c.drag=L),p.pitchDelta!==void 0&&(c.pitch=L),p.bearingDelta!==void 0&&(c.rotate=L)}_applyChanges(){let n={},c={},p={};for(let[f,b,L]of this._changes)f.panDelta&&(n.panDelta=(n.panDelta||new o.P(0,0))._add(f.panDelta)),f.zoomDelta&&(n.zoomDelta=(n.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(n.bearingDelta=(n.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(n.pitchDelta=(n.pitchDelta||0)+f.pitchDelta),f.around!==void 0&&(n.around=f.around),f.pinchAround!==void 0&&(n.pinchAround=f.pinchAround),f.noInertia&&(n.noInertia=f.noInertia),o.e(c,b),o.e(p,L);this._updateMapTransform(n,c,p),this._changes=[]}_updateMapTransform(n,c,p){let f=this._map,b=f._getTransformForUpdate(),L=f.terrain;if(!(ll(n)||L&&this._terrainMovement))return this._fireEvents(c,p,!0);let{panDelta:E,zoomDelta:H,bearingDelta:h,pitchDelta:I,around:_,pinchAround:F}=n;F!==void 0&&(_=F),f._stop(!0),_=_||f.transform.centerPoint;let R=b.pointLocation(E?_.sub(E):_);h&&(b.bearing+=h),I&&(b.pitch+=I),H&&(b.zoom+=H),L?this._terrainMovement||!c.drag&&!c.zoom?c.drag&&this._terrainMovement?b.center=b.pointLocation(b.centerPoint.sub(E)):b.setLocationAtPoint(R,_):(this._terrainMovement=!0,this._map._elevationFreeze=!0,b.setLocationAtPoint(R,_),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,b.recalculateZoom(f.terrain)})):b.setLocationAtPoint(R,_),f._applyUpdatedTransform(b),this._map._update(),n.noInertia||this._inertia.record(n),this._fireEvents(c,p,!0)}_fireEvents(n,c,p){let f=Na(this._eventsInProgress),b=Na(n),L={};for(let I in n){let{originalEvent:_}=n[I];this._eventsInProgress[I]||(L[`${I}start`]=_),this._eventsInProgress[I]=n[I]}!f&&b&&this._fireEvent("movestart",b.originalEvent);for(let I in L)this._fireEvent(I,L[I]);b&&this._fireEvent("move",b.originalEvent);for(let I in n){let{originalEvent:_}=n[I];this._fireEvent(I,_)}let E={},H;for(let I in this._eventsInProgress){let{handlerName:_,originalEvent:F}=this._eventsInProgress[I];this._handlersById[_].isActive()||(delete this._eventsInProgress[I],H=c[_]||F,E[`${I}end`]=H)}for(let I in E)this._fireEvent(I,E[I]);let h=Na(this._eventsInProgress);if(p&&(f||b)&&!h){this._updatingCamera=!0;let I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),_=F=>F!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new wc("renderFrame",{timeStamp:n})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Hl extends o.E{constructor(n,c){super(),this._renderFrameCallback=()=>{let p=Math.min((v.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(p)),p<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=c.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.M(this.transform.center.lng,this.transform.center.lat)}setCenter(n,c){return this.jumpTo({center:n},c)}panBy(n,c,p){return n=o.P.convert(n).mult(-1),this.panTo(this.transform.center,o.e({offset:n},c),p)}panTo(n,c,p){return this.easeTo(o.e({center:n},c),p)}getZoom(){return this.transform.zoom}setZoom(n,c){return this.jumpTo({zoom:n},c),this}zoomTo(n,c,p){return this.easeTo(o.e({zoom:n},c),p)}zoomIn(n,c){return this.zoomTo(this.getZoom()+1,n,c),this}zoomOut(n,c){return this.zoomTo(this.getZoom()-1,n,c),this}getBearing(){return this.transform.bearing}setBearing(n,c){return this.jumpTo({bearing:n},c),this}getPadding(){return this.transform.padding}setPadding(n,c){return this.jumpTo({padding:n},c),this}rotateTo(n,c,p){return this.easeTo(o.e({bearing:n},c),p)}resetNorth(n,c){return this.rotateTo(0,o.e({duration:1e3},n),c),this}resetNorthPitch(n,c){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},n),c),this}snapToNorth(n,c){return Math.abs(this.getBearing()){if(this._zooming&&(f.zoom=o.z.number(b,P,Gt)),this._rotating&&(f.bearing=o.z.number(L,h,Gt)),this._pitching&&(f.pitch=o.z.number(E,I,Gt)),this._padding&&(f.interpolatePadding(H,_,Gt),R=f.centerPoint.add(F)),this.terrain&&!n.freezeElevation&&this._updateElevation(Gt),ot)f.setLocationAtPoint(ot,pt);else{let Pt=f.zoomScale(f.zoom-b),dt=P>b?Math.min(2,J):Math.max(.5,J),Ct=Math.pow(dt,1-Gt),ee=f.unproject(V.add(X.mult(Gt*Ct)).mult(Pt));f.setLocationAtPoint(f.renderWorldCopies?ee.wrap():ee,R)}this._applyUpdatedTransform(f),this._fireMoveEvents(c)},Gt=>{this.terrain&&this._finalizeElevation(),this._afterEase(c,Gt)},n),this}_prepareEase(n,c,p={}){this._moving=!0,c||p.moving||this.fire(new o.k("movestart",n)),this._zooming&&!p.zooming&&this.fire(new o.k("zoomstart",n)),this._rotating&&!p.rotating&&this.fire(new o.k("rotatestart",n)),this._pitching&&!p.pitching&&this.fire(new o.k("pitchstart",n))}_prepareElevation(n){this._elevationCenter=n,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(n){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(n<1&&c!==this._elevationTarget){let p=this._elevationTarget-this._elevationStart;this._elevationStart+=n*(p-(c-(p*n+this._elevationStart))/(1-n)),this._elevationTarget=c}this.transform.elevation=o.z.number(this._elevationStart,this._elevationTarget,n)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(n){if(!this.transformCameraUpdate)return;let c=n.clone(),{center:p,zoom:f,pitch:b,bearing:L,elevation:E}=this.transformCameraUpdate(c);p&&(c.center=p),f!==void 0&&(c.zoom=f),b!==void 0&&(c.pitch=b),L!==void 0&&(c.bearing=L),E!==void 0&&(c.elevation=E),this.transform.apply(c)}_fireMoveEvents(n){this.fire(new o.k("move",n)),this._zooming&&this.fire(new o.k("zoom",n)),this._rotating&&this.fire(new o.k("rotate",n)),this._pitching&&this.fire(new o.k("pitch",n))}_afterEase(n,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;let p=this._zooming,f=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,p&&this.fire(new o.k("zoomend",n)),f&&this.fire(new o.k("rotateend",n)),b&&this.fire(new o.k("pitchend",n)),this.fire(new o.k("moveend",n))}flyTo(n,c){var p;if(!n.essential&&v.prefersReducedMotion){let Ye=o.L(n,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ye,c)}this.stop(),n=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b7},n);let f=this._getTransformForUpdate(),b=this.getZoom(),L=this.getBearing(),E=this.getPitch(),H=this.getPadding(),h="bearing"in n?this._normalizeBearing(n.bearing,L):L,I="pitch"in n?+n.pitch:E,_="padding"in n?n.padding:f.padding,F=o.P.convert(n.offset),R=f.centerPoint.add(F),Z=f.pointLocation(R),{center:N,zoom:P}=f.getConstrained(o.M.convert(n.center||Z),(p=n.zoom)!==null&&p!==void 0?p:b);this._normalizeCenter(N);let V=f.zoomScale(P-b),X=f.project(Z),J=f.project(N).sub(X),ot=n.curve,pt=Math.max(f.width,f.height),ut=pt/V,Gt=J.mag();if("minZoom"in n){let Ye=o.ac(Math.min(n.minZoom,b,P),f.minZoom,f.maxZoom),xe=pt/f.zoomScale(Ye-b);ot=Math.sqrt(xe/Gt*2)}let Pt=ot*ot;function dt(Ye){let xe=(ut*ut-pt*pt+(Ye?-1:1)*Pt*Pt*Gt*Gt)/(2*(Ye?ut:pt)*Pt*Gt);return Math.log(Math.sqrt(xe*xe+1)-xe)}function Ct(Ye){return(Math.exp(Ye)-Math.exp(-Ye))/2}function ee(Ye){return(Math.exp(Ye)+Math.exp(-Ye))/2}let ge=dt(!1),jt=function(Ye){return ee(ge)/ee(ge+ot*Ye)},Fe=function(Ye){return pt*((ee(ge)*(Ct(xe=ge+ot*Ye)/ee(xe))-Ct(ge))/Pt)/Gt;var xe},ke=(dt(!0)-ge)/ot;if(Math.abs(Gt)<1e-6||!isFinite(ke)){if(Math.abs(pt-ut)<1e-6)return this.easeTo(n,c);let Ye=utn.maxDuration&&(n.duration=0),this._zooming=!0,this._rotating=L!==h,this._pitching=I!==E,this._padding=!f.isPaddingEqual(_),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(N),this._ease(Ye=>{let xe=Ye*ke,ci=1/jt(xe);f.zoom=Ye===1?P:b+f.scaleZoom(ci),this._rotating&&(f.bearing=o.z.number(L,h,Ye)),this._pitching&&(f.pitch=o.z.number(E,I,Ye)),this._padding&&(f.interpolatePadding(H,_,Ye),R=f.centerPoint.add(F)),this.terrain&&!n.freezeElevation&&this._updateElevation(Ye);let pi=Ye===1?N:f.unproject(X.add(J.mult(Fe(xe))).mult(ci));f.setLocationAtPoint(f.renderWorldCopies?pi.wrap():pi,R),this._applyUpdatedTransform(f),this._fireMoveEvents(c)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(c)},n),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(n,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let p=this._onEaseEnd;delete this._onEaseEnd,p.call(this,c)}if(!n){let p=this.handlers;p&&p.stop(!1)}return this}_ease(n,c,p){p.animate===!1||p.duration===0?(n(1),c()):(this._easeStart=v.now(),this._easeOptions=p,this._onEaseFrame=n,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(n,c){n=o.b1(n,-180,180);let p=Math.abs(n-c);return Math.abs(n-360-c)180?-360:p<-180?360:0}queryTerrainElevation(n){return this.terrain?this.terrain.getElevationForLngLatZoom(o.M.convert(n),this.transform.tileZoom)-this.transform.elevation:null}}let ns={compact:!0,customAttribution:'MapLibre'};class ou{constructor(n=ns){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=c=>{!c||c.sourceDataType!=="metadata"&&c.sourceDataType!=="visibility"&&c.dataType!=="style"&&c.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=n}getDefaultPosition(){return"bottom-right"}onAdd(n){return this._map=n,this._compact=this.options.compact,this._container=x.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=x.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=x.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){x.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(n,c){let p=this._map._getUIString(`AttributionControl.${c}`);n.title=p,n.setAttribute("aria-label",p)}_updateAttributions(){if(!this._map.style)return;let n=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?n=n.concat(this.options.customAttribution.map(f=>typeof f!="string"?"":f)):typeof this.options.customAttribution=="string"&&n.push(this.options.customAttribution)),this._map.style.stylesheet){let f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}let c=this._map.style.sourceCaches;for(let f in c){let b=c[f];if(b.used||b.usedForTerrain){let L=b.getSource();L.attribution&&n.indexOf(L.attribution)<0&&n.push(L.attribution)}}n=n.filter(f=>String(f).trim()),n.sort((f,b)=>f.length-b.length),n=n.filter((f,b)=>{for(let L=b+1;L=0)return!1;return!0});let p=n.join(" | ");p!==this._attribHTML&&(this._attribHTML=p,n.length?(this._innerContainer.innerHTML=p,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class FA{constructor(n={}){this._updateCompact=()=>{let c=this._container.children;if(c.length){let p=c[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&p.classList.add("maplibregl-compact"):p.classList.remove("maplibregl-compact")}},this.options=n}getDefaultPosition(){return"bottom-left"}onAdd(n){this._map=n,this._compact=this.options&&this.options.compact,this._container=x.create("div","maplibregl-ctrl");let c=x.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){x.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Xr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(n){let c=++this._id;return this._queue.push({callback:n,id:c,cancelled:!1}),c}remove(n){let c=this._currentlyRunning,p=c?this._queue.concat(c):this._queue;for(let f of p)if(f.id===n)return void(f.cancelled=!0)}run(n=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let c=this._currentlyRunning=this._queue;this._queue=[];for(let p of c)if(!p.cancelled&&(p.callback(n),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var dn=o.X([{name:"a_pos3d",type:"Int16",components:3}]);class au extends o.E{constructor(n){super(),this.sourceCache=n,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,n.usedForTerrain=!0,n.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(n,c){this.sourceCache.update(n,c),this._renderableTilesKeys=[];let p={};for(let f of n.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c}))p[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.posMatrix=new Float64Array(16),o.aN(f.posMatrix,0,o.W,0,o.W,0,1),this._tiles[f.key]=new mi(f,this.tileSize));for(let f in this._tiles)p[f]||delete this._tiles[f]}freeRtt(n){for(let c in this._tiles){let p=this._tiles[c];(!n||p.tileID.equals(n)||p.tileID.isChildOf(n)||n.isChildOf(p.tileID))&&(p.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(n=>this.getTileByID(n))}getTileByID(n){return this._tiles[n]}getTerrainCoords(n){let c={};for(let p of this._renderableTilesKeys){let f=this._tiles[p].tileID;if(f.canonical.equals(n.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16),o.aN(b.posMatrix,0,o.W,0,o.W,0,1),c[p]=b}else if(f.canonical.isChildOf(n.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16);let L=f.canonical.z-n.canonical.z,E=f.canonical.x-(f.canonical.x>>L<>L<>L;o.aN(b.posMatrix,0,h,0,h,0,1),o.H(b.posMatrix,b.posMatrix,[-E*h,-H*h,0]),c[p]=b}else if(n.canonical.isChildOf(f.canonical)){let b=n.clone();b.posMatrix=new Float64Array(16);let L=n.canonical.z-f.canonical.z,E=n.canonical.x-(n.canonical.x>>L<>L<>L;o.aN(b.posMatrix,0,o.W,0,o.W,0,1),o.H(b.posMatrix,b.posMatrix,[E*h,H*h,0]),o.J(b.posMatrix,b.posMatrix,[1/2**L,1/2**L,0]),c[p]=b}}return c}getSourceTile(n,c){let p=this.sourceCache._source,f=n.overscaledZ-this.deltaZoom;if(f>p.maxzoom&&(f=p.maxzoom),f=p.minzoom&&(!b||!b.dem);)b=this.sourceCache.getTileByID(n.scaledTo(f--).key);return b}tilesAfterTime(n=Date.now()){return Object.values(this._tiles).filter(c=>c.timeAdded>=n)}}class cl{constructor(n,c,p){this.painter=n,this.sourceCache=new au(c),this.options=p,this.exaggeration=typeof p.exaggeration=="number"?p.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(n,c,p,f=o.W){var b;if(!(c>=0&&c=0&&pn.canonical.z&&(n.canonical.z>=f?b=n.canonical.z-f:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let L=n.canonical.x-(n.canonical.x>>b<>b<>8<<4|b>>8,c[L+3]=0;let p=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new qt(n,p,n.gl.RGBA,{premultiply:!1});return f.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(n){this.painter.maybeDrawDepthAndCoords(!0);let c=new Uint8Array(4),p=this.painter.context,f=p.gl;p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(n.x,this.painter.height/devicePixelRatio-n.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),p.bindFramebuffer.set(null);let b=c[0]+(c[2]>>4<<8),L=c[1]+((15&c[2])<<8),E=this.coordsIndex[255-c[3]],H=E&&this.sourceCache.getTileByID(E);if(!H)return null;let h=this._coordsTextureSize,I=(1<n.id!==c),this._recentlyUsed.push(n.id)}stampObject(n){n.stamp=++this._stamp}getOrCreateFreeObject(){for(let c of this._recentlyUsed)if(!this._objects[c].inUse)return this._objects[c];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let n=this._createObject(this._objects.length);return this._objects.push(n),n}freeObject(n){n.inUse=!1}freeAllObjects(){for(let n of this._objects)this.freeObject(n)}isFull(){return!(this._objects.length!n.inUse)===!1}}let ss={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ss{constructor(n,c){this.painter=n,this.terrain=c,this.pool=new Zl(n.context,30,c.sourceCache.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(n){return this.pool.getObjectForId(n.rtt[this._stacks.length-1].id).texture}prepareForRender(n,c){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=n._order.filter(p=>!n._layers[p].isHidden(c)),this._coordsDescendingInv={};for(let p in n.sourceCaches){this._coordsDescendingInv[p]={};let f=n.sourceCaches[p].getVisibleCoordinates();for(let b of f){let L=this.terrain.sourceCache.getTerrainCoords(b);for(let E in L)this._coordsDescendingInv[p][E]||(this._coordsDescendingInv[p][E]=[]),this._coordsDescendingInv[p][E].push(L[E])}}this._coordsDescendingInvStr={};for(let p of n._order){let f=n._layers[p],b=f.source;if(ss[f.type]&&!this._coordsDescendingInvStr[b]){this._coordsDescendingInvStr[b]={};for(let L in this._coordsDescendingInv[b])this._coordsDescendingInvStr[b][L]=this._coordsDescendingInv[b][L].map(E=>E.key).sort().join()}}for(let p of this._renderableTiles)for(let f in this._coordsDescendingInvStr){let b=this._coordsDescendingInvStr[f][p.tileID.key];b&&b!==p.rttCoords[f]&&(p.rtt=[])}}renderLayer(n){if(n.isHidden(this.painter.transform.zoom))return!1;let c=n.type,p=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===n.id;if(ss[c]&&(this._prevType&&ss[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(n.id),!f))return!0;if(ss[this._prevType]||ss[c]&&f){this._prevType=c;let b=this._stacks.length-1,L=this._stacks[b]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(sl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[b]){let h=this.pool.getObjectForId(E.rtt[b].id);if(h.stamp===E.rtt[b].stamp){this.pool.useObject(h);continue}}let H=this.pool.getOrCreateFreeObject();this.pool.useObject(H),this.pool.stampObject(H),E.rtt[b]={id:H.id,stamp:H.stamp},p.context.bindFramebuffer.set(H.fbo.framebuffer),p.context.clear({color:o.aO.transparent,stencil:0}),p.currentStencilSource=void 0;for(let h=0;h{y.touchstart=y.dragStart,y.touchmoveWindow=y.dragMove,y.touchend=y.dragEnd},us={showCompass:!0,showZoom:!0,visualizePitch:!1};class Bc{constructor(n,c,p=!1){this.mousedown=L=>{this.startMouse(o.e({},L,{ctrlKey:!0,preventDefault:()=>L.preventDefault()}),x.mousePos(this.element,L)),x.addEventListener(window,"mousemove",this.mousemove),x.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=L=>{this.moveMouse(L,x.mousePos(this.element,L))},this.mouseup=L=>{this.mouseRotate.dragEnd(L),this.mousePitch&&this.mousePitch.dragEnd(L),this.offTemp()},this.touchstart=L=>{L.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=x.touchPos(this.element,L.targetTouches)[0],this.startTouch(L,this._startPos),x.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.addEventListener(window,"touchend",this.touchend))},this.touchmove=L=>{L.targetTouches.length!==1?this.reset():(this._lastPos=x.touchPos(this.element,L.targetTouches)[0],this.moveTouch(L,this._lastPos))},this.touchend=L=>{L.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;let f=n.dragRotate._mouseRotate.getClickTolerance(),b=n.dragRotate._mousePitch.getClickTolerance();this.element=c,this.mouseRotate=Za({clickTolerance:f,enable:!0}),this.touchRotate=(({enable:L,clickTolerance:E,bearingDegreesPerPixelMoved:H=.8})=>{let h=new Ul;return new ls({clickTolerance:E,move:(I,_)=>({bearingDelta:(_.x-I.x)*H}),moveStateManager:h,enable:L,assignEvents:lo})})({clickTolerance:f,enable:!0}),this.map=n,p&&(this.mousePitch=Ql({clickTolerance:b,enable:!0}),this.touchPitch=(({enable:L,clickTolerance:E,pitchDegreesPerPixelMoved:H=-.5})=>{let h=new Ul;return new ls({clickTolerance:E,move:(I,_)=>({pitchDelta:(_.y-I.y)*H}),moveStateManager:h,enable:L,assignEvents:lo})})({clickTolerance:b,enable:!0})),x.addEventListener(c,"mousedown",this.mousedown),x.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),x.addEventListener(c,"touchcancel",this.reset)}startMouse(n,c){this.mouseRotate.dragStart(n,c),this.mousePitch&&this.mousePitch.dragStart(n,c),x.disableDrag()}startTouch(n,c){this.touchRotate.dragStart(n,c),this.touchPitch&&this.touchPitch.dragStart(n,c),x.disableDrag()}moveMouse(n,c){let p=this.map,{bearingDelta:f}=this.mouseRotate.dragMove(n,c)||{};if(f&&p.setBearing(p.getBearing()+f),this.mousePitch){let{pitchDelta:b}=this.mousePitch.dragMove(n,c)||{};b&&p.setPitch(p.getPitch()+b)}}moveTouch(n,c){let p=this.map,{bearingDelta:f}=this.touchRotate.dragMove(n,c)||{};if(f&&p.setBearing(p.getBearing()+f),this.touchPitch){let{pitchDelta:b}=this.touchPitch.dragMove(n,c)||{};b&&p.setPitch(p.getPitch()+b)}}off(){let n=this.element;x.removeEventListener(n,"mousedown",this.mousedown),x.removeEventListener(n,"touchstart",this.touchstart,{passive:!1}),x.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.removeEventListener(window,"touchend",this.touchend),x.removeEventListener(n,"touchcancel",this.reset),this.offTemp()}offTemp(){x.enableDrag(),x.removeEventListener(window,"mousemove",this.mousemove),x.removeEventListener(window,"mouseup",this.mouseup),x.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),x.removeEventListener(window,"touchend",this.touchend)}}let ia;function hl(y,n,c){let p=new o.M(y.lng,y.lat);if(y=new o.M(y.lng,y.lat),n){let f=new o.M(y.lng-360,y.lat),b=new o.M(y.lng+360,y.lat),L=c.locationPoint(y).distSqr(n);c.locationPoint(f).distSqr(n)180;){let f=c.locationPoint(y);if(f.x>=0&&f.y>=0&&f.x<=c.width&&f.y<=c.height)break;y.lng>c.center.lng?y.lng-=360:y.lng+=360}return y.lng!==p.lng&&c.locationPoint(y).y>c.height/2-c.getHorizon()?y:p}let kA={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 gl(y,n,c){let p=y.classList;for(let f in kA)p.remove(`maplibregl-${c}-anchor-${f}`);p.add(`maplibregl-${c}-anchor-${n}`)}class Va extends o.E{constructor(n){if(super(),this._onKeyPress=c=>{let p=c.code,f=c.charCode||c.keyCode;p!=="Space"&&p!=="Enter"&&f!==32&&f!==13||this.togglePopup()},this._onMapClick=c=>{let p=c.originalEvent.target,f=this._element;this._popup&&(p===f||f.contains(p))&&this.togglePopup()},this._update=c=>{var p;if(!this._map)return;let f=this._map.loaded()&&!this._map.isMoving();(c?.type==="terrain"||c?.type==="render"&&!f)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?hl(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let b="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?b=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(b=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let L="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?L="rotateX(0deg)":this._pitchAlignment==="map"&&(L=`rotateX(${this._map.getPitch()}deg)`),c&&c.type!=="moveend"||(this._pos=this._pos.round()),x.setTransform(this._element,`${kA[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${L} ${b}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(c&&c.type==="moveend")}).catch(()=>{})},this._onMove=c=>{if(!this._isDragging){let p=this._clickTolerance||this._map._clickTolerance;this._isDragging=c.point.dist(this._pointerdownPos)>=p}this._isDragging&&(this._pos=c.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new o.k("dragstart"))),this.fire(new o.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new o.k("dragend")),this._state="inactive"},this._addDragHandler=c=>{this._element.contains(c.originalEvent.target)&&(c.preventDefault(),this._positionDelta=c.point.sub(this._pos).add(this._offset),this._pointerdownPos=c.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._scale=n&&n.scale||1,this._draggable=n&&n.draggable||!1,this._clickTolerance=n&&n.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=n&&n.rotation||0,this._rotationAlignment=n&&n.rotationAlignment||"auto",this._pitchAlignment=n&&n.pitchAlignment&&n.pitchAlignment!=="auto"?n.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(n?.opacity,n?.opacityWhenCovered),n&&n.element)this._element=n.element,this._offset=o.P.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=x.create("div"),this._element.setAttribute("aria-label","Map marker");let c=x.createNS("http://www.w3.org/2000/svg","svg"),p=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${p}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${p}`);let b=x.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"stroke","none"),b.setAttributeNS(null,"stroke-width","1"),b.setAttributeNS(null,"fill","none"),b.setAttributeNS(null,"fill-rule","evenodd");let L=x.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"fill-rule","nonzero");let E=x.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let H=[{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(let V of H){let X=x.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",V.rx),X.setAttributeNS(null,"ry",V.ry),E.appendChild(X)}let h=x.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);let I=x.createNS("http://www.w3.org/2000/svg","path");I.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"),h.appendChild(I);let _=x.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"fill","#000000");let F=x.createNS("http://www.w3.org/2000/svg","path");F.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"),_.appendChild(F);let R=x.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(6.0, 7.0)"),R.setAttributeNS(null,"fill","#FFFFFF");let Z=x.createNS("http://www.w3.org/2000/svg","g");Z.setAttributeNS(null,"transform","translate(8.0, 8.0)");let N=x.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");let P=x.createNS("http://www.w3.org/2000/svg","circle");P.setAttributeNS(null,"fill","#FFFFFF"),P.setAttributeNS(null,"cx","5.5"),P.setAttributeNS(null,"cy","5.5"),P.setAttributeNS(null,"r","5.4999962"),Z.appendChild(N),Z.appendChild(P),L.appendChild(E),L.appendChild(h),L.appendChild(_),L.appendChild(R),L.appendChild(Z),c.appendChild(L),c.setAttributeNS(null,"height",p*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=o.P.convert(n&&n.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",c=>{c.preventDefault()}),this._element.addEventListener("mousedown",c=>{c.preventDefault()}),gl(this._element,this._anchor,"marker"),n&&n.className)for(let c of n.className.split(" "))this._element.classList.add(c);this._popup=null}addTo(n){return this.remove(),this._map=n,n.getCanvasContainer().appendChild(this._element),n.on("move",this._update),n.on("moveend",this._update),n.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("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),x.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(n){return this._lngLat=o.M.convert(n),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(n){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),n){if(!("offset"in n.options)){let f=Math.abs(13.5)/Math.SQRT2;n.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=n,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){let n=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:n?(n.isOpen()?n.remove():(n.setLngLat(this._lngLat),n.addTo(this._map)),this):this}_updateOpacity(n=!1){var c,p;if(!(!((c=this._map)===null||c===void 0)&&c.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(n)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let f=this._map,b=f.terrain.depthAtPoint(this._pos),L=f.terrain.getElevationForLngLatZoom(this._lngLat,f.transform.tileZoom);if(f.transform.lngLatToCameraDepth(this._lngLat,L)-b<.006)return void(this._element.style.opacity=this._opacity);let E=-this._offset.y/f.transform._pixelPerMeter,H=Math.sin(f.getPitch()*Math.PI/180)*E,h=f.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),I=f.transform.lngLatToCameraDepth(this._lngLat,L+H)-h>.006;((p=this._popup)===null||p===void 0?void 0:p.isOpen())&&I&&this._popup.remove(),this._element.style.opacity=I?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(n){return this._offset=o.P.convert(n),this._update(),this}addClassName(n){this._element.classList.add(n)}removeClassName(n){this._element.classList.remove(n)}toggleClassName(n){return this._element.classList.toggle(n)}setDraggable(n){return this._draggable=!!n,this._map&&(n?(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(n){return this._rotation=n||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(n){return this._rotationAlignment=n||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(n){return this._pitchAlignment=n&&n!=="auto"?n:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(n,c){return n===void 0&&c===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),n!==void 0&&(this._opacity=n),c!==void 0&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}let _c={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},ra=0,co=!1,Da={maxWidth:100,unit:"metric"};function LA(y,n,c){let p=c&&c.maxWidth||100,f=y._container.clientHeight/2,b=y.unproject([0,f]),L=y.unproject([p,f]),E=b.distanceTo(L);if(c&&c.unit==="imperial"){let H=3.2808*E;H>5280?Ia(n,p,H/5280,y._getUIString("ScaleControl.Miles")):Ia(n,p,H,y._getUIString("ScaleControl.Feet"))}else c&&c.unit==="nautical"?Ia(n,p,E/1852,y._getUIString("ScaleControl.NauticalMiles")):E>=1e3?Ia(n,p,E/1e3,y._getUIString("ScaleControl.Kilometers")):Ia(n,p,E,y._getUIString("ScaleControl.Meters"))}function Ia(y,n,c,p){let f=function(b){let L=Math.pow(10,`${Math.floor(b)}`.length-1),E=b/L;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(H){let h=Math.pow(10,Math.ceil(-Math.log(H)/Math.LN10));return Math.round(H*h)/h}(E),L*E}(c);y.style.width=n*(f/c)+"px",y.innerHTML=`${f} ${p}`}let xc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ml=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Sc(y){if(y){if(typeof y=="number"){let n=Math.round(Math.abs(y)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,y),"top-left":new o.P(n,n),"top-right":new o.P(-n,n),bottom:new o.P(0,-y),"bottom-left":new o.P(n,-n),"bottom-right":new o.P(-n,-n),left:new o.P(y,0),right:new o.P(-y,0)}}if(y instanceof o.P||Array.isArray(y)){let n=o.P.convert(y);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:o.P.convert(y.center||[0,0]),top:o.P.convert(y.top||[0,0]),"top-left":o.P.convert(y["top-left"]||[0,0]),"top-right":o.P.convert(y["top-right"]||[0,0]),bottom:o.P.convert(y.bottom||[0,0]),"bottom-left":o.P.convert(y["bottom-left"]||[0,0]),"bottom-right":o.P.convert(y["bottom-right"]||[0,0]),left:o.P.convert(y.left||[0,0]),right:o.P.convert(y.right||[0,0])}}return Sc(new o.P(0,0))}let Au=g;A.AJAXError=o.be,A.Evented=o.E,A.LngLat=o.M,A.MercatorCoordinate=o.Y,A.Point=o.P,A.addProtocol=o.bf,A.config=o.a,A.removeProtocol=o.bg,A.AttributionControl=ou,A.BoxZoomHandler=Fr,A.CanvasSource=ze,A.CooperativeGesturesHandler=Hi,A.DoubleClickZoomHandler=xA,A.DragPanHandler=ao,A.DragRotateHandler=SA,A.EdgeInsets=is,A.FullscreenControl=class extends o.E{constructor(y={}){super(),this._onFullscreenChange=()=>{var n;let c=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((n=c?.shadowRoot)===null||n===void 0)&&n.fullscreenElement;)c=c.shadowRoot.fullscreenElement;c===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,y&&y.container&&(y.container instanceof HTMLElement?this._container=y.container:o.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(y){return this._map=y,this._container||(this._container=this._map.getContainer()),this._controlContainer=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){x.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let y=this._fullscreenButton=x.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);x.create("span","maplibregl-ctrl-icon",y).setAttribute("aria-hidden","true"),y.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let y=this._getTitle();this._fullscreenButton.setAttribute("aria-label",y),this._fullscreenButton.title=y}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},A.GeoJSONSource=Qe,A.GeolocateControl=class extends o.E{constructor(y){super(),this._onSuccess=n=>{if(this._map){if(this._isOutOfMapMaxBounds(n))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",n)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=n,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(n),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(n),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",n)),this._finish()}},this._updateCamera=n=>{let c=new o.M(n.coords.longitude,n.coords.latitude),p=n.coords.accuracy,f=this._map.getBearing(),b=o.e({bearing:f},this.options.fitBoundsOptions),L=Me.fromLngLat(c,p);this._map.fitBounds(L,b,{geolocateSource:!0})},this._updateMarker=n=>{if(n){let c=new o.M(n.coords.longitude,n.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=n.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=n=>{if(this._map){if(this.options.trackUserLocation)if(n.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(n.code===3&&co)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",n)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=n=>{if(this._map){if(this._container.addEventListener("contextmenu",c=>c.preventDefault()),this._geolocateButton=x.create("button","maplibregl-ctrl-geolocate",this._container),x.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",n===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}else{let c=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=x.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Va({element:this._dotElement}),this._circleElement=x.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Va({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",c=>{c.geolocateSource||this._watchState!=="ACTIVE_LOCK"||c.originalEvent&&c.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new o.k("trackuserlocationend")))})}},this.options=o.e({},_c,y)}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(){return o._(this,arguments,void 0,function*(n=!1){if(ia!==void 0&&!n)return ia;if(window.navigator.permissions===void 0)return ia=!!window.navigator.geolocation,ia;try{ia=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{ia=!!window.navigator.geolocation}return ia})}().then(n=>this._setupUI(n)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),x.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,ra=0,co=!1}_isOutOfMapMaxBounds(y){let n=this._map.getMaxBounds(),c=y.coords;return n&&(c.longituden.getEast()||c.latituden.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let y=this._map.getBounds(),n=y.getSouthEast(),c=y.getNorthEast(),p=n.distanceTo(c),f=Math.ceil(this._accuracy/(p/this._map._container.clientHeight)*2);this._circleElement.style.width=`${f}px`,this._circleElement.style.height=`${f}px`}trigger(){if(!this._setup)return o.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ra--,co=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new o.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new o.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let y;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ra++,ra>1?(y={maximumAge:6e5,timeout:0},co=!0):(y=this.options.positionOptions,co=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,y)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},A.Hash=ma,A.ImageSource=Ne,A.KeyboardHandler=Pr,A.LngLatBounds=Me,A.LogoControl=FA,A.Map=class extends Hl{constructor(y){if(o.bc.mark(o.bd.create),(y=o.e({},Pl,y)).minZoom!=null&&y.maxZoom!=null&&y.minZoom>y.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(y.minPitch!=null&&y.maxPitch!=null&&y.minPitch>y.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(y.minPitch!=null&&y.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(y.maxPitch!=null&&y.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new _s(y.minZoom,y.maxZoom,y.minPitch,y.maxPitch,y.renderWorldCopies),{bearingSnap:y.bearingSnap}),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=y.interactive,this._maxTileCacheSize=y.maxTileCacheSize,this._maxTileCacheZoomLevels=y.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=y.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=y.preserveDrawingBuffer,this._antialias=y.antialias,this._trackResize=y.trackResize,this._bearingSnap=y.bearingSnap,this._refreshExpiredTiles=y.refreshExpiredTiles,this._fadeDuration=y.fadeDuration,this._crossSourceCollisions=y.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=y.collectResourceTiming,this._renderTaskQueue=new Xr,this._controls=[],this._mapId=o.a3(),this._locale=o.e({},Ao,y.locale),this._clickTolerance=y.clickTolerance,this._overridePixelRatio=y.pixelRatio,this._maxCanvasSize=y.maxCanvasSize,this.transformCameraUpdate=y.transformCameraUpdate,this._imageQueueHandle=O.addThrottleControl(()=>this.isMoving()),this._requestManager=new at(y.transformRequest),typeof y.container=="string"){if(this._container=document.getElementById(y.container),!this._container)throw new Error(`Container '${y.container}' not found.`)}else{if(!(y.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=y.container}if(y.maxBounds&&this.setMaxBounds(y.maxBounds),this._setupContainer(),this._setupPainter(),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)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1,c=ro(p=>{this._trackResize&&!this._removed&&this.resize(p)._update()},50);this._resizeObserver=new ResizeObserver(p=>{n?c(p):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jn(this,y),this._hash=y.hash&&new ma(typeof y.hash=="string"&&y.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:y.center,zoom:y.zoom,bearing:y.bearing,pitch:y.pitch}),y.bounds&&(this.resize(),this.fitBounds(y.bounds,o.e({},y.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=y.localIdeographFontFamily,this._validateStyle=y.validateStyle,y.style&&this.setStyle(y.style,{localIdeographFontFamily:y.localIdeographFontFamily}),y.attributionControl&&this.addControl(new ou(typeof y.attributionControl=="boolean"?void 0:y.attributionControl)),y.maplibreLogo&&this.addControl(new FA,y.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new o.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new o.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new o.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(y,n){if(n===void 0&&(n=y.getDefaultPosition?y.getDefaultPosition():"top-right"),!y||!y.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let c=y.onAdd(this);this._controls.push(y);let p=this._controlPositions[n];return n.indexOf("bottom")!==-1?p.insertBefore(c,p.firstChild):p.appendChild(c),this}removeControl(y){if(!y||!y.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let n=this._controls.indexOf(y);return n>-1&&this._controls.splice(n,1),y.onRemove(this),this}hasControl(y){return this._controls.indexOf(y)>-1}calculateCameraOptionsFromTo(y,n,c,p){return p==null&&this.terrain&&(p=this.terrain.getElevationForLngLatZoom(c,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(y,n,c,p)}resize(y){var n;let c=this._containerDimensions(),p=c[0],f=c[1],b=this._getClampedPixelRatio(p,f);if(this._resizeCanvas(p,f,b),this.painter.resize(p,f,b),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let H=this._getClampedPixelRatio(p,f);this._resizeCanvas(p,f,H),this.painter.resize(p,f,H)}this.transform.resize(p,f),(n=this._requestedCameraState)===null||n===void 0||n.resize(p,f);let L=!this._moving;return L&&(this.stop(),this.fire(new o.k("movestart",y)).fire(new o.k("move",y))),this.fire(new o.k("resize",y)),L&&this.fire(new o.k("moveend",y)),this}_getClampedPixelRatio(y,n){let{0:c,1:p}=this._maxCanvasSize,f=this.getPixelRatio(),b=y*f,L=n*f;return Math.min(b>c?c/b:1,L>p?p/L:1)*f}getPixelRatio(){var y;return(y=this._overridePixelRatio)!==null&&y!==void 0?y:devicePixelRatio}setPixelRatio(y){this._overridePixelRatio=y,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(y){return this.transform.setMaxBounds(Me.convert(y)),this._update()}setMinZoom(y){if((y=y??-2)>=-2&&y<=this.transform.maxZoom)return this.transform.minZoom=y,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=y,this._update(),this.getZoom()>y&&this.setZoom(y),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(y){if((y=y??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(y>=0&&y<=this.transform.maxPitch)return this.transform.minPitch=y,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(y>=this.transform.minPitch)return this.transform.maxPitch=y,this._update(),this.getPitch()>y&&this.setPitch(y),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(y){return this.transform.renderWorldCopies=y,this._update()}project(y){return this.transform.locationPoint(o.M.convert(y),this.style&&this.terrain)}unproject(y){return this.transform.pointLocation(o.P.convert(y),this.terrain)}isMoving(){var y;return this._moving||((y=this.handlers)===null||y===void 0?void 0:y.isMoving())}isZooming(){var y;return this._zooming||((y=this.handlers)===null||y===void 0?void 0:y.isZooming())}isRotating(){var y;return this._rotating||((y=this.handlers)===null||y===void 0?void 0:y.isRotating())}_createDelegatedListener(y,n,c){if(y==="mouseenter"||y==="mouseover"){let p=!1;return{layer:n,listener:c,delegates:{mousemove:b=>{let L=this.getLayer(n)?this.queryRenderedFeatures(b.point,{layers:[n]}):[];L.length?p||(p=!0,c.call(this,new Jr(y,this,b.originalEvent,{features:L}))):p=!1},mouseout:()=>{p=!1}}}}if(y==="mouseleave"||y==="mouseout"){let p=!1;return{layer:n,listener:c,delegates:{mousemove:L=>{(this.getLayer(n)?this.queryRenderedFeatures(L.point,{layers:[n]}):[]).length?p=!0:p&&(p=!1,c.call(this,new Jr(y,this,L.originalEvent)))},mouseout:L=>{p&&(p=!1,c.call(this,new Jr(y,this,L.originalEvent)))}}}}{let p=f=>{let b=this.getLayer(n)?this.queryRenderedFeatures(f.point,{layers:[n]}):[];b.length&&(f.features=b,c.call(this,f),delete f.features)};return{layer:n,listener:c,delegates:{[y]:p}}}}on(y,n,c){if(c===void 0)return super.on(y,n);let p=this._createDelegatedListener(y,n,c);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[y]=this._delegatedListeners[y]||[],this._delegatedListeners[y].push(p);for(let f in p.delegates)this.on(f,p.delegates[f]);return this}once(y,n,c){if(c===void 0)return super.once(y,n);let p=this._createDelegatedListener(y,n,c);for(let f in p.delegates)this.once(f,p.delegates[f]);return this}off(y,n,c){return c===void 0?super.off(y,n):(this._delegatedListeners&&this._delegatedListeners[y]&&(p=>{let f=this._delegatedListeners[y];for(let b=0;bthis._updateStyle(y,n));let c=this.style&&n.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!y)),y?(this.style=new Bo(this,n||{}),this.style.setEventedParent(this,{style:this.style}),typeof y=="string"?this.style.loadURL(y,n,c):this.style.loadJSON(y,n,c),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Bo(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(y,n){if(typeof y=="string"){let c=this._requestManager.transformRequest(y,tt.Style);o.h(c,new AbortController).then(p=>{this._updateDiff(p.data,n)}).catch(p=>{p&&this.fire(new o.j(p))})}else typeof y=="object"&&this._updateDiff(y,n)}_updateDiff(y,n){try{this.style.setState(y,n)&&this._update(!0)}catch(c){o.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(y,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(y,n){return this._lazyInitEmptyStyle(),this.style.addSource(y,n),this._update(!0)}isSourceLoaded(y){let n=this.style&&this.style.sourceCaches[y];if(n!==void 0)return n.loaded();this.fire(new o.j(new Error(`There is no source with ID '${y}'`)))}setTerrain(y){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),y){let n=this.style.sourceCaches[y.source];if(!n)throw new Error(`cannot load terrain, because there exists no source with ID: ${y.source}`);this.terrain===null&&n.reload();for(let c in this.style._layers){let p=this.style._layers[c];p.type==="hillshade"&&p.source===y.source&&o.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new cl(this.painter,n,y),this.painter.renderToTexture=new Ss(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=c=>{c.dataType==="style"?this.terrain.sourceCache.freeRtt():c.dataType==="source"&&c.tile&&(c.sourceId!==y.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(c.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new o.k("terrain",{terrain:y})),this}getTerrain(){var y,n;return(n=(y=this.terrain)===null||y===void 0?void 0:y.options)!==null&&n!==void 0?n:null}areTilesLoaded(){let y=this.style&&this.style.sourceCaches;for(let n in y){let c=y[n]._tiles;for(let p in c){let f=c[p];if(f.state!=="loaded"&&f.state!=="errored")return!1}}return!0}removeSource(y){return this.style.removeSource(y),this._update(!0)}getSource(y){return this.style.getSource(y)}addImage(y,n,c={}){let{pixelRatio:p=1,sdf:f=!1,stretchX:b,stretchY:L,content:E}=c;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||o.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{let{width:H,height:h,data:I}=n,_=n;return this.style.addImage(y,{data:new o.R({width:H,height:h},new Uint8Array(I)),pixelRatio:p,stretchX:b,stretchY:L,content:E,sdf:f,version:0,userImage:_}),_.onAdd&&_.onAdd(this,y),this}}{let{width:H,height:h,data:I}=v.getImageData(n);this.style.addImage(y,{data:new o.R({width:H,height:h},I),pixelRatio:p,stretchX:b,stretchY:L,content:E,sdf:f,version:0})}}updateImage(y,n){let c=this.style.getImage(y);if(!c)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let p=n instanceof HTMLImageElement||o.b(n)?v.getImageData(n):n,{width:f,height:b,data:L}=p;if(f===void 0||b===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(f!==c.data.width||b!==c.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(n instanceof HTMLImageElement||o.b(n));return c.data.replace(L,E),this.style.updateImage(y,c),this}getImage(y){return this.style.getImage(y)}hasImage(y){return y?!!this.style.getImage(y):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(y){this.style.removeImage(y)}loadImage(y){return O.getImage(this._requestManager.transformRequest(y,tt.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(y,n){return this._lazyInitEmptyStyle(),this.style.addLayer(y,n),this._update(!0)}moveLayer(y,n){return this.style.moveLayer(y,n),this._update(!0)}removeLayer(y){return this.style.removeLayer(y),this._update(!0)}getLayer(y){return this.style.getLayer(y)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(y,n,c){return this.style.setLayerZoomRange(y,n,c),this._update(!0)}setFilter(y,n,c={}){return this.style.setFilter(y,n,c),this._update(!0)}getFilter(y){return this.style.getFilter(y)}setPaintProperty(y,n,c,p={}){return this.style.setPaintProperty(y,n,c,p),this._update(!0)}getPaintProperty(y,n){return this.style.getPaintProperty(y,n)}setLayoutProperty(y,n,c,p={}){return this.style.setLayoutProperty(y,n,c,p),this._update(!0)}getLayoutProperty(y,n){return this.style.getLayoutProperty(y,n)}setGlyphs(y,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(y,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(y,n,c={}){return this._lazyInitEmptyStyle(),this.style.addSprite(y,n,c,p=>{p||this._update(!0)}),this}removeSprite(y){return this._lazyInitEmptyStyle(),this.style.removeSprite(y),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(y,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(y,n,c=>{c||this._update(!0)}),this}setLight(y,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(y,n),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(y,n){return this.style.setFeatureState(y,n),this._update()}removeFeatureState(y,n){return this.style.removeFeatureState(y,n),this._update()}getFeatureState(y){return this.style.getFeatureState(y)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let y=0,n=0;return this._container&&(y=this._container.clientWidth||400,n=this._container.clientHeight||300),[y,n]}_setupContainer(){let y=this._container;y.classList.add("maplibregl-map");let n=this._canvasContainer=x.create("div","maplibregl-canvas-container",y);this._interactive&&n.classList.add("maplibregl-interactive"),this._canvas=x.create("canvas","maplibregl-canvas",n),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");let c=this._containerDimensions(),p=this._getClampedPixelRatio(c[0],c[1]);this._resizeCanvas(c[0],c[1],p);let f=this._controlContainer=x.create("div","maplibregl-control-container",y),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(L=>{b[L]=x.create("div",`maplibregl-ctrl-${L} `,f)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(y,n,c){this._canvas.width=Math.floor(c*y),this._canvas.height=Math.floor(c*n),this._canvas.style.width=`${y}px`,this._canvas.style.height=`${n}px`}_setupPainter(){let y={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},n=null;this._canvas.addEventListener("webglcontextcreationerror",p=>{n={requestedAttributes:y},p&&(n.statusMessage=p.statusMessage,n.type=p.type)},{once:!0});let c=this._canvas.getContext("webgl2",y)||this._canvas.getContext("webgl",y);if(!c){let p="Failed to initialize WebGL";throw n?(n.message=p,new Error(JSON.stringify(n))):new Error(p)}this.painter=new fa(c,this.transform),T.testSupport(c)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(y){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||y,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(y){return this._update(),this._renderTaskQueue.add(y)}_cancelRenderFrame(y){this._renderTaskQueue.remove(y)}_render(y){let n=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(y),this._removed)return;let c=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let f=this.transform.zoom,b=v.now();this.style.zoomHistory.update(f,b);let L=new o.a8(f,{now:b,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=L.crossFadingFactor();E===1&&E===this._crossFadingFactor||(c=!0,this._crossFadingFactor=E),this.style.update(L)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,n,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bc.mark(o.bd.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||c)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0,o.bc.mark(o.bd.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var y;this._hash&&this._hash.remove();for(let c of this._controls)c.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),O.removeThrottleControl(this._imageQueueHandle),(y=this._resizeObserver)===null||y===void 0||y.disconnect();let n=this.painter.context.gl.getExtension("WEBGL_lose_context");n&&n.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),x.remove(this._canvasContainer),x.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bc.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(y=>{o.bc.frame(y),this._frameRequest=null,this._render(y)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(y){this._showTileBoundaries!==y&&(this._showTileBoundaries=y,this._update())}get showPadding(){return!!this._showPadding}set showPadding(y){this._showPadding!==y&&(this._showPadding=y,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(y){this._showCollisionBoxes!==y&&(this._showCollisionBoxes=y,y?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(y){this._showOverdrawInspector!==y&&(this._showOverdrawInspector=y,this._update())}get repaint(){return!!this._repaint}set repaint(y){this._repaint!==y&&(this._repaint=y,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(y){this._vertices=y,this._update()}get version(){return ul}getCameraTargetElevation(){return this.transform.elevation}},A.MapMouseEvent=Jr,A.MapTouchEvent=xs,A.MapWheelEvent=zn,A.Marker=Va,A.NavigationControl=class{constructor(y){this._updateZoomButtons=()=>{let n=this._map.getZoom(),c=n===this._map.getMaxZoom(),p=n===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=p,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",p.toString())},this._rotateCompassArrow=()=>{let n=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=n},this._setButtonTitle=(n,c)=>{let p=this._map._getUIString(`NavigationControl.${c}`);n.title=p,n.setAttribute("aria-label",p)},this.options=o.e({},us,y),this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",n=>n.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",n=>this._map.zoomIn({},{originalEvent:n})),x.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",n=>this._map.zoomOut({},{originalEvent:n})),x.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",n=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:n}):this._map.resetNorth({},{originalEvent:n})}),this._compassIcon=x.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(y){return this._map=y,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 Bc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){x.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(y,n){let c=x.create("button",y,this._container);return c.type="button",c.addEventListener("click",n),c}},A.Popup=class extends o.E{constructor(y){super(),this.remove=()=>(this._content&&x.remove(this._content),this._container&&(x.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new o.k("close"))),this),this._onMouseUp=n=>{this._update(n.point)},this._onMouseMove=n=>{this._update(n.point)},this._onDrag=n=>{this._update(n.point)},this._update=n=>{var c;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=x.create("div","maplibregl-popup",this._map.getContainer()),this._tip=x.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let E of this.options.className.split(" "))this._container.classList.add(E);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?hl(this._lngLat,this._flatPos,this._map.transform):(c=this._lngLat)===null||c===void 0?void 0:c.wrap(),this._trackPointer&&!n)return;let p=this._flatPos=this._pos=this._trackPointer&&n?n:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&n?n:this._map.transform.locationPoint(this._lngLat));let f=this.options.anchor,b=Sc(this.options.offset);if(!f){let E=this._container.offsetWidth,H=this._container.offsetHeight,h;h=p.y+b.bottom.ythis._map.transform.height-H?["bottom"]:[],p.xthis._map.transform.width-E/2&&h.push("right"),f=h.length===0?"bottom":h.join("-")}let L=p.add(b[f]);this.options.subpixelPositioning||(L=L.round()),x.setTransform(this._container,`${kA[f]} translate(${L.x}px,${L.y}px)`),gl(this._container,f,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(xc),y)}addTo(y){return this._map&&this.remove(),this._map=y,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(y){return this._lngLat=o.M.convert(y),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(y){return this.setDOMContent(document.createTextNode(y))}setHTML(y){let n=document.createDocumentFragment(),c=document.createElement("body"),p;for(c.innerHTML=y;p=c.firstChild,p;)n.appendChild(p);return this.setDOMContent(n)}getMaxWidth(){var y;return(y=this._container)===null||y===void 0?void 0:y.style.maxWidth}setMaxWidth(y){return this.options.maxWidth=y,this._update(),this}setDOMContent(y){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=x.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(y),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(y){this._container&&this._container.classList.add(y)}removeClassName(y){this._container&&this._container.classList.remove(y)}setOffset(y){return this.options.offset=y,this._update(),this}toggleClassName(y){if(this._container)return this._container.classList.toggle(y)}setSubpixelPositioning(y){this.options.subpixelPositioning=y}_createCloseButton(){this.options.closeButton&&(this._closeButton=x.create("button","maplibregl-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))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let y=this._container.querySelector(Ml);y&&y.focus()}},A.RasterDEMTileSource=Li,A.RasterTileSource=Rt,A.ScaleControl=class{constructor(y){this._onMove=()=>{LA(this._map,this._container,this.options)},this.setUnit=n=>{this.options.unit=n,LA(this._map,this._container,this.options)},this.options=o.e({},Da,y)}getDefaultPosition(){return"bottom-left"}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-scale",y.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){x.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},A.ScrollZoomHandler=Al,A.Style=Bo,A.TerrainControl=class{constructor(y){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=y}onAdd(y){return this._map=y,this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=x.create("button","maplibregl-ctrl-terrain",this._container),x.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){x.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},A.TwoFingersTouchPitchHandler=ol,A.TwoFingersTouchRotateHandler=BA,A.TwoFingersTouchZoomHandler=rs,A.TwoFingersTouchZoomRotateHandler=wi,A.VectorTileSource=xt,A.VideoSource=Je,A.addSourceType=(y,n)=>o._(void 0,void 0,void 0,function*(){if(hi(y))throw new Error(`A source type called "${y}" already exists.`);((c,p)=>{ui[c]=p})(y,n)}),A.clearPrewarmedResources=function(){let y=It;y&&(y.isPreloaded()&&y.numActive()===1?(y.release(fe),It=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()"))},A.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},A.getRTLTextPluginStatus=function(){return Oi().getRTLTextPluginStatus()},A.getVersion=function(){return Au},A.getWorkerCount=function(){return j.workerCount},A.getWorkerUrl=function(){return o.a.WORKER_URL},A.importScriptInWorkers=function(y){return he().broadcast("importScript",y)},A.prewarm=function(){Ot().acquire(fe)},A.setMaxParallelImageRequests=function(y){o.a.MAX_PARALLEL_IMAGE_REQUESTS=y},A.setRTLTextPlugin=function(y,n){return Oi().setRTLTextPlugin(y,n)},A.setWorkerCount=function(y){j.workerCount=y},A.setWorkerUrl=function(y){o.a.WORKER_URL=y}});var s=r;return s})});var lb=la((fd,md)=>{(function(r,t){typeof fd=="object"&&typeof md<"u"?t(fd):typeof define=="function"&&define.amd?define(["exports"],t):t((r=typeof globalThis<"u"?globalThis:r||self).VectorTextProtocol={})})(fd,function(r){"use strict";function t(gt){return gt&>.__esModule&&Object.prototype.hasOwnProperty.call(gt,"default")?gt.default:gt}function i(gt){if(gt.__esModule)return gt;var bt=gt.default;if(typeof bt=="function"){var ct=function Bt(){return this instanceof Bt?Reflect.construct(bt,arguments,this.constructor):bt.apply(this,arguments)};ct.prototype=bt.prototype}else ct={};return Object.defineProperty(ct,"__esModule",{value:!0}),Object.keys(gt).forEach(function(Bt){var Kt=Object.getOwnPropertyDescriptor(gt,Bt);Object.defineProperty(ct,Bt,Kt.get?Kt:{enumerable:!0,get:function(){return gt[Bt]}})}),ct}function s(gt){return new Function("d","return {"+gt.map(function(bt,ct){return JSON.stringify(bt)+": d["+ct+"]"}).join(",")+"}")}function A(gt){var bt=new RegExp('["'+gt+` +]`),ct=gt.charCodeAt(0);function Bt(ae,we){var ve,Ie,oe={},ye={},Be=[],Re=ae.length,Qi=0,Ri=0;function Pe(){if(Qi>=Re)return ye;if(Ie)return Ie=!1,oe;var Ai,Fi=Qi;if(ae.charCodeAt(Fi)===34){for(var Wi=Fi;Wi++=0?0:1],Bt=Math.abs(pt),Kt=Math.floor(Bt),Yt=60*(Bt-Kt),ae=Math.floor(Yt);return{whole:Kt,minutes:ae,seconds:Math.floor(60*(Yt-ae)),dir:ct}}function at(pt,yt){if(yt||(yt="NSEW"),typeof pt!="string")return null;var ct=(pt=pt.toUpperCase()).match(/^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/);if(!ct)return null;var Bt,Kt=ct[0];if(ct[1]&&ct[5]?(Bt=ct[1],Kt=Kt.slice(0,-1)):Bt=ct[1]||ct[5],Bt&&yt.indexOf(Bt)===-1)return null;var Yt=ct[2]?parseFloat(ct[2]):0,ae=ct[3]?parseFloat(ct[3])/60:0,Be=ct[4]?parseFloat(ct[4])/3600:0,_e=Yt<0?-1:1;return Bt!=="S"&&Bt!=="W"||(_e*=-1),{val:(Math.abs(Yt)+ae+Be)*_e,dim:Bt,matched:Kt,remain:pt.slice(Kt.length)}}$.exports=function(pt,yt){var ct=at(pt,yt);return ct===null?null:ct.val},$.exports.pair=function(pt,yt){var ct=at(pt=pt.trim(),yt);if(!ct)return null;var Bt=at(pt=ct.remain.trim(),yt);return!Bt||Bt.remain?null:ct.dim?function(Kt,Yt,ae){if(ae==="N"||ae==="S")return[Kt,Yt];if(ae==="W"||ae==="E")return[Yt,Kt]}(ct.val,Bt.val,ct.dim):[ct.val,Bt.val]},$.exports.format=O,$.exports.formatPair=function(pt){return O(pt.lat,"lat")+" "+O(pt.lon,"lon")},$.exports.coordToDMS=tt;var Lt=$.exports,Tt=K,Qt=Lt,Ft=/(Lat)(itude)?/gi,vt=/(L)(on|ng)(gitude)?/i;function Jt(pt,yt){var ct,Bt,Kt;for(var Yt in pt)(Bt=Yt.match(yt))&&(!ct||Bt[0].length/Yt.length>Kt)&&(Kt=Bt[0].length/Yt.length,ct=Yt);return ct}function qt(pt){return Jt(pt,Ft)}function At(pt){return Jt(pt,vt)}function lt(pt){return typeof pt=="object"?Object.keys(pt).length:0}function kt(pt){var yt=[];return[",",";"," ","|"].forEach(function(ct){var Bt=Tt.dsvFormat(ct).parse(pt);if(Bt.length>=1){for(var Kt=lt(Bt[0]),Yt=0;Yt{ct[Bt]=Kt});return ct}function Ot(pt){return pt?.nodeType===1}function Ae(pt){return fe(pt,"line",yt=>Object.assign({},j(yt,"color",ct=>({stroke:`#${ct}`})),bt(yt,"opacity",ct=>({"stroke-opacity":ct})),bt(yt,"width",ct=>({"stroke-width":96*ct/25.4}))))}function he(pt){let yt=[];if(pt===null)return yt;for(let ct of Array.from(pt.childNodes)){if(!Ot(ct))continue;let Bt=de(ct.nodeName);if(Bt==="gpxtpx:TrackPointExtension")yt=yt.concat(he(ct));else{let Kt=wt(ct);yt.push([Bt,He(Kt)])}}return yt}function de(pt){return["heart","gpxtpx:hr","hr"].includes(pt)?"heart":pt}function He(pt){let yt=parseFloat(pt);return isNaN(yt)?pt:yt}function Re(pt){let yt=[parseFloat(pt.getAttribute("lon")||""),parseFloat(pt.getAttribute("lat")||"")];if(isNaN(yt[0])||isNaN(yt[1]))return null;It(pt,"ele",Bt=>{yt.push(Bt)});let ct=Ut(pt,"time");return{coordinates:yt,time:ct?wt(ct):null,extendedValues:he(Ut(pt,"extensions"))}}function je(pt){let yt=Ht(pt,["name","cmt","desc","type","time","keywords"]),ct=Array.from(pt.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3","*"));for(let Kt of ct)Kt.parentNode?.parentNode===pt&&(yt[Kt.tagName.replace(":","_")]=wt(Kt));let Bt=ne(pt,"link");return Bt.length&&(yt.links=Bt.map(Kt=>Object.assign({href:Kt.getAttribute("href")},Ht(Kt,["text","type"])))),yt}function Me(pt,yt){let ct=ne(pt,yt),Bt=[],Kt=[],Yt={};for(let ae=0;ae1,ae=Object.assign({_gpxType:"trk"},je(pt),Ae(Ut(pt,"extensions")),Bt.length?{coordinateProperties:{times:Yt?Bt:Bt[0]}}:{});for(let Be of Kt){ct.push(Be.line),ae.coordinateProperties||(ae.coordinateProperties={});let _e=ae.coordinateProperties,Ce=Object.entries(Be.extendedValues);for(let se=0;senew Array(Ge.line.length).fill(null))),_e[ye][se]=be):_e[ye]=be}}return{type:"Feature",properties:ae,geometry:Yt?{type:"MultiLineString",coordinates:ct}:{type:"LineString",coordinates:ct[0]}}}function Rt(pt){let yt=Object.assign(je(pt),Ht(pt,["sym"])),ct=Re(pt);return ct?{type:"Feature",properties:yt,geometry:{type:"Point",coordinates:ct.coordinates}}:null}function*Li(pt){for(let yt of ne(pt,"trk")){let ct=xt(yt);ct&&(yield ct)}for(let yt of ne(pt,"rte")){let ct=gi(yt);ct&&(yield ct)}for(let yt of ne(pt,"wpt")){let ct=Rt(yt);ct&&(yield ct)}}let Ue="http://www.garmin.com/xmlschemas/ActivityExtension/v2",Ee=[["heartRate","heartRates"],["Cadence","cadences"],["Speed","speeds"],["Watts","watts"]],Ne=[["TotalTimeSeconds","totalTimeSeconds"],["DistanceMeters","distanceMeters"],["MaximumSpeed","maxSpeed"],["AverageHeartRateBpm","avgHeartRate"],["MaximumHeartRateBpm","maxHeartRate"],["AvgSpeed","avgSpeed"],["AvgWatts","avgWatts"],["MaxWatts","maxWatts"]];function Je(pt,yt){let ct=[];for(let[Bt,Kt]of yt){let Yt=Ut(pt,Bt);if(!Yt){let Be=pt.getElementsByTagNameNS(Ue,Bt);Be.length&&(Yt=Be[0])}let ae=parseFloat(wt(Yt));isNaN(ae)||ct.push([Kt,ae])}return ct}function ze(pt){let yt=[It(pt,"LongitudeDegrees"),It(pt,"LatitudeDegrees")];if(yt[0]===void 0||isNaN(yt[0])||yt[1]===void 0||isNaN(yt[1]))return null;let ct=Ut(pt,"HeartRateBpm"),Bt=wt(Ut(pt,"Time"));return Ut(pt,"AltitudeMeters",Kt=>{let Yt=parseFloat(wt(Kt));isNaN(Yt)||yt.push(Yt)}),{coordinates:yt,time:Bt||null,heartRate:ct?parseFloat(wt(ct)):null,extensions:Je(pt,Ee)}}function ui(pt){let yt=ne(pt,"Trackpoint"),ct=[],Bt=[],Kt=[];if(yt.length<2)return null;let Yt={},ae={extendedProperties:Yt};for(let Be=0;Be({name:wt(_e)})));for(let _e of yt)ae=ui(_e),ae&&(ct.push(ae.line),ae.times.length&&Bt.push(ae.times),ae.heartRates.length&&Kt.push(ae.heartRates),Yt.push(ae.extendedProperties));for(let _e=0;_eArray(ye.length).fill(null))),Be[se][_e]=Ce[se])}return ct.length===0?null:((Bt.length||Kt.length)&&(Be.coordinateProperties=Object.assign(Bt.length?{times:ct.length===1?Bt[0]:Bt}:{},Kt.length?{heart:ct.length===1?Kt[0]:Kt}:{})),{type:"Feature",properties:Be,geometry:ct.length===1?{type:"LineString",coordinates:ct[0]}:{type:"MultiLineString",coordinates:ct}})}function*Ei(pt){for(let yt of ne(pt,"Lap")){let ct=hi(yt);ct&&(yield ct)}for(let yt of ne(pt,"Courses")){let ct=hi(yt);ct&&(yield ct)}}function Pi(pt,yt){let ct={},Bt=yt=="stroke"||yt==="fill"?yt:yt+"-color";return pt[0]==="#"&&(pt=pt.substring(1)),pt.length===6||pt.length===3?ct[Bt]="#"+pt:pt.length===8&&(ct[yt+"-opacity"]=parseInt(pt.substring(0,2),16)/255,ct[Bt]="#"+pt.substring(6,8)+pt.substring(4,6)+pt.substring(2,4)),ct}function Ie(pt,yt,ct){let Bt={};return It(pt,yt,Kt=>{Bt[ct]=Kt}),Bt}function Oi(pt,yt){return fe(pt,"color",ct=>Pi(wt(ct),yt))}function mi(pt){return fe(pt,"Icon",(yt,ct)=>(j(yt,"href",Bt=>{ct.icon=Bt}),ct))}function Vi(pt){return Object.assign({},function(yt){return fe(yt,"PolyStyle",(ct,Bt)=>Object.assign(Bt,fe(ct,"color",Kt=>Pi(wt(Kt),"fill")),j(ct,"fill",Kt=>{if(Kt==="0")return{"fill-opacity":0}}),j(ct,"outline",Kt=>{if(Kt==="0")return{"stroke-opacity":0}})))}(pt),function(yt){return fe(yt,"LineStyle",ct=>Object.assign(Oi(ct,"stroke"),Ie(ct,"width","stroke-width")))}(pt),function(yt){return fe(yt,"LabelStyle",ct=>Object.assign(Oi(ct,"label"),Ie(ct,"scale","label-scale")))}(pt),function(yt){return fe(yt,"IconStyle",ct=>Object.assign(Oi(ct,"icon"),Ie(ct,"scale","icon-scale"),Ie(ct,"heading","icon-heading"),fe(ct,"hotSpot",Bt=>{let Kt=parseFloat(Bt.getAttribute("x")||""),Yt=parseFloat(Bt.getAttribute("y")||""),ae=Bt.getAttribute("xunits")||"",Be=Bt.getAttribute("yunits")||"";return isNaN(Kt)||isNaN(Yt)?{}:{"icon-offset":[Kt,Yt],"icon-offset-units":[ae,Be]}}),mi(ct)))}(pt))}let We=pt=>Number(pt),Se={string:pt=>pt,int:We,uint:We,short:We,ushort:We,float:We,double:We,bool:pt=>Boolean(pt)};function $e(pt,yt){return fe(pt,"ExtendedData",(ct,Bt)=>{for(let Kt of ne(ct,"Data"))Bt[Kt.getAttribute("name")||""]=wt(Ut(Kt,"value"));for(let Kt of ne(ct,"SimpleData")){let Yt=Kt.getAttribute("name")||"",ae=yt[Yt]||Se.string;Bt[Yt]=ae(wt(Kt))}return Bt})}function di(pt){let yt=Ut(pt,"description");for(let ct of Array.from(yt?.childNodes||[]))if(ct.nodeType===4)return{description:{"@type":"html",value:wt(ct)}};return{}}function Zi(pt){return fe(pt,"TimeSpan",yt=>({timespan:{begin:wt(Ut(yt,"begin")),end:wt(Ut(yt,"end"))}}))}function qi(pt){return fe(pt,"TimeStamp",yt=>({timestamp:wt(Ut(yt,"when"))}))}function vi(pt,yt){return j(pt,"styleUrl",ct=>(ct=te(ct),yt[ct]?Object.assign({styleUrl:ct},yt[ct]):{styleUrl:ct}))}let tr=/\s*/g,Lr=/^\s*|\s*$/g,ft=/\s+/;function Y(pt){return pt.replace(tr,"").split(",").map(parseFloat).filter(yt=>!isNaN(yt)).slice(0,3)}function q(pt){return pt.replace(Lr,"").split(ft).map(Y).filter(yt=>yt.length>=2)}function rt(pt){let yt=ne(pt,"coord");yt.length===0&&(yt=function(Bt,Kt,Yt){return Array.from(Bt.getElementsByTagNameNS(Yt,Kt))}(pt,"coord","*"));let ct=yt.map(Bt=>wt(Bt).split(" ").map(parseFloat));return ct.length===0?null:{geometry:ct.length>2?{type:"LineString",coordinates:ct}:{type:"Point",coordinates:ct[0]},times:ne(pt,"when").map(Bt=>wt(Bt))}}function ht(pt){if(pt.length===0)return pt;let yt=pt[0],ct=pt[pt.length-1],Bt=!0;for(let Kt=0;Kt=2&&yt.push({type:"Point",coordinates:Yt});break}case"LinearRing":case"LineString":{let Yt=q(Zt(Kt));Yt.length>=2&&yt.push({type:"LineString",coordinates:Yt});break}case"Polygon":{let Yt=[];for(let ae of ne(Kt,"LinearRing")){let Be=ht(q(Zt(ae)));Be.length>=4&&Yt.push(Be)}Yt.length&&yt.push({type:"Polygon",coordinates:Yt});break}case"Track":case"gx:Track":{let Yt=rt(Kt);if(!Yt)break;let{times:ae,geometry:Be}=Yt;yt.push(Be),ae.length&&ct.push(ae);break}}}return{geometries:yt,coordTimes:ct}}function Xt(pt,yt,ct,Bt){let{coordTimes:Kt,geometries:Yt}=zt(pt),ae=function(Ce){return Ce.length===0?null:Ce.length===1?Ce[0]:{type:"GeometryCollection",geometries:Ce}}(Yt);if(!ae&&Bt.skipNullGeometry)return null;let Be={type:"Feature",geometry:ae,properties:Object.assign(Ht(pt,["name","address","visibility","open","phoneNumber","description"]),di(pt),vi(pt,yt),Vi(pt),$e(pt,ct),Zi(pt),qi(pt),Kt.length?{coordinateProperties:{times:Kt.length===1?Kt[0]:Kt}}:{})};Be.properties?.visibility!==void 0&&(Be.properties.visibility=Be.properties.visibility!=="0");let _e=pt.getAttribute("id");return _e!==null&&_e!==""&&(Be.id=_e),Be}function Mt(pt){return Ut(pt,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ht(q(Zt(pt)))]}}:function(yt){let ct=Ut(yt,"LatLonBox");if(ct){let Bt=It(ct,"north"),Kt=It(ct,"west"),Yt=It(ct,"east"),ae=It(ct,"south"),Be=It(ct,"rotation");if(typeof Bt=="number"&&typeof ae=="number"&&typeof Kt=="number"&&typeof Yt=="number"){let _e=[Kt,ae,Yt,Bt],Ce=[[[Kt,Bt],[Yt,Bt],[Yt,ae],[Kt,ae],[Kt,Bt]]];return typeof Be=="number"&&(Ce=function(se,ye,be){let Ge=[(se[0]+se[2])/2,(se[1]+se[3])/2];return[ye[0].map(Ui=>{let Ri=Ui[1]-Ge[1],Pe=Ui[0]-Ge[0],Qe=Math.sqrt(Math.pow(Ri,2)+Math.pow(Pe,2)),Ai=Math.atan2(Ri,Pe)+be*re;return[Ge[0]+Math.cos(Ai)*Qe,Ge[1]+Math.sin(Ai)*Qe]})]}(_e,Ce,Be)),{bbox:_e,geometry:{type:"Polygon",coordinates:Ce}}}}return null}(pt)}let re=Math.PI/180;function ce(pt,yt,ct,Bt){let Kt=Mt(pt),Yt=Kt?.geometry||null;if(!Yt&&Bt.skipNullGeometry)return null;let ae={type:"Feature",geometry:Yt,properties:Object.assign({"@geometry-type":"groundoverlay"},Ht(pt,["name","address","visibility","open","phoneNumber","description"]),di(pt),vi(pt,yt),Vi(pt),mi(pt),$e(pt,ct),Zi(pt),qi(pt))};Kt?.bbox&&(ae.bbox=Kt.bbox),ae.properties?.visibility!==void 0&&(ae.properties.visibility=ae.properties.visibility!=="0");let Be=pt.getAttribute("id");return Be!==null&&Be!==""&&(ae.id=Be),ae}function pe(pt){let yt=pt.getAttribute("id"),ct=pt.parentNode;return!yt&&Ot(ct)&&ct.localName==="CascadingStyle"&&(yt=ct.getAttribute("kml:id")||ct.getAttribute("id")),te(yt||"")}function me(pt){let yt={};for(let ct of ne(pt,"Style"))yt[pe(ct)]=Vi(ct);for(let ct of ne(pt,"StyleMap")){let Bt=te(ct.getAttribute("id")||"");j(ct,"styleUrl",Kt=>{Kt=te(Kt),yt[Kt]&&(yt[Bt]=yt[Kt])})}return yt}function Xe(pt){let yt={};for(let ct of ne(pt,"SimpleField"))yt[ct.getAttribute("name")||""]=Se[ct.getAttribute("type")||""]||Se.string;return yt}let oi=["name","visibility","open","address","description","phoneNumber","visibility"];function*ii(pt,yt={skipNullGeometry:!1}){let ct=me(pt),Bt=Xe(pt);for(let Kt of ne(pt,"Placemark")){let Yt=Xt(Kt,ct,Bt,yt);Yt&&(yield Yt)}for(let Kt of ne(pt,"GroundOverlay")){let Yt=ce(Kt,ct,Bt,yt);Yt&&(yield Yt)}}var Ni=Object.freeze({__proto__:null,gpx:function(pt){return{type:"FeatureCollection",features:Array.from(Li(pt))}},gpxGen:Li,kml:function(pt,yt={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(ii(pt,yt))}},kmlGen:ii,kmlWithFolders:function(pt,yt={skipNullGeometry:!1}){let ct=me(pt),Bt=Xe(pt),Kt={type:"root",children:[]};return function Yt(ae,Be,_e){if(Ot(ae))switch(ae.tagName){case"GroundOverlay":{let Ce=ce(ae,ct,Bt,_e);Ce&&Be.children.push(Ce);break}case"Placemark":{let Ce=Xt(ae,ct,Bt,_e);Ce&&Be.children.push(Ce);break}case"Folder":{let Ce=function(se){let ye={};for(let be of Array.from(se.childNodes))Ot(be)&&oi.includes(be.tagName)&&(ye[be.tagName]=wt(be));return{type:"folder",meta:ye,children:[]}}(ae);Be.children.push(Ce),Be=Ce;break}}if(ae.childNodes)for(let Ce=0;Ce=0?1:-1)}function Bt(Yt,ae,Be){var _e=2*((Yt=ct(Yt*Be))-(ae=ct(ae*Be)));_e<0&&(_e=-_e-1);for(var Ce="";_e>=32;)Ce+=String.fromCharCode(63+(32|31&_e)),_e/=32;return Ce+=String.fromCharCode(63+(0|_e))}function Kt(Yt){for(var ae=[],Be=0;Be=32);Be=1&Ge?(-Ge-1)/2:Ge/2,be=1,Ge=0;do Ge+=(31&(Ui=Yt.charCodeAt(_e++)-63))*be,be*=32;while(Ui>=32);Ce+=Be,se+=1&Ge?(-Ge-1)/2:Ge/2,ye.push([Ce/Ri,se/Ri])}return ye},yt.encode=function(Yt,ae){if(!Yt.length)return"";for(var Be=Math.pow(10,Number.isInteger(ae)?ae:5),_e=Bt(Yt[0][0],0,Be)+Bt(Yt[0][1],0,Be),Ce=1;Ce{let pt=se=>se[0],yt=se=>se[se.length-1],ct=se=>se.join(","),Bt=(se,ye,be)=>{let Ge=se[ye];Ge?Ge.push(be):se[ye]=[be]},Kt=(se,ye,be)=>{let Ge=se[ye],Ui=null;Ge&&(Ui=Ge.indexOf(be))>=0&&Ge.splice(Ui,1)},Yt=(se,ye)=>{let be=se[ye];return be&&be.length>0?be[0]:null},ae=se=>se.length>3&&ct(pt(se))===ct(yt(se)),Be=(se,ye,be)=>{ye=ye||0,be=be||1;let Ge=se.reduce((nr,ai,dr)=>se[nr][ye]>ai[ye]?nr:dr,0),Ui=Ge<=0?se.length-2:Ge-1,Ri=Ge>=se.length-1?1:Ge+1,Pe=se[Ui][ye],Qe=se[Ge][ye],Ai=se[Ri][ye],Fi=se[Ui][be],Wi=se[Ge][be];return(Qe-Pe)*(se[Ri][be]-Fi)-(Ai-Pe)*(Wi-Fi)<0?"clockwise":"counterclockwise"},_e=se=>se instanceof Array?se.map(_e):parseFloat(se);class Ce extends Map{constructor(){super(),this.binders=[]}add(ye,be){this.has(ye)||this.set(ye,be)}addBinder(ye){this.binders.push(ye)}bindAll(){this.binders.forEach(ye=>ye.bind())}}return{purgeProps:(se,ye)=>{if(se){let be=Object.assign({},se);if(ye)for(let Ge of ye)delete be[Ge];return be}return{}},mergeProps:(se,ye)=>(se=se||{},ye=ye||{},Object.assign(se,ye)),first:pt,last:yt,coordsToKey:ct,addToMap:Bt,removeFromMap:Kt,getFirstFromMap:Yt,isRing:ae,ringDirection:Be,ptInsidePolygon:(se,ye,be,Ge)=>{be=be||0,Ge=Ge||1;let Ui=!1;for(let Ri=0,Pe=ye.length-1;Ri=0){let be=[ye,1];se&&be.push(se),[].splice.apply(this.container,be)}}else if(typeof this.container=="object"){let ye=Object.keys(this.container).find(be=>this.container[be]===this);ye&&(se?this.container[ye]=se:delete this.container[ye])}}},WayCollection:class extends Array{constructor(){super(),this.firstMap={},this.lastMap={}}addWay(se){(se=se.toCoordsArray()).length>0&&(this.push(se),Bt(this.firstMap,ct(pt(se)),se),Bt(this.lastMap,ct(yt(se)),se))}toStrings(){let se=[],ye=null;for(;ye=this.shift();){Kt(this.firstMap,ct(pt(ye)),ye),Kt(this.lastMap,ct(yt(ye)),ye);let be=ye,Ge=null;do{let Ui=ct(yt(be)),Ri=!1;Ge=Yt(this.firstMap,Ui),Ge||(Ge=Yt(this.lastMap,Ui),Ri=!0),Ge&&(this.splice(this.indexOf(Ge),1),Kt(this.firstMap,ct(pt(Ge)),Ge),Kt(this.lastMap,ct(yt(Ge)),Ge),Ri&&(Ge.length>be.length&&([be,Ge]=[Ge,be]),Ge.reverse()),be=be.concat(Ge.slice(1)))}while(Ge);se.push(_e(be))}return se}toRings(se){let ye=this.toStrings(),be=[],Ge=null;for(;Ge=ye.shift();)ae(Ge)&&(Be(Ge)!==se&&Ge.reverse(),be.push(Ge));return be}}}})(),Cr={building:{},highway:{whitelist:["services","rest_area","escape","elevator"]},natural:{blacklist:["coastline","cliff","ridge","arete","tree_row"]},landuse:{},waterway:{whitelist:["riverbank","dock","boatyard","dam"]},amenity:{},leisure:{},barrier:{whitelist:["city_wall","ditch","hedge","retaining_wall","wall","spikes"]},railway:{whitelist:["station","turntable","roundhouse","platform"]},area:{},boundary:{},man_made:{blacklist:["cutline","embankment","pipeline"]},power:{whitelist:["plant","substation","generator","transformer"]},place:{},shop:{},aeroway:{blacklist:["taxiway"]},tourism:{},historic:{},public_transport:{},office:{},"building:part":{},military:{},ruins:{},"area:highway":{},craft:{},golf:{},indoor:{}},ki=(()=>{let{first:pt,last:yt,coordsToKey:ct,addToMap:Bt,removeFromMap:Kt,getFirstFromMap:Yt,isRing:ae,ringDirection:Be,ptInsidePolygon:_e,strToFloat:Ce,LateBinder:se,WayCollection:ye}=zi,be=Cr;class Ge{constructor(Qe,Ai,Fi){this.type=Qe,this.id=Ai,this.refElems=Fi,this.tags={},this.props={id:this.getCompositeId()},this.refCount=0,this.hasTag=!1,Fi&&Fi.add(this.getCompositeId(),this)}addTags(Qe){this.tags=Object.assign(this.tags,Qe),this.hasTag=!!Qe}addTag(Qe,Ai){this.tags[Qe]=Ai,this.hasTag=!!Qe}addProp(Qe,Ai){this.props[Qe]=Ai}addProps(Qe){this.props=Object.assign(this.props,Qe)}getCompositeId(){return`${this.type}/${this.id}`}getProps(){return Object.assign(this.props,this.tags)}toFeatureArray(){return[]}}class Ui extends Ge{constructor(Qe,Ai){super("node",Qe,Ai),this.latLng=null}setLatLng(Qe){this.latLng=Qe}toFeatureArray(){return this.latLng?[{type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"Point",coordinates:Ce([this.latLng.lon,this.latLng.lat])}}]:[]}getLatLng(){return this.latLng}}class Ri extends Ge{constructor(Qe,Ai){super("way",Qe,Ai),this.latLngArray=[],this.isPolygon=!1}addLatLng(Qe){this.latLngArray.push(Qe)}setLatLngArray(Qe){this.latLngArray=Qe}addNodeRef(Qe){let Ai=new se(this.latLngArray,function(Fi){let Wi=this.refElems.get(`node/${Fi}`);if(Wi)return Wi.refCount++,Wi.getLatLng()},this,[Qe]);this.latLngArray.push(Ai),this.refElems.addBinder(Ai)}analyzeGeometryType(Qe,Ai){let Fi=be[Qe];Fi&&(this.isPolygon=!0,Fi.whitelist?this.isPolygon=Fi.whitelist.indexOf(Ai)>=0:Fi.blacklist&&(this.isPolygon=!(Fi.blacklist.indexOf(Ai)>=0)))}addTags(Qe){super.addTags(Qe);for(let[Ai,Fi]of Object.entries(Qe))this.analyzeGeometryType(Ai,Fi)}addTag(Qe,Ai){super.addTag(Qe,Ai),this.analyzeGeometryType(Qe,Ai)}toCoordsArray(){return this.latLngArray.map(Qe=>[Qe.lon,Qe.lat])}toFeatureArray(){let Qe=this.toCoordsArray();if(Qe.length>1){Qe=Ce(Qe);let Ai={type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"LineString",coordinates:Qe}};return this.isPolygon&&ae(Qe)?(Be(Qe)!=="counterclockwise"&&Qe.reverse(),Ai.geometry={type:"Polygon",coordinates:[Qe]},[Ai]):[Ai]}return[]}}return{Node:Ui,Way:Ri,Relation:class extends Ge{constructor(Pe,Qe){super("relation",Pe,Qe),this.relations=[],this.nodes=[],this.bounds=null}setBounds(Pe){this.bounds=Pe}addMember(Pe){switch(Pe.type){case"relation":let Qe=new se(this.relations,function(Wi){let nr=this.refElems.get(`relation/${Wi}`);if(nr)return nr.refCount++,nr},this,[Pe.ref]);this.relations.push(Qe),this.refElems.addBinder(Qe);break;case"way":Pe.role||(Pe.role="");let Ai=this[Pe.role];if(Ai||(Ai=this[Pe.role]=[]),Pe.geometry){let Wi=new Ri(Pe.ref,this.refElems);Wi.setLatLngArray(Pe.geometry),Wi.refCount++,Ai.push(Wi)}else if(Pe.nodes){let Wi=new Ri(Pe.ref,this.refElems);for(let nr of Pe.nodes)Wi.addNodeRef(nr);Wi.refCount++,Ai.push(Wi)}else{let Wi=new se(Ai,function(nr){let ai=this.refElems.get(`way/${nr}`);if(ai)return ai.refCount++,ai},this,[Pe.ref]);Ai.push(Wi),this.refElems.addBinder(Wi)}break;case"node":let Fi=null;if(Pe.lat&&Pe.lon){Fi=new Ui(Pe.ref,this.refElems),Fi.setLatLng({lon:Pe.lon,lat:Pe.lat}),Pe.tags&&Fi.addTags(Pe.tags);for(let[Wi,nr]of Object.entries(Pe))["id","type","lat","lon"].indexOf(Wi)<0&&Fi.addProp(Wi,nr);Fi.refCount++,this.nodes.push(Fi)}else{let Wi=new se(this.nodes,function(nr){let ai=this.refElems.get(`node/${nr}`);if(ai)return ai.refCount++,ai},this,[Pe.ref]);this.nodes.push(Wi),this.refElems.addBinder(Wi)}}}toFeatureArray(){let Pe=[],Qe=[],Ai=[],Fi=["outer","inner",""];for(let ai of this.relations)if(ai)for(let dr of Fi){let Or=ai[dr];if(Or){let Ur=this[dr];Ur?[].splice.apply(Ur,[Ur.length,0].concat(Or)):this[dr]=Or}}for(let ai of Fi){let dr=this[ai];if(dr){this[ai]=new ye;for(let Or of dr)this[ai].addWay(Or)}}let Wi=null,nr={type:"Feature",id:this.getCompositeId(),bbox:this.bounds,properties:this.getProps()};this.bounds||delete nr.bbox,this.outer?(Wi=((ai,dr)=>{let Or=ai?ai.toRings("counterclockwise"):[],Ur=dr?dr.toRings("clockwise"):[];if(Or.length>0){let _n=[],vn=null;for(vn of Or)_n.push([vn]);for(;vn=Ur.shift();)for(let ws in Or)if(_e(pt(vn),Or[ws])){_n[ws].push(vn);break}return _n.length===1?{type:"Polygon",coordinates:_n[0]}:{type:"MultiPolygon",coordinates:_n}}return null})(this.outer,this.inner),Wi&&(nr.geometry=Wi,Pe.push(nr))):this[""]&&(Wi=(ai=>{let dr=ai?ai.toStrings():[];return dr.length>0?dr.length===1?{type:"LineString",coordinates:dr[0]}:{type:"MultiLineString",coordinates:dr}:null})(this[""]),Wi&&(nr.geometry=Wi,Qe.push(nr)));for(let ai of this.nodes)Ai=Ai.concat(ai.toFeatureArray());return Pe.concat(Qe).concat(Ai)}}}})(),fr=(()=>{function pt(ct){return ct.match(/^(.+?)\[(.+?)\]>$/g)!=null}function yt(ct){let Bt=/^(.+?)\[(.+?)\]>$/g.exec(ct);return Bt?{evt:Bt[1]+">",exp:Bt[2]}:{evt:ct}}return class{constructor(ct){ct&&(this.queryParent=!!ct.queryParent,this.progressive=ct.progressive,this.queryParent&&(this.parentMap=new WeakMap)),this.evtListeners={}}parse(ct,Bt,Kt){Kt=Kt?Kt+".":"";let Yt=/<([^ >\/]+)(.*?)>/gm,ae=null,Be=[];for(;ae=Yt.exec(ct);){let _e=ae[1],Ce={$tag:_e},se=Kt+_e,ye=ae[2].trim(),be=!1;(ye.endsWith("/")||_e.startsWith("?")||_e.startsWith("!"))&&(be=!0);let Ge=/([^ ]+?)="(.+?)"/g,Ui=/([^ ]+?)='(.+?)'/g,Ri=null,Pe=!1;for(;Ri=Ge.exec(ye);)Pe=!0,Ce[Ri[1]]=Ri[2];if(!Pe)for(;Ri=Ui.exec(ye);)Pe=!0,Ce[Ri[1]]=Ri[2];if(Pe||ye===""||(Ce.text=ye),this.progressive&&this.emit(`<${se}>`,Ce,Bt),!be){let Qe=new RegExp(`([^]+?)`,"g");Qe.lastIndex=Yt.lastIndex;let Ai=Qe.exec(ct);if(Ai&&Ai[1]){Yt.lastIndex=Qe.lastIndex;let Fi=this.parse(Ai[1],Ce,se);Fi.length>0?Ce.$innerNodes=Fi:Ce.$innerText=Ai[1]}}this.queryParent&&Bt&&this.parentMap.set(Ce,Bt),this.progressive&&this.emit(``,Ce,Bt),Be.push(Ce)}return Be}getParent(ct){return this.queryParent?this.parentMap.get(ct):null}#t(ct,Bt){let Kt=this.evtListeners[ct];Kt?Kt.push(Bt):this.evtListeners[ct]=[Bt]}addListener(ct,Bt){pt(ct)&&(ct=yt(ct),Bt.condition=function(Kt){let Yt="return "+Kt.replace(/(\$.+?)(?=[=!.])/g,"node.$&")+";";return new Function("node",Yt)}(ct.exp),ct=ct.evt),this.#t(ct,Bt)}#e(ct,Bt){let Kt=this.evtListeners[ct],Yt=null;Kt&&(Yt=Kt.indexOf(Bt))>=0&&Kt.splice(Yt,1)}removeListener(ct,Bt){pt(ct)&&(ct=(ct=yt(ct)).evt),this.#e(ct,Bt)}emit(ct,...Bt){let Kt=this.evtListeners[ct];if(Kt)for(let Yt of Kt)Yt.condition?Yt.condition.apply(null,Bt)===!0&&Yt.apply(null,Bt):Yt.apply(null,Bt)}on(ct,Bt){this.addListener(ct,Bt)}off(ct,Bt){this.removeListener(ct,Bt)}}})();let{Node:br,Way:Tr,Relation:Dt}=ki,{purgeProps:Ke,RefElements:Te}=zi,or=fr;var Er=(pt,yt)=>{let ct=!1,Bt=!1,Kt=!0;(_e=>{if(_e){ct=!(!_e.completeFeature&&!_e.allFeatures),Bt=!!_e.renderTagged;let Ce=_e.suppressWay||_e.excludeWay;Ce===void 0||Ce||(Kt=!1)}})(yt);let Yt=(_e=>_e.elements?"json":_e.indexOf("=0?"xml":_e.trim().startsWith("{")?"json-raw":"invalid")(pt),ae=new Te,Be=[];Yt==="json-raw"&&(Yt=(pt=JSON.parse(pt)).elements?"json":"invalid"),Yt==="json"?(_e=>{for(let Ce of _e.elements)switch(Ce.type){case"node":let se=new br(Ce.id,ae);Ce.tags&&se.addTags(Ce.tags),se.addProps(Ke(Ce,["id","type","tags","lat","lon"])),se.setLatLng(Ce);break;case"way":let ye=new Tr(Ce.id,ae);if(Ce.tags&&ye.addTags(Ce.tags),ye.addProps(Ke(Ce,["id","type","tags","nodes","geometry"])),Ce.nodes)for(let Ge of Ce.nodes)ye.addNodeRef(Ge);else Ce.geometry&&ye.setLatLngArray(Ce.geometry);break;case"relation":let be=new Dt(Ce.id,ae);if(Ce.bounds&&be.setBounds([parseFloat(Ce.bounds.minlon),parseFloat(Ce.bounds.minlat),parseFloat(Ce.bounds.maxlon),parseFloat(Ce.bounds.maxlat)]),Ce.tags&&be.addTags(Ce.tags),be.addProps(Ke(Ce,["id","type","tags","bounds","members"])),Ce.members)for(let Ge of Ce.members)be.addMember(Ge)}})(pt):Yt==="xml"&&(_e=>{let Ce=new or({progressive:!0});Ce.on("",se=>{let ye=new br(se.id,ae);for(let[be,Ge]of Object.entries(se))!be.startsWith("$")&&["id","lon","lat"].indexOf(be)<0&&ye.addProp(be,Ge);if(ye.setLatLng(se),se.$innerNodes)for(let be of se.$innerNodes)be.$tag==="tag"&&ye.addTag(be.k,be.v)}),Ce.on("",se=>{let ye=new Tr(se.id,ae);for(let[be,Ge]of Object.entries(se))!be.startsWith("$")&&["id"].indexOf(be)<0&&ye.addProp(be,Ge);if(se.$innerNodes)for(let be of se.$innerNodes)be.$tag==="nd"?be.lon&&be.lat?ye.addLatLng(be):be.ref&&ye.addNodeRef(be.ref):be.$tag==="tag"&&ye.addTag(be.k,be.v)}),Ce.on("",se=>{new Dt(se.id,ae)}),Ce.on("",(se,ye)=>{let be=ae.get(`relation/${ye.id}`),Ge={type:se.type,role:se.role?se.role:"",ref:se.ref};if(se.lat&&se.lon){Ge.lat=se.lat,Ge.lon=se.lon,Ge.tags={};for(let[Ui,Ri]of Object.entries(se))!Ui.startsWith("$")&&["type","lat","lon"].indexOf(Ui)<0&&(Ge[Ui]=Ri)}if(se.$innerNodes){let Ui=[],Ri=[];for(let Pe of se.$innerNodes)Pe.lat&&Pe.lon?Ui.push(Pe):Ri.push(Pe.ref);Ui.length>0?Ge.geometry=Ui:Ri.length>0&&(Ge.nodes=Ri)}be.addMember(Ge)}),Ce.on("",(se,ye)=>{ae.get(`relation/${ye.id}`).setBounds([parseFloat(se.minlon),parseFloat(se.minlat),parseFloat(se.maxlon),parseFloat(se.maxlat)])}),Ce.on("",(se,ye)=>{ae.get(`relation/${ye.id}`).addTag(se.k,se.v)}),Ce.parse(_e)})(pt),ae.bindAll();for(let _e of ae.values())if(_e.refCount<=0||_e.hasTag&&Bt&&!(_e instanceof Tr&&Kt)){let Ce=_e.toFeatureArray();if(_e instanceof Dt&&!ct&&Ce.length>0)return Ce[0].geometry;Be=Be.concat(Ce)}return{type:"FeatureCollection",features:Be}},Ji=t(Er);let Mr=["topojson","osm","kml","gpx","tcx","csv","tsv","polyline"];class vs{constructor(yt,ct,Bt={}){this.blankGeoJSON=()=>({type:"FeatureCollection",features:[]}),this._rawData=ct,this._format=yt,this._options=Bt;let Kt={topojson:this.loadTopoJson,osm:this.loadOsm,kml:this.loadXml,gpx:this.loadXml,tcx:this.loadXml,csv:this.loadCsv,tsv:this.loadCsv,polyline:this.loadPolyline};this._conversionFn=Kt[yt]}async convert(){return this._conversionFn?this._conversionFn():new Promise((yt,ct)=>ct(`No converter exists for ${this._format}`))}async loadXml(){return Ni[this._format](new DOMParser().parseFromString(this._rawData,"text/xml"))}async loadCsv(){let yt=this._options.csvOptions||{};return this._format==="tsv"&&(yt.delimiter=" "),await new Promise((ct,Bt)=>{_t.csv2geojson(this._rawData,yt,(Kt,Yt)=>{Kt?Bt(Kt):ct(Yt)})})}async loadTopoJson(){let yt={};try{yt=JSON.parse(this._rawData)}catch{throw"Invalid TopoJson"}let ct=this.blankGeoJSON();return yt.type==="Topology"&&yt.objects!==void 0&&(ct={type:"FeatureCollection",features:ct.features=Object.keys(yt.objects).map(Bt=>{return Kt=yt,typeof(Yt=Bt)=="string"&&(Yt=Kt.objects[Yt]),Yt.type==="GeometryCollection"?{type:"FeatureCollection",features:Yt.geometries.map(function(ae){return ie(Kt,ae)})}:ie(Kt,Yt);var Kt,Yt}).reduce((Bt,Kt)=>[...Bt,...Kt.features],[])}),ct}async loadOsm(){return Ji(this._rawData)}async loadPolyline(){let yt=this._options.polylineOptions||{};return await new Promise((ct,Bt)=>{try{let Kt=rr.toGeoJSON(this._rawData,yt.precision),Yt=Kt;yt.type==="point"?Kt.coordinates.length===1?Yt={type:"Point",coordinates:Kt.coordinates[0]}:console.warn("Cannot convert polyline to "+yt.type):yt.type==="polygon"&&(Kt.coordinates[0][0]===Kt.coordinates[Kt.coordinates.length-1][0]&&Kt.coordinates[0][1]===Kt.coordinates[Kt.coordinates.length-1][1]?Yt={type:"Polygon",coordinates:[Kt.coordinates]}:console.warn("Cannot convert polyline to "+yt.type)),ct({type:"FeatureCollection",features:[{type:"Feature",geometry:Yt,properties:yt.properties||{}}]})}catch(Kt){Bt(Kt)}})}}var Sr=null;try{var xr=typeof md<"u"&&typeof md.require=="function"&&gd("worker_threads")||typeof __non_webpack_require__=="function"&&__non_webpack_require__("worker_threads")||typeof gd=="function"&&gd("worker_threads");Sr=xr.Worker}catch{}function Wo(pt,yt,ct){var Bt=yt===void 0?null:yt,Kt=function(Be,_e){return Buffer.from(Be,"base64").toString(_e?"utf16":"utf8")}(pt,ct!==void 0&&ct),Yt=Kt.indexOf(` -`,10)+1,ae=Kt.substring(Yt)+(Bt?"//# sourceMappingURL="+Bt:"");return function(Be){return new Sr(ae,Object.assign({},Be,{eval:!0}))}}function an(pt,yt,ct){var Bt=yt===void 0?null:yt,Kt=function(_e,Ce){var se=atob(_e);if(Ce){for(var ye=new Uint8Array(se.length),be=0,Ge=se.length;beMath.random().toString(36).substring(2);class Nr{constructor(yt,ct){this.initId=Fr()+"-"+yt,this.worker=new zo,this.handlers=new Map,this.worker.onmessage=Bt=>{let Kt=Bt.data,Yt=this.handlers.get(Kt.id),ae=this;if(Yt){if(Kt.type==="response"&&Yt.resolve(Kt.message),Kt.type==="error"){let Be=Kt.error||new Error(`Unknown error with ${yt}`);Yt.reject(Be)}Kt.type==="init_response"&&(this._=Object.keys(Kt.message).map(Be=>{let _e=typeof Kt.message[Be]=="function";return[Be,function(){return _e?ae.exec(Be)(...arguments):ae.get(Be)}]}).reduce((Be,_e)=>({...Be,[_e[0]]:_e[1]}),{}),Yt.resolve(this._))}},this.worker.postMessage({type:"init",id:this.initId,command:yt,message:ct})}onLoad(){return new Promise(yt=>{this._===void 0?this.handlers.set(this.initId,{resolve:yt,reject:yt}):yt(this._)})}exec(yt){let ct=this;return function(...Bt){return new Promise((Kt,Yt)=>{let ae=Fr()+"-"+yt;ct.handlers.set(ae,{resolve:Kt,reject:Yt}),ct.worker.postMessage({type:"exec",id:ae,command:yt,message:[...Bt]})})}}get(yt){return new Promise((ct,Bt)=>{let Kt=Fr()+"-"+yt;this.handlers.set(Kt,{resolve:ct,reject:Bt}),this.worker.postMessage({type:"get",id:Kt,command:yt,message:[]})})}}let Gs=new URL("test://http://example.com").href!=="test://http://example.com";async function Kn(pt,yt,ct){let Bt=await fetch(pt,ct?{signal:ct.signal}:void 0),Kt={};try{let Yt=new URL(pt,window.location.href).hash,ae=decodeURIComponent(Yt.slice(1));Kt=JSON.parse(ae)}catch(Yt){console.warn("Error parsing or reading URL:",Yt)}if(Bt.status==200){let Yt=await Bt.text(),ae;return["kml","tcx","gpx"].indexOf(yt)>=0||!(()=>{let Be=!1;try{Be=typeof window.Worker=="function"}catch{Be=!1}return Be})()?ae=new vs(yt,Yt,Kt).convert():ae=new Nr("Converter",[yt,Yt,Kt]).exec("convert")(),await ae}throw new Error(`Data fetch error: ${Bt.statusText}`)}let to=(pt,yt)=>{let ct=new AbortController,Bt=pt.url.split("://")[0],Kt=pt.url.replace(new RegExp(`^${Bt}://`),""),Yt=Gs?(ae=>{let Be=new RegExp("^(https?)(//)");return ae.replace(Be,"$1:$2")})(Kt):Kt;return Yt&&Kn(Yt,Bt,ct).then(ae=>yt(null,ae)).catch(ae=>yt(ae)),{cancel:()=>{ct.abort()}}};r.VectorTextProtocol=to,r.addOptions=(pt,yt)=>{try{let ct=new URL(pt);return ct.hash=`#${encodeURIComponent(JSON.stringify(yt))}`,ct.toString()}catch(ct){return console.error("Error parsing or updating URL:",ct),pt}},r.addProtocols=pt=>{Mr.forEach(yt=>{pt.addProtocol(yt,to)})}})});var Ym=la((kK,cb)=>{cb.exports=w3;var v3=Object.prototype.hasOwnProperty;function w3(){for(var r={},t=0;t{(function(){var r=this,t={};typeof ub<"u"?hb.exports=t:r.fuzzy=t,t.simpleFilter=function(i,s){return s.filter(function(A){return t.test(i,A)})},t.test=function(i,s){return t.match(i,s)!==null},t.match=function(i,s,A){A=A||{};var o=0,g=[],d=s.length,C=0,v=0,x=A.pre||"",T=A.post||"",G=A.caseSensitive&&s||s.toLowerCase(),k;i=A.caseSensitive&&i||i.toLowerCase();for(var W=0;W{"use strict";var Mo=function(r){return this.component=r,this.items=[],this.active=r.options.noInitialSelection?-1:0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,r.el.parentNode.insertBefore(this.wrapper,r.el.nextSibling),this};Mo.prototype.show=function(){this.element.style.display="block"};Mo.prototype.hide=function(){this.element.style.display="none"};Mo.prototype.add=function(r){this.items.push(r)};Mo.prototype.clear=function(){this.items=[],this.active=this.component.options.noInitialSelection?-1:0};Mo.prototype.isEmpty=function(){return!this.items.length};Mo.prototype.isVisible=function(){return this.element.style.display==="block"};Mo.prototype.draw=function(){if(this.element.innerHTML="",this.items.length===0){this.hide();return}for(var r=0;r=this.items.length-1?0:this.active+1)};Mo.prototype.drawError=function(r){var t=document.createElement("li");t.innerHTML=r,this.element.appendChild(t),this.show()};db.exports=Mo});var mb=la((EK,fb)=>{"use strict";var B3=Ym(),_3=gb(),x3=pb(),zs=function(r,t,i){return i=i||{},this.options=B3({minLength:2,limit:5,filter:!0,hideOnBlur:!0,noInitialSelection:!0},i),this.el=r,this.data=t||[],this.list=new x3(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(s){this.handleKeyUp(s.keyCode,s)}.bind(this),!1),this.el.addEventListener("keydown",function(s){this.handleKeyDown(s)}.bind(this)),this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this)),this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this)),this.el.addEventListener("paste",function(s){this.handlePaste(s)}.bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};zs.prototype.handleKeyUp=function(r,t){if(!(r===40||r===38||r===27||r===9)){if(r===13){this.list.items[this.list.active]&&(this.list.handleMouseUp(this.list.items[this.list.active]),t.stopPropagation());return}this.handleInputChange(this.el.value)}};zs.prototype.handleKeyDown=function(r){switch(r.keyCode){case 13:this.list.active>=0&&(this.list.selectingListItem=!0);break;case 9:this.list.isEmpty()||(this.list.isVisible()&&r.preventDefault(),this.value(this.list.active>=0?this.list.items[this.list.active].original:null),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next();break}};zs.prototype.handleBlur=function(){!this.list.selectingListItem&&this.options.hideOnBlur&&this.list.hide()};zs.prototype.handlePaste=function(r){if(r.clipboardData)this.handleInputChange(r.clipboardData.getData("Text"));else{var t=this;setTimeout(function(){t.handleInputChange(r.target.value)},100)}};zs.prototype.handleInputChange=function(r){if(this.query=this.normalize(r),this.list.clear(),this.query.length-1};zs.prototype.value=function(r){if(this.selected=r,this.el.value=this.getItemValue(r||{place_name:this.query}),document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")};zs.prototype.getCandidates=function(r){var t={pre:"",post:"",extract:function(s){return this.getItemValue(s)}.bind(this)},i;this.options.filter?(i=_3.filter(this.query,this.data,t),i=i.map(function(s){return{original:s.original,string:this.render(s.original,s.string)}}.bind(this))):i=this.data.map(function(s){var A=this.render(s);return{original:s,string:A}}.bind(this)),r(i)};zs.prototype.getItemValue=function(r){return r};zs.prototype.render=function(r,t){if(t)return t;for(var i=r.original?this.getItemValue(r.original):this.getItemValue(r),s=this.normalize(i),A=s.lastIndexOf(this.query);A>-1;){var o=A+this.query.length;i=i.slice(0,A)+""+i.slice(A,o)+""+i.slice(o),A=s.slice(0,A).lastIndexOf(this.query)}return i};zs.prototype.renderError=function(r){this.list.drawError(r)};fb.exports=zs});var yb=la((TK,Ib)=>{"use strict";var Cb=mb();Ib.exports=Cb;typeof window<"u"&&(window.Suggestions=Cb)});var Bb=la((QK,wb)=>{var S3="Expected a function",bb=NaN,F3="[object Symbol]",k3=/^\s+|\s+$/g,L3=/^[-+]0x[0-9a-f]+$/i,E3=/^0b[01]+$/i,T3=/^0o[0-7]+$/i,Q3=parseInt,U3=typeof global=="object"&&global&&global.Object===Object&&global,G3=typeof self=="object"&&self&&self.Object===Object&&self,R3=U3||G3||Function("return this")(),H3=Object.prototype,Z3=H3.toString,P3=Math.max,M3=Math.min,jm=function(){return R3.Date.now()};function N3(r,t,i){var s,A,o,g,d,C,v=0,x=!1,T=!1,G=!0;if(typeof r!="function")throw new TypeError(S3);t=vb(t)||0,qm(i)&&(x=!!i.leading,T="maxWait"in i,o=T?P3(vb(i.maxWait)||0,t):o,G="trailing"in i?!!i.trailing:G);function k(Qt){var Ft=s,vt=A;return s=A=void 0,v=Qt,g=r.apply(vt,Ft),g}function W(Qt){return v=Qt,d=setTimeout(O,t),x?k(Qt):g}function K(Qt){var Ft=Qt-C,vt=Qt-v,Jt=t-Ft;return T?M3(Jt,o-vt):Jt}function $(Qt){var Ft=Qt-C,vt=Qt-v;return C===void 0||Ft>=t||Ft<0||T&&vt>=o}function O(){var Qt=jm();if($(Qt))return tt(Qt);d=setTimeout(O,K(Qt))}function tt(Qt){return d=void 0,G&&s?k(Qt):(s=A=void 0,g)}function at(){d!==void 0&&clearTimeout(d),v=0,s=C=A=d=void 0}function Lt(){return d===void 0?g:tt(jm())}function Tt(){var Qt=jm(),Ft=$(Qt);if(s=arguments,A=this,C=Qt,Ft){if(d===void 0)return W(C);if(T)return d=setTimeout(O,t),k(C)}return d===void 0&&(d=setTimeout(O,t)),g}return Tt.cancel=at,Tt.flush=Lt,Tt}function qm(r){var t=typeof r;return!!r&&(t=="object"||t=="function")}function V3(r){return!!r&&typeof r=="object"}function D3(r){return typeof r=="symbol"||V3(r)&&Z3.call(r)==F3}function vb(r){if(typeof r=="number")return r;if(D3(r))return bb;if(qm(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=qm(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=r.replace(k3,"");var i=E3.test(r);return i||T3.test(r)?Q3(r.slice(2),i?2:8):L3.test(r)?bb:+r}wb.exports=N3});var Gb=la((UK,$m)=>{"use strict";var Bu=typeof Reflect=="object"?Reflect:null,_b=Bu&&typeof Bu.apply=="function"?Bu.apply:function(t,i,s){return Function.prototype.apply.call(t,i,s)},Cd;Bu&&typeof Bu.ownKeys=="function"?Cd=Bu.ownKeys:Object.getOwnPropertySymbols?Cd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Cd=function(t){return Object.getOwnPropertyNames(t)};function K3(r){console&&console.warn&&console.warn(r)}var Sb=Number.isNaN||function(t){return t!==t};function qr(){qr.init.call(this)}$m.exports=qr;$m.exports.once=J3;qr.EventEmitter=qr;qr.prototype._events=void 0;qr.prototype._eventsCount=0;qr.prototype._maxListeners=void 0;var xb=10;function Id(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(qr,"defaultMaxListeners",{enumerable:!0,get:function(){return xb},set:function(r){if(typeof r!="number"||r<0||Sb(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");xb=r}});qr.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};qr.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Sb(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Fb(r){return r._maxListeners===void 0?qr.defaultMaxListeners:r._maxListeners}qr.prototype.getMaxListeners=function(){return Fb(this)};qr.prototype.emit=function(t){for(var i=[],s=1;s0&&(g=i[0]),g instanceof Error)throw g;var d=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw d.context=g,d}var C=o[t];if(C===void 0)return!1;if(typeof C=="function")_b(C,this,i);else for(var v=C.length,x=Qb(C,v),s=0;s0&&g.length>A&&!g.warned){g.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=r,d.type=t,d.count=g.length,K3(d)}return r}qr.prototype.addListener=function(t,i){return kb(this,t,i,!1)};qr.prototype.on=qr.prototype.addListener;qr.prototype.prependListener=function(t,i){return kb(this,t,i,!0)};function W3(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Lb(r,t,i){var s={fired:!1,wrapFn:void 0,target:r,type:t,listener:i},A=W3.bind(s);return A.listener=i,s.wrapFn=A,A}qr.prototype.once=function(t,i){return Id(i),this.on(t,Lb(this,t,i)),this};qr.prototype.prependOnceListener=function(t,i){return Id(i),this.prependListener(t,Lb(this,t,i)),this};qr.prototype.removeListener=function(t,i){var s,A,o,g,d;if(Id(i),A=this._events,A===void 0)return this;if(s=A[t],s===void 0)return this;if(s===i||s.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete A[t],A.removeListener&&this.emit("removeListener",t,s.listener||i));else if(typeof s!="function"){for(o=-1,g=s.length-1;g>=0;g--)if(s[g]===i||s[g].listener===i){d=s[g].listener,o=g;break}if(o<0)return this;o===0?s.shift():O3(s,o),s.length===1&&(A[t]=s[0]),A.removeListener!==void 0&&this.emit("removeListener",t,d||i)}return this};qr.prototype.off=qr.prototype.removeListener;qr.prototype.removeAllListeners=function(t){var i,s,A;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var o=Object.keys(s),g;for(A=0;A=0;A--)this.removeListener(t,i[A]);return this};function Eb(r,t,i){var s=r._events;if(s===void 0)return[];var A=s[t];return A===void 0?[]:typeof A=="function"?i?[A.listener||A]:[A]:i?z3(A):Qb(A,A.length)}qr.prototype.listeners=function(t){return Eb(this,t,!0)};qr.prototype.rawListeners=function(t){return Eb(this,t,!1)};qr.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):Tb.call(r,t)};qr.prototype.listenerCount=Tb;function Tb(r){var t=this._events;if(t!==void 0){var i=t[r];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}qr.prototype.eventNames=function(){return this._eventsCount>0?Cd(this._events):[]};function Qb(r,t){for(var i=new Array(t),s=0;s{Rb.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}});var Pb=la((RK,Zb)=>{"use strict";var Y3={de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"\u05DC\u05D7\u05E4\u05E9",ja:"\u30B5\u30FC\u30C1",lv:"Mekl\u0113t",pt:"Procurar",sr:"\u041F\u0440\u0435\u0442\u0440\u0430\u0433\u0430",zh:"\u641C\u7D22",cs:"Vyhled\xE1v\xE1n\xED",hu:"Keres\xE9s",ka:"\u10EB\u10D8\u10D4\u10D1\u10D0",nb:"S\xF8ke",sk:"Vyh\u013Ead\xE1vanie",th:"\u0E04\u0E49\u0E19\u0E2B\u0E32",fi:"Hae",is:"Leita",ko:"\uC218\uC0C9",pl:"Szukaj",sl:"Iskanje",fa:"\u062C\u0633\u062A\u062C\u0648",ru:"\u041F\u043E\u0438\u0441\u043A"};Zb.exports={placeholder:Y3}});var Nb=la((Mb,yd)=>{(function(r,t,i){typeof yd<"u"&&yd.exports?yd.exports=i():r[t]=i()})(Mb,"subtag",function(){var r="",t=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;function i(d){return d.match(t)||[]}function s(d){return i(d).filter(function(C,v){return C&&v})}function A(d){return d=i(d),{language:d[1]||r,extlang:d[2]||r,script:d[3]||r,region:d[4]||r}}function o(d,C,v){Object.defineProperty(d,C,{value:v,enumerable:!0})}function g(d,C,v){function x(T){return i(T)[d]||r}o(x,"pattern",C),o(A,v,x)}return g(1,/^[a-zA-Z]{2,3}$/,"language"),g(2,/^[a-zA-Z]{3}$/,"extlang"),g(3,/^[a-zA-Z]{4}$/,"script"),g(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),o(A,"split",s),A})});var Wb=la((HK,Kb)=>{"use strict";var j3=yb(),q3=Bb(),ca=Ym(),$3=Gb().EventEmitter,Vb=Hb(),tF=Pb(),eF=Nb();function Db(r,t){this._eventEmitter=new $3,this.options=ca({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null,this.geocoderApi=r}Db.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,showResultsWhileTyping:!1,minLength:2,reverseGeocode:!1,limit:5,enableEventLogging:!0,marker:!0,popup:!1,maplibregl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(r){return r.text!==void 0?r.text:r.place_name},render:function(r){if(r.geometry){var d=r.place_name.split(",");return'

'+d[0]+'
'+d.splice(1,d.length).join(",")+"
"}else{var t=r.text,i=t.toLowerCase().indexOf(this.query.toLowerCase()),s=this.query.length,A=t.substring(0,i),o=t.substring(i,i+s),g=t.substring(i+s);return'
'+A+''+o+""+g+"
"}},popupRender:function(r){var t=r.place_name.split(",");return'"},showResultMarkers:!0,debounceSearch:200},addTo:function(r){function t(s,A){if(!document.body.contains(A))throw new Error("Element provided to #addTo() exists, but is not in the DOM");var o=s.onAdd();A.appendChild(o)}if(r._controlContainer)r.addControl(this);else if(r instanceof HTMLElement)t(this,r);else if(typeof r=="string"){var i=document.querySelectorAll(r);if(i.length===0)throw new Error("Element ",r,"not found.");if(i.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,i[0])}else throw new Error("Error: addTo must be a maplibre-gl-js map, an html element, or a CSS selector query for a single html element")},onAdd:function(r){if(r&&typeof r!="string"&&(this._map=r),this.setLanguage(),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl maplibregl-ctrl-geocoder maplibregl-ctrl";var i=this.createIcon("search",'');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input maplibregl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",q3(this._onKeyDown,this.options.debounceSearch)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton);var s=document.createElement("div");s.classList.add("mapboxgl-ctrl-geocoder--pin-right","maplibregl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button maplibregl-ctrl-geocoder--button";var A=this.createIcon("close",'');return this._clearEl.appendChild(A),this._loadingEl=this.createIcon("loading",''),s.appendChild(this._clearEl),s.appendChild(this._loadingEl),t.appendChild(i),t.appendChild(this._inputEl),t.appendChild(s),this._typeahead=new j3(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit,noInitialSelection:!0}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this.resultMarkers=[],this._handleMarker=this._handleMarker.bind(this),this._handleResultMarkers=this._handleResultMarkers.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._maplibregl=this.options.maplibregl,!this._maplibregl&&this.options.marker&&(console.error("No maplibregl detected in options. Map markers are disabled. Please set options.maplibregl."),this.options.marker=!1)),t},createIcon:function(r,t){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+r+" maplibregl-ctrl-geocoder--icon maplibregl-ctrl-geocoder--icon-"+r),i.setAttribute("viewBox","0 0 18 18"),i.setAttribute("xml:space","preserve"),i.setAttribute("width",18),i.setAttribute("height",18),"innerHTML"in i)i.innerHTML=t;else{var s=document.createElement("div");s.innerHTML=""+t.valueOf().toString()+"";var A=s.firstChild,o=A.firstChild;i.appendChild(o)}return i},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onPaste:function(r){var t=(r.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(t)},_onKeyDown:function(r){var t=27,i=9;if(r.keyCode===t&&this.options.clearAndBlurOnEsc)return this._clear(r),this._inputEl.blur();var s=r.target&&r.target.shadowRoot?r.target.shadowRoot.activeElement:r.target,A=s?s.value:"";if(!A)return this.fresh=!0,r.keyCode!==i&&this.clear(r),this._clearEl.style.display="none";if(!(r.metaKey||[i,t,37,39,38,40].indexOf(r.keyCode)!==-1)){if(r.keyCode===13)if(!this.options.showResultsWhileTyping)this._typeahead.selected||this._geocode(s.value);else{this._typeahead.selected==null&&this.geocoderApi.getSuggestions?this._geocode(s.value,!0):this._typeahead.selected==null&&this.options.showResultMarkers&&this._fitBoundsForMarkers();return}s.value.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(s.value)}},_showButton:function(){this._inputEl.value.length>0&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(r){this.options.clearOnBlur&&this._clearOnBlur(r),this.options.collapsed&&this._collapse()},_onChange:function(){var r=this._typeahead.selected;if(r&&!r.geometry)r.placeId?this._geocode(r.placeId,!0,!0):this._geocode(r.text,!0);else if(r&&JSON.stringify(r)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var t;if(this._removeResultMarkers(),r.properties&&Vb[r.properties.short_code])t=ca({},this.options.flyTo),this._map&&this._map.fitBounds(Vb[r.properties.short_code].bbox,t);else if(r.bbox){var i=r.bbox;t=ca({},this.options.flyTo),this._map&&this._map.fitBounds([[i[0],i[1]],[i[2],i[3]]],t)}else{var s={zoom:this.options.zoom};t=ca({},s,this.options.flyTo),r.center?t.center=r.center:r.geometry&&r.geometry.type&&r.geometry.type==="Point"&&r.geometry.coordinates&&(t.center=r.geometry.coordinates),this._map&&this._map.flyTo(t)}}this.options.marker&&this._maplibregl&&this._handleMarker(r),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(r),this._typeahead.selected=null,this._eventEmitter.emit("result",{result:r})}},_getConfigForRequest:function(){var r=["bbox","limit","proximity","countries","types","language","reverseMode"],t=this,i=r.reduce(function(s,A){return t.options[A]&&(["countries","types","language"].indexOf(A)>-1?s[A]=t.options[A].split(/[\s,]+/):s[A]=t.options[A],A==="proximity"&&t.options[A]&&typeof t.options[A].longitude=="number"&&typeof t.options[A].latitude=="number"&&(s[A]=[t.options[A].longitude,t.options[A].latitude])),s},{});return i},_geocode:function(r,t,i){this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:r}),this.inputString=r;var s=null,A=this._getConfigForRequest(),o;if(this.options.localGeocoderOnly)o=Promise.resolve();else if(this.options.reverseGeocode&&/(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(r)){var g=r.split(/[\s(,)?]+/).map(function(v){return parseFloat(v,10)}).reverse();A.types&&A.types[0],A=ca(A,{query:g,limit:1}),"proximity"in A&&delete A.proximity,o=this.geocoderApi.reverseGeocode(A)}else A=ca(A,{query:r}),this.geocoderApi.getSuggestions?t?this.geocoderApi.searchByPlaceId&&i?o=this.geocoderApi.searchByPlaceId(A):o=this.geocoderApi.forwardGeocode(A):o=this.geocoderApi.getSuggestions(A):o=this.geocoderApi.forwardGeocode(A);var d=[];this.options.localGeocoder&&(d=this.options.localGeocoder(r),d||(d=[]));var C=[];return o.catch(function(v){s=v}.bind(this)).then(function(v){this._loadingEl.style.display="none";var x={};return v?x=v:x={type:"FeatureCollection",features:[]},x.config=A,this.fresh&&(this.fresh=!1),x.features=x.features?d.concat(x.features):d,this.options.externalGeocoder?(C=this.options.externalGeocoder(r,x.features,A)||[],C.then(function(T){return x.features=x.features?T.concat(x.features):T,x},function(){return x})):x}.bind(this)).then(function(v){if(s)throw s;this.options.filter&&v.features.length&&(v.features=v.features.filter(this.options.filter));var x=[];v.suggestions?x=v.suggestions:v.place?x=[v.place]:x=v.features,x.length?(this._clearEl.style.display="block",this._typeahead.update(x),(!this.options.showResultsWhileTyping||t)&&this.options.showResultMarkers&&(v.features.length>0||v.place)&&this._fitBoundsForMarkers(),this._eventEmitter.emit("results",v)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",v))}.bind(this)).catch(function(v){this._loadingEl.style.display="none",d.length&&this.options.localGeocoder||C.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(d)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:d}),this._eventEmitter.emit("error",{error:v})}.bind(this)),o},_clear:function(r){r&&r.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this._removeResultMarkers(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(r){this._clear(r),this._inputEl.focus()},_clearOnBlur:function(r){var t=this;r.relatedTarget&&t._clear(r)},_onQueryResult:function(r){var t=r;if(!!t.features.length){var i=t.features[0];this._typeahead.selected=i,this._inputEl.value=i.place_name,this._onChange()}},_updateProximity:function(){if(!!this._map)if(this._map.getZoom()>9){var r=this._map.getCenter().wrap();this.setProximity({longitude:r.lng,latitude:r.lat})}else this.setProximity(null)},_collapse:function(){!this._inputEl.value&&this._inputEl!==document.activeElement&&this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed","maplibregl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed","maplibregl-ctrl-geocoder--collapsed")},query:function(r){return this._geocode(r).then(this._onQueryResult),this},_renderError:function(){var r="
There was an error reaching the server
";this._renderMessage(r)},_renderNoResults:function(){var r="
No results found
";this._renderMessage(r)},_renderMessage:function(r){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(r)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var r=this.options.language.split(",")[0],t=eF.language(r),i=tF.placeholder[t];if(i)return i}return"Search"},_fitBoundsForMarkers:function(){if(!(this._typeahead.data.length<1)){var r=this._typeahead.data.filter(function(A){return typeof A!="string"}).slice(0,this.options.limit);if(this._clearEl.style.display="none",this.options.flyTo&&this._maplibregl&&this._map){var t={padding:100},i=ca({},t,this.options.flyTo),s=new this._maplibregl.LngLatBounds;r.forEach(function(A){s.extend(A.geometry.coordinates)}),this._map.fitBounds(s.toArray(),i)}return r.length>0&&this._maplibregl&&this._handleResultMarkers(r),this}},setInput:function(r){return this._inputEl.value=r,this._typeahead.selected=null,this._typeahead.clear(),r.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(r),this},setProximity:function(r){return this.options.proximity=r,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(r){return r&&typeof r=="function"&&(this._typeahead.render=r),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(r){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=r||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(r){return this.options.zoom=r,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(r){return this.options.flyTo=r,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(r){return this.placeholder=r||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(r){return this.options.bbox=r,this},getCountries:function(){return this.options.countries},setCountries:function(r){return this.options.countries=r,this},getTypes:function(){return this.options.types},setTypes:function(r){return this.options.types=r,this},getMinLength:function(){return this.options.minLength},setMinLength:function(r){return this.options.minLength=r,this._typeahead&&(this._typeahead.options.minLength=r),this},getLimit:function(){return this.options.limit},setLimit:function(r){return this.options.limit=r,this._typeahead&&(this._typeahead.options.limit=r),this},getFilter:function(){return this.options.filter},setFilter:function(r){return this.options.filter=r,this},setGeocoderApi:function(r){return this.geocoderApi=r,this},getGeocoderApi:function(){return this.geocoderApi},_handleMarker:function(r){if(!!this._map){this._removeMarker();var t={color:"#4668F2"},i=ca({},t,this.options.marker);this.mapMarker=new this._maplibregl.Marker(i);var s;if(this.options.popup){var A={},o=ca({},A,this.options.popup);s=new this._maplibregl.Popup(o).setHTML(this.options.popupRender(r))}return r.center?(this.mapMarker.setLngLat(r.center).addTo(this._map),this.options.popup&&this.mapMarker.setPopup(s)):r.geometry&&r.geometry.type&&r.geometry.type==="Point"&&r.geometry.coordinates&&(this.mapMarker.setLngLat(r.geometry.coordinates).addTo(this._map),this.options.popup&&this.mapMarker.setPopup(s)),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},_handleResultMarkers:function(r){if(!!this._map){this._removeResultMarkers();var t={color:"#4668F2"},i=ca({},t,this.options.showResultMarkers);return r.forEach(function(s){if(this.options.showResultMarkers&&this.options.showResultMarkers.element){var A=this.options.showResultMarkers.element.cloneNode(!0);i=ca(i,{element:A})}var o=new this._maplibregl.Marker(ca({},i,{element:A})),g;if(this.options.popup){var d={},C=ca({},d,this.options.popup);g=new this._maplibregl.Popup(C).setHTML(this.options.popupRender(s))}s.center?(o.setLngLat(s.center).addTo(this._map),this.options.popup&&o.setPopup(g)):s.geometry&&s.geometry.type&&s.geometry.type==="Point"&&s.geometry.coordinates&&(o.setLngLat(s.geometry.coordinates).addTo(this._map),this.options.popup&&o.setPopup(g)),this.resultMarkers.push(o)}.bind(this)),this}},_removeResultMarkers:function(){this.resultMarkers&&this.resultMarkers.length>0&&(this.resultMarkers.forEach(function(r){r.remove()}),this.resultMarkers=[])},on:function(r,t){return this._eventEmitter.on(r,t),this},off:function(r,t){return this._eventEmitter.removeListener(r,t),this}};Kb.exports=Db});var X2={};Om(X2,{default:()=>BT});function $a(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");yC(r,t);function i(){this.constructor=r}r.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function Co(r,t,i,s){function A(o){return o instanceof i?o:new i(function(g){g(o)})}return new(i||(i=Promise))(function(o,g){function d(x){try{v(s.next(x))}catch(T){g(T)}}function C(x){try{v(s.throw(x))}catch(T){g(T)}}function v(x){x.done?o(x.value):A(x.value).then(d,C)}v((s=s.apply(r,t||[])).next())})}function Js(r,t){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,A,o,g;return g={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function d(v){return function(x){return C([v,x])}}function C(v){if(s)throw new TypeError("Generator is already executing.");for(;i;)try{if(s=1,A&&(o=v[0]&2?A.return:v[0]?A.throw||((o=A.return)&&o.call(A),0):A.next)&&!(o=o.call(A,v[1])).done)return o;switch(A=0,o&&(v=[v[0]&2,o.value]),v[0]){case 0:case 1:o=v;break;case 4:return i.label++,{value:v[1],done:!1};case 5:i.label++,A=v[1],v=[0];continue;case 7:v=i.ops.pop(),i.trys.pop();continue;default:if(o=i.trys,!(o=o.length>0&&o[o.length-1])&&(v[0]===6||v[0]===2)){i=0;continue}if(v[0]===3&&(!o||v[1]>o[0]&&v[1]=1&&(i-=1),i<1/6?(t-r)*i*6+r:i<1/2?t:i<2/3?(t-r)*6*(2/3-i)+r:r}function ik(r){return!(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319&&i>10)+55296,g%1024+56320)),(A+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Ob="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rF=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Zh=0;Zh"u"?[]:new Uint8Array(256);for(Ph=0;Ph>4,x[A++]=(g&15)<<4|d>>2,x[A++]=(d&3)<<6|C&63;return v},sF=function(r){for(var t=r.length,i=[],s=0;s>Hc,AF=1<>Hc,cF=Ov+lF,uF=cF,hF=32,gF=uF+hF,dF=65536>>DC,pF=1<=0){if(t<55296||t>56319&&t<=65535)return i=this.index[t>>Hc],i=(i<>Hc)],i=(i<>DC),i=this.index[i],i+=t>>Hc&fF,i=this.index[i],i=(i<"u"?[]:new Uint8Array(256);for(Mh=0;MhYb?(A.push(!0),d-=Yb):A.push(!1),["normal","auto","loose"].indexOf(t)!==-1&&[8208,8211,12316,12448].indexOf(o)!==-1)return s.push(g),i.push(BC);if(d===wF||d===vC){if(g===0)return s.push(g),i.push(Qu);var C=i[g-1];return EF.indexOf(C)===-1?(s.push(s[g-1]),i.push(C)):(s.push(g),i.push(Qu))}if(s.push(g),d===FF)return i.push(t==="strict"?_C:sg);if(d===Yv||d===SF)return i.push(Qu);if(d===kF)return o>=131072&&o<=196605||o>=196608&&o<=262141?i.push(sg):i.push(Qu);i.push(d)}),[s,i,A]},nC=function(r,t,i,s){var A=s[i];if(Array.isArray(r)?r.indexOf(A)!==-1:r===A)for(var o=i;o<=s.length;){o++;var g=s[o];if(g===t)return!0;if(g!==ic)break}if(A===ic)for(var o=i;o>0;){o--;var d=s[o];if(Array.isArray(r)?r.indexOf(d)!==-1:r===d)for(var C=i;C<=s.length;){C++;var g=s[C];if(g===t)return!0;if(g!==ic)break}if(d!==ic)break}return!1},rv=function(r,t){for(var i=r;i>=0;){var s=t[i];if(s===ic)i--;else return s}return 0},UF=function(r,t,i,s,A){if(i[s]===0)return mo;var o=s-1;if(Array.isArray(A)&&A[o]===!0)return mo;var g=o-1,d=o+1,C=t[o],v=g>=0?t[g]:0,x=t[d];if(C===zv&&x===Jv)return mo;if(EC.indexOf(C)!==-1)return jv;if(EC.indexOf(x)!==-1||qv.indexOf(x)!==-1)return mo;if(rv(o,t)===Xv)return _d;if(LC.get(r[o])===vC||(C===wd||C===Bd)&&LC.get(r[d])===vC||C===jb||x===jb||C===qb||[ic,wC,Jh].indexOf(C)===-1&&x===qb||[vd,Nh,xF,_u,xu].indexOf(x)!==-1||rv(o,t)===Vh||nC(iC,Vh,o,t)||nC([vd,Nh],_C,o,t)||nC($b,$b,o,t))return mo;if(C===ic)return _d;if(C===iC||x===iC)return mo;if(x===BC||C===BC)return _d;if([wC,Jh,_C].indexOf(x)!==-1||C===_F||v===FC&&TF.indexOf(C)!==-1||C===xu&&x===FC||x===tv||Il.indexOf(x)!==-1&&C===ua||Il.indexOf(C)!==-1&&x===ua||C===Yh&&[sg,wd,Bd].indexOf(x)!==-1||[sg,wd,Bd].indexOf(C)!==-1&&x===Xh||Il.indexOf(C)!==-1&&ev.indexOf(x)!==-1||ev.indexOf(C)!==-1&&Il.indexOf(x)!==-1||[Yh,Xh].indexOf(C)!==-1&&(x===ua||[Vh,Jh].indexOf(x)!==-1&&t[d+1]===ua)||[Vh,Jh].indexOf(C)!==-1&&x===ua||C===ua&&[ua,xu,_u].indexOf(x)!==-1)return mo;if([ua,xu,_u,vd,Nh].indexOf(x)!==-1)for(var T=o;T>=0;){var G=t[T];if(G===ua)return mo;if([xu,_u].indexOf(G)!==-1)T--;else break}if([Yh,Xh].indexOf(x)!==-1)for(var T=[vd,Nh].indexOf(C)!==-1?g:o;T>=0;){var G=t[T];if(G===ua)return mo;if([xu,_u].indexOf(G)!==-1)T--;else break}if(kC===C&&[kC,Pd,xC,SC].indexOf(x)!==-1||[Pd,xC].indexOf(C)!==-1&&[Pd,Md].indexOf(x)!==-1||[Md,SC].indexOf(C)!==-1&&x===Md||iv.indexOf(C)!==-1&&[tv,Xh].indexOf(x)!==-1||iv.indexOf(x)!==-1&&C===Yh||Il.indexOf(C)!==-1&&Il.indexOf(x)!==-1||C===_u&&Il.indexOf(x)!==-1||Il.concat(ua).indexOf(C)!==-1&&x===Vh&&LF.indexOf(r[d])===-1||Il.concat(ua).indexOf(x)!==-1&&C===Nh)return mo;if(C===rC&&x===rC){for(var k=i[o],W=1;k>0&&(k--,t[k]===rC);)W++;if(W%2!==0)return mo}return C===wd&&x===Bd?mo:_d},GF=function(r,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=QF(r,t.lineBreak),s=i[0],A=i[1],o=i[2];(t.wordBreak==="break-all"||t.wordBreak==="break-word")&&(A=A.map(function(d){return[ua,Qu,Yv].indexOf(d)!==-1?sg:d}));var g=t.wordBreak==="keep-all"?o.map(function(d,C){return d&&r[C]>=19968&&r[C]<=40959}):void 0;return[s,A,g]},RF=function(){function r(t,i,s,A){this.codePoints=t,this.required=i===jv,this.start=s,this.end=A}return r.prototype.slice=function(){return Gn.apply(void 0,this.codePoints.slice(this.start,this.end))},r}(),HF=function(r,t){var i=tp(r),s=GF(i,t),A=s[0],o=s[1],g=s[2],d=i.length,C=0,v=0;return{next:function(){if(v>=d)return{done:!0,value:null};for(var x=mo;v=$v&&r<=57},m4=function(r){return r>=55296&&r<=57343},Su=function(r){return Io(r)||r>=i2&&r<=n2||r>=t2&&r<=h4},C4=function(r){return r>=t2&&r<=d4},I4=function(r){return r>=i2&&r<=f4},y4=function(r){return C4(r)||I4(r)},b4=function(r){return r>=i4},Ld=function(r){return r===Dd||r===MF||r===NF},Kd=function(r){return y4(r)||b4(r)||r===WF},Av=function(r){return Kd(r)||Io(r)||r===No},v4=function(r){return r>=o4&&r<=a4||r===A4||r>=l4&&r<=c4||r===u4},ec=function(r,t){return r!==tg?!1:t!==Dd},Ed=function(r,t,i){return r===No?Kd(t)||ec(t,i):Kd(r)?!0:!!(r===tg&&ec(r,t))},oC=function(r,t,i){return r===Gc||r===No?Io(t)?!0:t===og&&Io(i):Io(r===og?t:r)},w4=function(r){var t=0,i=1;(r[t]===Gc||r[t]===No)&&(r[t]===No&&(i=-1),t++);for(var s=[];Io(r[t]);)s.push(r[t++]);var A=s.length?parseInt(Gn.apply(void 0,s),10):0;r[t]===og&&t++;for(var o=[];Io(r[t]);)o.push(r[t++]);var g=o.length,d=g?parseInt(Gn.apply(void 0,o),10):0;(r[t]===r2||r[t]===e2)&&t++;var C=1;(r[t]===Gc||r[t]===No)&&(r[t]===No&&(C=-1),t++);for(var v=[];Io(r[t]);)v.push(r[t++]);var x=v.length?parseInt(Gn.apply(void 0,v),10):0;return i*(A+d*Math.pow(10,-g))*Math.pow(10,C*x)},B4={type:2},_4={type:3},x4={type:4},S4={type:13},F4={type:8},k4={type:21},L4={type:9},E4={type:10},T4={type:11},Q4={type:12},U4={type:14},Td={type:23},G4={type:1},R4={type:25},H4={type:24},Z4={type:26},P4={type:27},M4={type:28},N4={type:29},V4={type:31},TC={type:32},s2=function(){function r(){this._value=[]}return r.prototype.write=function(t){this._value=this._value.concat(tp(t))},r.prototype.read=function(){for(var t=[],i=this.consumeToken();i!==TC;)t.push(i),i=this.consumeToken();return t},r.prototype.consumeToken=function(){var t=this.consumeCodePoint();switch(t){case xd:return this.consumeStringToken(xd);case VF:var i=this.peekCodePoint(0),s=this.peekCodePoint(1),A=this.peekCodePoint(2);if(Av(i)||ec(s,A)){var o=Ed(i,s,A)?PF:ZF,g=this.consumeName();return{type:5,value:g,flags:o}}break;case DF:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),S4;break;case Sd:return this.consumeStringToken(Sd);case Fd:return B4;case Kh:return _4;case sC:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),U4;break;case Gc:if(oC(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case r4:return x4;case No:var d=t,C=this.peekCodePoint(0),v=this.peekCodePoint(1);if(oC(d,C,v))return this.reconsumeCodePoint(t),this.consumeNumericToken();if(Ed(d,C,v))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();if(C===No&&v===JF)return this.consumeCodePoint(),this.consumeCodePoint(),H4;break;case og:if(oC(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case sv:if(this.peekCodePoint(0)===sC)for(this.consumeCodePoint();;){var x=this.consumeCodePoint();if(x===sC&&(x=this.consumeCodePoint(),x===sv))return this.consumeToken();if(x===DA)return this.consumeToken()}break;case n4:return Z4;case s4:return P4;case zF:if(this.peekCodePoint(0)===OF&&this.peekCodePoint(1)===No&&this.peekCodePoint(2)===No)return this.consumeCodePoint(),this.consumeCodePoint(),R4;break;case XF:var T=this.peekCodePoint(0),G=this.peekCodePoint(1),k=this.peekCodePoint(2);if(Ed(T,G,k)){var g=this.consumeName();return{type:7,value:g}}break;case YF:return M4;case tg:if(ec(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();break;case jF:return N4;case qF:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),F4;break;case $F:return T4;case t4:return Q4;case g4:case p4:var W=this.peekCodePoint(0),K=this.peekCodePoint(1);return W===Gc&&(Su(K)||K===kd)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(t),this.consumeIdentLikeToken();case ov:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),L4;if(this.peekCodePoint(0)===ov)return this.consumeCodePoint(),k4;break;case e4:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),E4;break;case DA:return TC}return Ld(t)?(this.consumeWhiteSpace(),V4):Io(t)?(this.reconsumeCodePoint(t),this.consumeNumericToken()):Kd(t)?(this.reconsumeCodePoint(t),this.consumeIdentLikeToken()):{type:6,value:Gn(t)}},r.prototype.consumeCodePoint=function(){var t=this._value.shift();return typeof t>"u"?-1:t},r.prototype.reconsumeCodePoint=function(t){this._value.unshift(t)},r.prototype.peekCodePoint=function(t){return t>=this._value.length?-1:this._value[t]},r.prototype.consumeUnicodeRangeToken=function(){for(var t=[],i=this.consumeCodePoint();Su(i)&&t.length<6;)t.push(i),i=this.consumeCodePoint();for(var s=!1;i===kd&&t.length<6;)t.push(i),i=this.consumeCodePoint(),s=!0;if(s){var A=parseInt(Gn.apply(void 0,t.map(function(C){return C===kd?$v:C})),16),o=parseInt(Gn.apply(void 0,t.map(function(C){return C===kd?n2:C})),16);return{type:30,start:A,end:o}}var g=parseInt(Gn.apply(void 0,t),16);if(this.peekCodePoint(0)===No&&Su(this.peekCodePoint(1))){this.consumeCodePoint(),i=this.consumeCodePoint();for(var d=[];Su(i)&&d.length<6;)d.push(i),i=this.consumeCodePoint();var o=parseInt(Gn.apply(void 0,d),16);return{type:30,start:g,end:o}}else return{type:30,start:g,end:g}},r.prototype.consumeIdentLikeToken=function(){var t=this.consumeName();return t.toLowerCase()==="url"&&this.peekCodePoint(0)===Fd?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Fd?(this.consumeCodePoint(),{type:19,value:t}):{type:20,value:t}},r.prototype.consumeUrlToken=function(){var t=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===DA)return{type:22,value:""};var i=this.peekCodePoint(0);if(i===Sd||i===xd){var s=this.consumeStringToken(this.consumeCodePoint());return s.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===DA||this.peekCodePoint(0)===Kh)?(this.consumeCodePoint(),{type:22,value:s.value}):(this.consumeBadUrlRemnants(),Td)}for(;;){var A=this.consumeCodePoint();if(A===DA||A===Kh)return{type:22,value:Gn.apply(void 0,t)};if(Ld(A))return this.consumeWhiteSpace(),this.peekCodePoint(0)===DA||this.peekCodePoint(0)===Kh?(this.consumeCodePoint(),{type:22,value:Gn.apply(void 0,t)}):(this.consumeBadUrlRemnants(),Td);if(A===xd||A===Sd||A===Fd||v4(A))return this.consumeBadUrlRemnants(),Td;if(A===tg)if(ec(A,this.peekCodePoint(0)))t.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Td;else t.push(A)}},r.prototype.consumeWhiteSpace=function(){for(;Ld(this.peekCodePoint(0));)this.consumeCodePoint()},r.prototype.consumeBadUrlRemnants=function(){for(;;){var t=this.consumeCodePoint();if(t===Kh||t===DA)return;ec(t,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},r.prototype.consumeStringSlice=function(t){for(var i=5e4,s="";t>0;){var A=Math.min(i,t);s+=Gn.apply(void 0,this._value.splice(0,A)),t-=A}return this._value.shift(),s},r.prototype.consumeStringToken=function(t){var i="",s=0;do{var A=this._value[s];if(A===DA||A===void 0||A===t)return i+=this.consumeStringSlice(s),{type:0,value:i};if(A===Dd)return this._value.splice(0,s),G4;if(A===tg){var o=this._value[s+1];o!==DA&&o!==void 0&&(o===Dd?(i+=this.consumeStringSlice(s),s=-1,this._value.shift()):ec(A,o)&&(i+=this.consumeStringSlice(s),i+=Gn(this.consumeEscapedCodePoint()),s=-1))}s++}while(!0)},r.prototype.consumeNumber=function(){var t=[],i=Ag,s=this.peekCodePoint(0);for((s===Gc||s===No)&&t.push(this.consumeCodePoint());Io(this.peekCodePoint(0));)t.push(this.consumeCodePoint());s=this.peekCodePoint(0);var A=this.peekCodePoint(1);if(s===og&&Io(A))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),i=nv;Io(this.peekCodePoint(0));)t.push(this.consumeCodePoint());s=this.peekCodePoint(0),A=this.peekCodePoint(1);var o=this.peekCodePoint(2);if((s===r2||s===e2)&&((A===Gc||A===No)&&Io(o)||Io(A)))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),i=nv;Io(this.peekCodePoint(0));)t.push(this.consumeCodePoint());return[w4(t),i]},r.prototype.consumeNumericToken=function(){var t=this.consumeNumber(),i=t[0],s=t[1],A=this.peekCodePoint(0),o=this.peekCodePoint(1),g=this.peekCodePoint(2);if(Ed(A,o,g)){var d=this.consumeName();return{type:15,number:i,flags:s,unit:d}}return A===KF?(this.consumeCodePoint(),{type:16,number:i,flags:s}):{type:17,number:i,flags:s}},r.prototype.consumeEscapedCodePoint=function(){var t=this.consumeCodePoint();if(Su(t)){for(var i=Gn(t);Su(this.peekCodePoint(0))&&i.length<6;)i+=Gn(this.consumeCodePoint());Ld(this.peekCodePoint(0))&&this.consumeCodePoint();var s=parseInt(i,16);return s===0||m4(s)||s>1114111?av:s}return t===DA?av:t},r.prototype.consumeName=function(){for(var t="";;){var i=this.consumeCodePoint();if(Av(i))t+=Gn(i);else if(ec(i,this.peekCodePoint(0)))t+=Gn(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(i),t}},r}(),o2=function(){function r(t){this._tokens=t}return r.create=function(t){var i=new s2;return i.write(t),new r(i.read())},r.parseValue=function(t){return r.create(t).parseComponentValue()},r.parseValues=function(t){return r.create(t).parseComponentValues()},r.prototype.parseComponentValue=function(){for(var t=this.consumeToken();t.type===31;)t=this.consumeToken();if(t.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(t);var i=this.consumeComponentValue();do t=this.consumeToken();while(t.type===31);if(t.type===32)return i;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},r.prototype.parseComponentValues=function(){for(var t=[];;){var i=this.consumeComponentValue();if(i.type===32)return t;t.push(i),t.push()}},r.prototype.consumeComponentValue=function(){var t=this.consumeToken();switch(t.type){case 11:case 28:case 2:return this.consumeSimpleBlock(t.type);case 19:return this.consumeFunction(t)}return t},r.prototype.consumeSimpleBlock=function(t){for(var i={type:t,values:[]},s=this.consumeToken();;){if(s.type===32||K4(s,t))return i;this.reconsumeToken(s),i.values.push(this.consumeComponentValue()),s=this.consumeToken()}},r.prototype.consumeFunction=function(t){for(var i={name:t.value,values:[],type:18};;){var s=this.consumeToken();if(s.type===32||s.type===3)return i;this.reconsumeToken(s),i.values.push(this.consumeComponentValue())}},r.prototype.consumeToken=function(){var t=this._tokens.shift();return typeof t>"u"?TC:t},r.prototype.reconsumeToken=function(t){this._tokens.unshift(t)},r}(),lg=function(r){return r.type===15},Hu=function(r){return r.type===17},$r=function(r){return r.type===20},D4=function(r){return r.type===0},QC=function(r,t){return $r(r)&&r.value===t},a2=function(r){return r.type!==31},Ru=function(r){return r.type!==31&&r.type!==4},KA=function(r){var t=[],i=[];return r.forEach(function(s){if(s.type===4){if(i.length===0)throw new Error("Error parsing function args, zero tokens for arg");t.push(i),i=[];return}s.type!==31&&i.push(s)}),i.length&&t.push(i),t},K4=function(r,t){return t===11&&r.type===12||t===28&&r.type===29?!0:t===2&&r.type===3},ac=function(r){return r.type===17||r.type===15},Xn=function(r){return r.type===16||ac(r)},A2=function(r){return r.length>1?[r[0],r[1]]:[r[0]]},Qs={type:17,number:0,flags:Ag},KC={type:16,number:50,flags:Ag},rc={type:16,number:100,flags:Ag},jh=function(r,t,i){var s=r[0],A=r[1];return[ln(s,t),ln(typeof A<"u"?A:s,i)]},ln=function(r,t){if(r.type===16)return r.number/100*t;if(lg(r))switch(r.unit){case"rem":case"em":return 16*r.number;case"px":default:return r.number}return r.number},l2="deg",c2="grad",u2="rad",h2="turn",ep={name:"angle",parse:function(r,t){if(t.type===15)switch(t.unit){case l2:return Math.PI*t.number/180;case c2:return Math.PI/200*t.number;case u2:return t.number;case h2:return Math.PI*2*t.number}throw new Error("Unsupported angle type")}},g2=function(r){return r.type===15&&(r.unit===l2||r.unit===c2||r.unit===u2||r.unit===h2)},d2=function(r){var t=r.filter($r).map(function(i){return i.value}).join(" ");switch(t){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Qs,Qs];case"to top":case"bottom":return Ba(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Qs,rc];case"to right":case"left":return Ba(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[rc,rc];case"to bottom":case"top":return Ba(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[rc,Qs];case"to left":case"right":return Ba(270)}return 0},Ba=function(r){return Math.PI*r/180},sc={name:"color",parse:function(r,t){if(t.type===18){var i=W4[t.name];if(typeof i>"u")throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(r,t.values)}if(t.type===5){if(t.value.length===3){var s=t.value.substring(0,1),A=t.value.substring(1,2),o=t.value.substring(2,3);return nc(parseInt(s+s,16),parseInt(A+A,16),parseInt(o+o,16),1)}if(t.value.length===4){var s=t.value.substring(0,1),A=t.value.substring(1,2),o=t.value.substring(2,3),g=t.value.substring(3,4);return nc(parseInt(s+s,16),parseInt(A+A,16),parseInt(o+o,16),parseInt(g+g,16)/255)}if(t.value.length===6){var s=t.value.substring(0,2),A=t.value.substring(2,4),o=t.value.substring(4,6);return nc(parseInt(s,16),parseInt(A,16),parseInt(o,16),1)}if(t.value.length===8){var s=t.value.substring(0,2),A=t.value.substring(2,4),o=t.value.substring(4,6),g=t.value.substring(6,8);return nc(parseInt(s,16),parseInt(A,16),parseInt(o,16),parseInt(g,16)/255)}}if(t.type===20){var d=bl[t.value.toUpperCase()];if(typeof d<"u")return d}return bl.TRANSPARENT}},oc=function(r){return(255&r)===0},ms=function(r){var t=255&r,i=255&r>>8,s=255&r>>16,A=255&r>>24;return t<255?"rgba("+A+","+s+","+i+","+t/255+")":"rgb("+A+","+s+","+i+")"},nc=function(r,t,i,s){return(r<<24|t<<16|i<<8|Math.round(s*255)<<0)>>>0},lv=function(r,t){if(r.type===17)return r.number;if(r.type===16){var i=t===3?1:255;return t===3?r.number/100*i:Math.round(r.number/100*i)}return 0},cv=function(r,t){var i=t.filter(Ru);if(i.length===3){var s=i.map(lv),A=s[0],o=s[1],g=s[2];return nc(A,o,g,1)}if(i.length===4){var d=i.map(lv),A=d[0],o=d[1],g=d[2],C=d[3];return nc(A,o,g,C)}return 0};uv=function(r,t){var i=t.filter(Ru),s=i[0],A=i[1],o=i[2],g=i[3],d=(s.type===17?Ba(s.number):ep.parse(r,s))/(Math.PI*2),C=Xn(A)?A.number/100:0,v=Xn(o)?o.number/100:0,x=typeof g<"u"&&Xn(g)?ln(g,1):1;if(C===0)return nc(v*255,v*255,v*255,1);var T=v<=.5?v*(C+1):v+C-v*C,G=v*2-T,k=aC(G,T,d+1/3),W=aC(G,T,d),K=aC(G,T,d-1/3);return nc(k*255,W*255,K*255,x)},W4={hsl:uv,hsla:uv,rgb:cv,rgba:cv},eg=function(r,t){return sc.parse(r,o2.create(t).parseComponentValue())},bl={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},O4={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(r,t){return t.map(function(i){if($r(i))switch(i.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},z4={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ip=function(r,t){var i=sc.parse(r,t[0]),s=t[1];return s&&Xn(s)?{color:i,stop:s}:{color:i,stop:null}},hv=function(r,t){var i=r[0],s=r[r.length-1];i.stop===null&&(i.stop=Qs),s.stop===null&&(s.stop=rc);for(var A=[],o=0,g=0;go?A.push(C):A.push(o),o=C}else A.push(null)}for(var v=null,g=0;gg.optimumDistance)?{optimumCorner:d,optimumDistance:x}:g},{optimumDistance:A?1/0:-1/0,optimumCorner:null}).optimumCorner},Y4=function(r,t,i,s,A){var o=0,g=0;switch(r.size){case 0:r.shape===0?o=g=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-A)):r.shape===1&&(o=Math.min(Math.abs(t),Math.abs(t-s)),g=Math.min(Math.abs(i),Math.abs(i-A)));break;case 2:if(r.shape===0)o=g=Math.min(qa(t,i),qa(t,i-A),qa(t-s,i),qa(t-s,i-A));else if(r.shape===1){var d=Math.min(Math.abs(i),Math.abs(i-A))/Math.min(Math.abs(t),Math.abs(t-s)),C=gv(s,A,t,i,!0),v=C[0],x=C[1];o=qa(v-t,(x-i)/d),g=d*o}break;case 1:r.shape===0?o=g=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-A)):r.shape===1&&(o=Math.max(Math.abs(t),Math.abs(t-s)),g=Math.max(Math.abs(i),Math.abs(i-A)));break;case 3:if(r.shape===0)o=g=Math.max(qa(t,i),qa(t,i-A),qa(t-s,i),qa(t-s,i-A));else if(r.shape===1){var d=Math.max(Math.abs(i),Math.abs(i-A))/Math.max(Math.abs(t),Math.abs(t-s)),T=gv(s,A,t,i,!1),v=T[0],x=T[1];o=qa(v-t,(x-i)/d),g=d*o}break}return Array.isArray(r.size)&&(o=ln(r.size[0],s),g=r.size.length===2?ln(r.size[1],A):o),[o,g]},j4=function(r,t){var i=Ba(180),s=[];return KA(t).forEach(function(A,o){if(o===0){var g=A[0];if(g.type===20&&g.value==="to"){i=d2(A);return}else if(g2(g)){i=ep.parse(r,g);return}}var d=ip(r,A);s.push(d)}),{angle:i,stops:s,type:1}},Qd=function(r,t){var i=Ba(180),s=[];return KA(t).forEach(function(A,o){if(o===0){var g=A[0];if(g.type===20&&["top","left","right","bottom"].indexOf(g.value)!==-1){i=d2(A);return}else if(g2(g)){i=(ep.parse(r,g)+Ba(270))%Ba(360);return}}var d=ip(r,A);s.push(d)}),{angle:i,stops:s,type:1}},q4=function(r,t){var i=Ba(180),s=[],A=1,o=0,g=3,d=[];return KA(t).forEach(function(C,v){var x=C[0];if(v===0){if($r(x)&&x.value==="linear"){A=1;return}else if($r(x)&&x.value==="radial"){A=2;return}}if(x.type===18){if(x.name==="from"){var T=sc.parse(r,x.values[0]);s.push({stop:Qs,color:T})}else if(x.name==="to"){var T=sc.parse(r,x.values[0]);s.push({stop:rc,color:T})}else if(x.name==="color-stop"){var G=x.values.filter(Ru);if(G.length===2){var T=sc.parse(r,G[1]),k=G[0];Hu(k)&&s.push({stop:{type:16,number:k.number*100,flags:k.flags},color:T})}}}}),A===1?{angle:(i+Ba(180))%Ba(360),stops:s,type:A}:{size:g,shape:o,stops:s,position:d,type:A}},p2="closest-side",f2="farthest-side",m2="closest-corner",C2="farthest-corner",I2="circle",y2="ellipse",b2="cover",v2="contain",$4=function(r,t){var i=0,s=3,A=[],o=[];return KA(t).forEach(function(g,d){var C=!0;if(d===0){var v=!1;C=g.reduce(function(T,G){if(v)if($r(G))switch(G.value){case"center":return o.push(KC),T;case"top":case"left":return o.push(Qs),T;case"right":case"bottom":return o.push(rc),T}else(Xn(G)||ac(G))&&o.push(G);else if($r(G))switch(G.value){case I2:return i=0,!1;case y2:return i=1,!1;case"at":return v=!0,!1;case p2:return s=0,!1;case b2:case f2:return s=1,!1;case v2:case m2:return s=2,!1;case C2:return s=3,!1}else if(ac(G)||Xn(G))return Array.isArray(s)||(s=[]),s.push(G),!1;return T},C)}if(C){var x=ip(r,g);A.push(x)}}),{size:s,shape:i,stops:A,position:o,type:2}},Ud=function(r,t){var i=0,s=3,A=[],o=[];return KA(t).forEach(function(g,d){var C=!0;if(d===0?C=g.reduce(function(x,T){if($r(T))switch(T.value){case"center":return o.push(KC),!1;case"top":case"left":return o.push(Qs),!1;case"right":case"bottom":return o.push(rc),!1}else if(Xn(T)||ac(T))return o.push(T),!1;return x},C):d===1&&(C=g.reduce(function(x,T){if($r(T))switch(T.value){case I2:return i=0,!1;case y2:return i=1,!1;case v2:case p2:return s=0,!1;case f2:return s=1,!1;case m2:return s=2,!1;case b2:case C2:return s=3,!1}else if(ac(T)||Xn(T))return Array.isArray(s)||(s=[]),s.push(T),!1;return x},C)),C){var v=ip(r,g);A.push(v)}}),{size:s,shape:i,stops:A,position:o,type:2}},tk=function(r){return r.type===1},ek=function(r){return r.type===2},WC={name:"image",parse:function(r,t){if(t.type===22){var i={url:t.value,type:0};return r.cache.addImage(t.value),i}if(t.type===18){var s=w2[t.name];if(typeof s>"u")throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(r,t.values)}throw new Error("Unsupported image type "+t.type)}};w2={"linear-gradient":j4,"-moz-linear-gradient":Qd,"-ms-linear-gradient":Qd,"-o-linear-gradient":Qd,"-webkit-linear-gradient":Qd,"radial-gradient":$4,"-moz-radial-gradient":Ud,"-ms-radial-gradient":Ud,"-o-radial-gradient":Ud,"-webkit-radial-gradient":Ud,"-webkit-gradient":q4},rk={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(r,t){if(t.length===0)return[];var i=t[0];return i.type===20&&i.value==="none"?[]:t.filter(function(s){return Ru(s)&&ik(s)}).map(function(s){return WC.parse(r,s)})}},nk={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(r,t){return t.map(function(i){if($r(i))switch(i.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},sk={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(r,t){return KA(t).map(function(i){return i.filter(Xn)}).map(A2)}},ok={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(r,t){return KA(t).map(function(i){return i.filter($r).map(function(s){return s.value}).join(" ")}).map(ak)}},ak=function(r){switch(r){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}};(function(r){r.AUTO="auto",r.CONTAIN="contain",r.COVER="cover"})(Gu||(Gu={}));Ak={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(r,t){return KA(t).map(function(i){return i.filter(lk)})}},lk=function(r){return $r(r)||Xn(r)},rp=function(r){return{name:"border-"+r+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},ck=rp("top"),uk=rp("right"),hk=rp("bottom"),gk=rp("left"),np=function(r){return{name:"border-radius-"+r,initialValue:"0 0",prefix:!1,type:1,parse:function(t,i){return A2(i.filter(Xn))}}},dk=np("top-left"),pk=np("top-right"),fk=np("bottom-right"),mk=np("bottom-left"),sp=function(r){return{name:"border-"+r+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(t,i){switch(i){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Ck=sp("top"),Ik=sp("right"),yk=sp("bottom"),bk=sp("left"),op=function(r){return{name:"border-"+r+"-width",initialValue:"0",type:0,prefix:!1,parse:function(t,i){return lg(i)?i.number:0}}},vk=op("top"),wk=op("right"),Bk=op("bottom"),_k=op("left"),xk={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Sk={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(r,t){switch(t){case"rtl":return 1;case"ltr":default:return 0}}},Fk={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(r,t){return t.filter($r).reduce(function(i,s){return i|kk(s.value)},0)}},kk=function(r){switch(r){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Lk={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Ek={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(r,t){return t.type===20&&t.value==="normal"?0:t.type===17||t.type===15?t.number:0}};(function(r){r.NORMAL="normal",r.STRICT="strict"})(Wd||(Wd={}));Tk={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"strict":return Wd.STRICT;case"normal":default:return Wd.NORMAL}}},Qk={name:"line-height",initialValue:"normal",prefix:!1,type:4},dv=function(r,t){return $r(r)&&r.value==="normal"?1.2*t:r.type===17?t*r.number:Xn(r)?ln(r,t):t},Uk={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(r,t){return t.type===20&&t.value==="none"?null:WC.parse(r,t)}},Gk={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(r,t){switch(t){case"inside":return 0;case"outside":default:return 1}}},UC={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},ap=function(r){return{name:"margin-"+r,initialValue:"0",prefix:!1,type:4}},Rk=ap("top"),Hk=ap("right"),Zk=ap("bottom"),Pk=ap("left"),Mk={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(r,t){return t.filter($r).map(function(i){switch(i.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},Nk={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"break-word":return"break-word";case"normal":default:return"normal"}}},Ap=function(r){return{name:"padding-"+r,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Vk=Ap("top"),Dk=Ap("right"),Kk=Ap("bottom"),Wk=Ap("left"),Ok={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(r,t){switch(t){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},zk={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(r,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Jk={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(r,t){return t.length===1&&QC(t[0],"none")?[]:KA(t).map(function(i){for(var s={color:bl.TRANSPARENT,offsetX:Qs,offsetY:Qs,blur:Qs},A=0,o=0;o"u")throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return i(t.values)}return null}},jk=function(r){var t=r.filter(function(i){return i.type===17}).map(function(i){return i.number});return t.length===6?t:null},qk=function(r){var t=r.filter(function(C){return C.type===17}).map(function(C){return C.number}),i=t[0],s=t[1];t[2],t[3];var A=t[4],o=t[5];t[6],t[7],t[8],t[9],t[10],t[11];var g=t[12],d=t[13];return t[14],t[15],t.length===16?[i,s,A,o,g,d]:null},$k={matrix:jk,matrix3d:qk},pv={type:16,number:50,flags:Ag},tL=[pv,pv],eL={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(r,t){var i=t.filter(Xn);return i.length!==2?tL:[i[0],i[1]]}},iL={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}};(function(r){r.NORMAL="normal",r.BREAK_ALL="break-all",r.KEEP_ALL="keep-all"})(ig||(ig={}));rL={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"break-all":return ig.BREAK_ALL;case"keep-all":return ig.KEEP_ALL;case"normal":default:return ig.NORMAL}}},nL={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(r,t){if(t.type===20)return{auto:!0,order:0};if(Hu(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},B2={name:"time",parse:function(r,t){if(t.type===15)switch(t.unit.toLowerCase()){case"s":return 1e3*t.number;case"ms":return t.number}throw new Error("Unsupported time type")}},sL={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(r,t){return Hu(t)?t.number:1}},oL={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},aL={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(r,t){return t.filter($r).map(function(i){switch(i.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(i){return i!==0})}},AL={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(r,t){var i=[],s=[];return t.forEach(function(A){switch(A.type){case 20:case 0:i.push(A.value);break;case 17:i.push(A.number.toString());break;case 4:s.push(i.join(" ")),i.length=0;break}}),i.length&&s.push(i.join(" ")),s.map(function(A){return A.indexOf(" ")===-1?A:"'"+A+"'"})}},lL={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},cL={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(r,t){if(Hu(t))return t.number;if($r(t))switch(t.value){case"bold":return 700;case"normal":default:return 400}return 400}},uL={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(r,t){return t.filter($r).map(function(i){return i.value})}},hL={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},as=function(r,t){return(r&t)!==0},gL={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(r,t){if(t.length===0)return[];var i=t[0];return i.type===20&&i.value==="none"?[]:t}},dL={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(r,t){if(t.length===0)return null;var i=t[0];if(i.type===20&&i.value==="none")return null;for(var s=[],A=t.filter(a2),o=0;o1?1:0],this.overflowWrap=_i(t,Nk,i.overflowWrap),this.paddingTop=_i(t,Vk,i.paddingTop),this.paddingRight=_i(t,Dk,i.paddingRight),this.paddingBottom=_i(t,Kk,i.paddingBottom),this.paddingLeft=_i(t,Wk,i.paddingLeft),this.paintOrder=_i(t,IL,i.paintOrder),this.position=_i(t,zk,i.position),this.textAlign=_i(t,Ok,i.textAlign),this.textDecorationColor=_i(t,oL,(s=i.textDecorationColor)!==null&&s!==void 0?s:i.color),this.textDecorationLine=_i(t,aL,(A=i.textDecorationLine)!==null&&A!==void 0?A:i.textDecoration),this.textShadow=_i(t,Jk,i.textShadow),this.textTransform=_i(t,Xk,i.textTransform),this.transform=_i(t,Yk,i.transform),this.transformOrigin=_i(t,eL,i.transformOrigin),this.visibility=_i(t,iL,i.visibility),this.webkitTextStrokeColor=_i(t,yL,i.webkitTextStrokeColor),this.webkitTextStrokeWidth=_i(t,bL,i.webkitTextStrokeWidth),this.wordBreak=_i(t,rL,i.wordBreak),this.zIndex=_i(t,nL,i.zIndex)}return r.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},r.prototype.isTransparent=function(){return oc(this.backgroundColor)},r.prototype.isTransformed=function(){return this.transform!==null},r.prototype.isPositioned=function(){return this.position!==0},r.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},r.prototype.isFloating=function(){return this.float!==0},r.prototype.isInlineLevel=function(){return as(this.display,4)||as(this.display,33554432)||as(this.display,268435456)||as(this.display,536870912)||as(this.display,67108864)||as(this.display,134217728)},r}(),wL=function(){function r(t,i){this.content=_i(t,gL,i.content),this.quotes=_i(t,mL,i.quotes)}return r}(),mv=function(){function r(t,i){this.counterIncrement=_i(t,dL,i.counterIncrement),this.counterReset=_i(t,pL,i.counterReset)}return r}(),_i=function(r,t,i){var s=new s2,A=i!==null&&typeof i<"u"?i.toString():t.initialValue;s.write(A);var o=new o2(s.read());switch(t.type){case 2:var g=o.parseComponentValue();return t.parse(r,$r(g)?g.value:t.initialValue);case 0:return t.parse(r,o.parseComponentValue());case 1:return t.parse(r,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return ep.parse(r,o.parseComponentValue());case"color":return sc.parse(r,o.parseComponentValue());case"image":return WC.parse(r,o.parseComponentValue());case"length":var d=o.parseComponentValue();return ac(d)?d:Qs;case"length-percentage":var C=o.parseComponentValue();return Xn(C)?C:Qs;case"time":return B2.parse(r,o.parseComponentValue())}break}},BL="data-html2canvas-debug",_L=function(r){var t=r.getAttribute(BL);switch(t){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},GC=function(r,t){var i=_L(r);return i===1||t===i},WA=function(){function r(t,i){if(this.context=t,this.textNodes=[],this.elements=[],this.flags=0,GC(i,3))debugger;this.styles=new vL(t,window.getComputedStyle(i,null)),ZC(i)&&(this.styles.animationDuration.some(function(s){return s>0})&&(i.style.animationDuration="0s"),this.styles.transform!==null&&(i.style.transform="none")),this.bounds=$d(this.context,i),GC(i,4)&&(this.flags|=16)}return r}(),xL="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAI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AgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",Cv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qh=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Wh=0;Wh>4,x[A++]=(g&15)<<4|d>>2,x[A++]=(d&3)<<6|C&63;return v},FL=function(r){for(var t=r.length,i=[],s=0;s>Zc,EL=1<>Zc,QL=_2+TL,UL=QL,GL=32,RL=UL+GL,HL=65536>>OC,ZL=1<=0){if(t<55296||t>56319&&t<=65535)return i=this.index[t>>Zc],i=(i<>Zc)],i=(i<>OC),i=this.index[i],i+=t>>Zc&PL,i=this.index[i],i=(i<"u"?[]:new Uint8Array(256);for(Oh=0;Oh=55296&&A<=56319&&i>10)+55296,g%1024+56320)),(A+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},JL=NL(xL),Rc="\xD7",Fv="\xF7",XL=function(r){return JL.get(r)},YL=function(r,t,i){var s=i-2,A=t[s],o=t[i-1],g=t[i];if(o===cC&&g===uC)return Rc;if(o===cC||o===uC||o===bv||g===cC||g===uC||g===bv)return Fv;if(o===wv&&[wv,hC,Bv,_v].indexOf(g)!==-1||(o===Bv||o===hC)&&(g===hC||g===gC)||(o===_v||o===gC)&&g===gC||g===xv||g===vv||g===WL||o===KL)return Rc;if(o===xv&&g===Sv){for(;A===vv;)A=t[--s];if(A===Sv)return Rc}if(o===dC&&g===dC){for(var d=0;A===dC;)d++,A=t[--s];if(d%2===0)return Rc}return Fv},jL=function(r){var t=OL(r),i=t.length,s=0,A=0,o=t.map(XL);return{next:function(){if(s>=i)return{done:!0,value:null};for(var g=Rc;sg.x||x.y>g.y;return g=x,v===0?!0:T});return r.body.removeChild(t),d},eE=function(){return typeof new Image().crossOrigin<"u"},iE=function(){return typeof new XMLHttpRequest().responseType=="string"},rE=function(r){var t=new Image,i=r.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch{return!1}return!0},kv=function(r){return r[0]===0&&r[1]===255&&r[2]===0&&r[3]===255},nE=function(r){var t=r.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var A=new Image,o=t.toDataURL();A.src=o;var g=RC(i,i,0,0,A);return s.fillStyle="red",s.fillRect(0,0,i,i),Lv(g).then(function(d){s.drawImage(d,0,0);var C=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var v=r.createElement("div");return v.style.backgroundImage="url("+o+")",v.style.height=i+"px",kv(C)?Lv(RC(i,i,0,0,v)):Promise.reject(!1)}).then(function(d){return s.drawImage(d,0,0),kv(s.getImageData(0,0,i,i).data)}).catch(function(){return!1})},RC=function(r,t,i,s,A){var o="http://www.w3.org/2000/svg",g=document.createElementNS(o,"svg"),d=document.createElementNS(o,"foreignObject");return g.setAttributeNS(null,"width",r.toString()),g.setAttributeNS(null,"height",t.toString()),d.setAttributeNS(null,"width","100%"),d.setAttributeNS(null,"height","100%"),d.setAttributeNS(null,"x",i.toString()),d.setAttributeNS(null,"y",s.toString()),d.setAttributeNS(null,"externalResourcesRequired","true"),g.appendChild(d),d.appendChild(A),g},Lv=function(r){return new Promise(function(t,i){var s=new Image;s.onload=function(){return t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r))})},Ts={get SUPPORT_RANGE_BOUNDS(){var r=$L(document);return Object.defineProperty(Ts,"SUPPORT_RANGE_BOUNDS",{value:r}),r},get SUPPORT_WORD_BREAKING(){var r=Ts.SUPPORT_RANGE_BOUNDS&&tE(document);return Object.defineProperty(Ts,"SUPPORT_WORD_BREAKING",{value:r}),r},get SUPPORT_SVG_DRAWING(){var r=rE(document);return Object.defineProperty(Ts,"SUPPORT_SVG_DRAWING",{value:r}),r},get SUPPORT_FOREIGNOBJECT_DRAWING(){var r=typeof Array.from=="function"&&typeof window.fetch=="function"?nE(document):Promise.resolve(!1);return Object.defineProperty(Ts,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:r}),r},get SUPPORT_CORS_IMAGES(){var r=eE();return Object.defineProperty(Ts,"SUPPORT_CORS_IMAGES",{value:r}),r},get SUPPORT_RESPONSE_TYPE(){var r=iE();return Object.defineProperty(Ts,"SUPPORT_RESPONSE_TYPE",{value:r}),r},get SUPPORT_CORS_XHR(){var r="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Ts,"SUPPORT_CORS_XHR",{value:r}),r},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var r=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Ts,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:r}),r}},rg=function(){function r(t,i){this.text=t,this.bounds=i}return r}(),sE=function(r,t,i,s){var A=AE(t,i),o=[],g=0;return A.forEach(function(d){if(i.textDecorationLine.length||d.trim().length>0)if(Ts.SUPPORT_RANGE_BOUNDS){var C=Ev(s,g,d.length).getClientRects();if(C.length>1){var v=zC(d),x=0;v.forEach(function(G){o.push(new rg(G,vl.fromDOMRectList(r,Ev(s,x+g,G.length).getClientRects()))),x+=G.length})}else o.push(new rg(d,vl.fromDOMRectList(r,C)))}else{var T=s.splitText(d.length);o.push(new rg(d,oE(r,s))),s=T}else Ts.SUPPORT_RANGE_BOUNDS||(s=s.splitText(d.length));g+=d.length}),o},oE=function(r,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var A=t.parentNode;if(A){A.replaceChild(s,t);var o=$d(r,s);return s.firstChild&&A.replaceChild(s.firstChild,s),o}}return vl.EMPTY},Ev=function(r,t,i){var s=r.ownerDocument;if(!s)throw new Error("Node has no owner document");var A=s.createRange();return A.setStart(r,t),A.setEnd(r,t+i),A},zC=function(r){if(Ts.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(r)).map(function(i){return i.segment})}return qL(r)},aE=function(r,t){if(Ts.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(r)).map(function(s){return s.segment})}return cE(r,t)},AE=function(r,t){return t.letterSpacing!==0?zC(r):aE(r,t)},lE=[32,160,4961,65792,65793,4153,4241],cE=function(r,t){for(var i=HF(r,{lineBreak:t.lineBreak,wordBreak:t.overflowWrap==="break-word"?"break-word":t.wordBreak}),s=[],A,o=function(){if(A.value){var g=A.value.slice(),d=tp(g),C="";d.forEach(function(v){lE.indexOf(v)===-1?C+=Gn(v):(C.length&&s.push(C),s.push(Gn(v)),C="")}),C.length&&s.push(C)}};!(A=i.next()).done;)o();return s},uE=function(){function r(t,i,s){this.text=hE(i.data,s.textTransform),this.textBounds=sE(t,this.text,s,i)}return r}(),hE=function(r,t){switch(t){case 1:return r.toLowerCase();case 3:return r.replace(gE,dE);case 2:return r.toUpperCase();default:return r}},gE=/(^|\s|:|-|\(|\))([a-z])/g,dE=function(r,t,i){return r.length>0?t+i.toUpperCase():r},x2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.src=s.currentSrc||s.src,A.intrinsicWidth=s.naturalWidth,A.intrinsicHeight=s.naturalHeight,A.context.cache.addImage(A.src),A}return t}(WA),S2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.canvas=s,A.intrinsicWidth=s.width,A.intrinsicHeight=s.height,A}return t}(WA),F2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this,o=new XMLSerializer,g=$d(i,s);return s.setAttribute("width",g.width+"px"),s.setAttribute("height",g.height+"px"),A.svg="data:image/svg+xml,"+encodeURIComponent(o.serializeToString(s)),A.intrinsicWidth=s.width.baseVal.value,A.intrinsicHeight=s.height.baseVal.value,A.context.cache.addImage(A.svg),A}return t}(WA),k2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.value=s.value,A}return t}(WA),HC=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.start=s.start,A.reversed=typeof s.reversed=="boolean"&&s.reversed===!0,A}return t}(WA),pE=[{type:15,flags:0,unit:"px",number:3}],fE=[{type:16,flags:0,number:50}],mE=function(r){return r.width>r.height?new vl(r.left+(r.width-r.height)/2,r.top,r.height,r.height):r.width0)i.textNodes.push(new uE(r,A,i.styles));else if(Uu(A))if(P2(A)&&A.assignedNodes)A.assignedNodes().forEach(function(d){return Nd(r,d,i,s)});else{var g=Q2(r,A);g.styles.isVisible()&&(bE(A,g,s)?g.flags|=4:vE(g.styles)&&(g.flags|=2),yE.indexOf(A.tagName)!==-1&&(g.flags|=8),i.elements.push(g),A.slot,A.shadowRoot?Nd(r,A.shadowRoot,g,s):!Jd(A)&&!R2(A)&&!Xd(A)&&Nd(r,A,g,s))}},Q2=function(r,t){return PC(t)?new x2(r,t):H2(t)?new S2(r,t):R2(t)?new F2(r,t):wE(t)?new k2(r,t):BE(t)?new HC(r,t):_E(t)?new JC(r,t):Xd(t)?new L2(r,t):Jd(t)?new E2(r,t):Z2(t)?new T2(r,t):new WA(r,t)},U2=function(r,t){var i=Q2(r,t);return i.flags|=4,Nd(r,t,i,i),i},bE=function(r,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||XC(r)&&i.styles.isTransparent()},vE=function(r){return r.isPositioned()||r.isFloating()},G2=function(r){return r.nodeType===Node.TEXT_NODE},Uu=function(r){return r.nodeType===Node.ELEMENT_NODE},ZC=function(r){return Uu(r)&&typeof r.style<"u"&&!Vd(r)},Vd=function(r){return typeof r.className=="object"},wE=function(r){return r.tagName==="LI"},BE=function(r){return r.tagName==="OL"},_E=function(r){return r.tagName==="INPUT"},xE=function(r){return r.tagName==="HTML"},R2=function(r){return r.tagName==="svg"},XC=function(r){return r.tagName==="BODY"},H2=function(r){return r.tagName==="CANVAS"},Qv=function(r){return r.tagName==="VIDEO"},PC=function(r){return r.tagName==="IMG"},Z2=function(r){return r.tagName==="IFRAME"},Uv=function(r){return r.tagName==="STYLE"},SE=function(r){return r.tagName==="SCRIPT"},Jd=function(r){return r.tagName==="TEXTAREA"},Xd=function(r){return r.tagName==="SELECT"},P2=function(r){return r.tagName==="SLOT"},Gv=function(r){return r.tagName.indexOf("-")>0},FE=function(){function r(){this.counters={}}return r.prototype.getCounterValue=function(t){var i=this.counters[t];return i&&i.length?i[i.length-1]:1},r.prototype.getCounterValues=function(t){var i=this.counters[t];return i||[]},r.prototype.pop=function(t){var i=this;t.forEach(function(s){return i.counters[s].pop()})},r.prototype.parse=function(t){var i=this,s=t.counterIncrement,A=t.counterReset,o=!0;s!==null&&s.forEach(function(d){var C=i.counters[d.counter];C&&d.increment!==0&&(o=!1,C.length||C.push(1),C[Math.max(0,C.length-1)]+=d.increment)});var g=[];return o&&A.forEach(function(d){var C=i.counters[d.counter];g.push(d.counter),C||(C=i.counters[d.counter]=[]),C.push(d.reset)}),g},r}(),Rv={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Hv={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},kE={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},LE={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},Fu=function(r,t,i,s,A,o){return ri?ag(r,A,o.length>0):s.integers.reduce(function(g,d,C){for(;r>=d;)r-=d,g+=s.values[C];return g},"")+o},M2=function(r,t,i,s){var A="";do i||r--,A=s(r)+A,r/=t;while(r*t>=t);return A},Un=function(r,t,i,s,A){var o=i-t+1;return(r<0?"-":"")+(M2(Math.abs(r),o,s,function(g){return Gn(Math.floor(g%o)+t)})+A)},Uc=function(r,t,i){i===void 0&&(i=". ");var s=t.length;return M2(Math.abs(r),s,!1,function(A){return t[Math.floor(A%s)]})+i},Eu=1,$l=2,tc=4,$h=8,yl=function(r,t,i,s,A,o){if(r<-9999||r>9999)return ag(r,4,A.length>0);var g=Math.abs(r),d=A;if(g===0)return t[0]+d;for(var C=0;g>0&&C<=4;C++){var v=g%10;v===0&&as(o,Eu)&&d!==""?d=t[v]+d:v>1||v===1&&C===0||v===1&&C===1&&as(o,$l)||v===1&&C===1&&as(o,tc)&&r>100||v===1&&C>1&&as(o,$h)?d=t[v]+(C>0?i[C-1]:"")+d:v===1&&C>0&&(d=i[C-1]+d),g=Math.floor(g/10)}return(r<0?s:"")+d},Zv="\u5341\u767E\u5343\u842C",Pv="\u62FE\u4F70\u4EDF\u842C",Mv="\u30DE\u30A4\u30CA\u30B9",pC="\uB9C8\uC774\uB108\uC2A4",ag=function(r,t,i){var s=i?". ":"",A=i?"\u3001":"",o=i?", ":"",g=i?" ":"";switch(t){case 0:return"\u2022"+g;case 1:return"\u25E6"+g;case 2:return"\u25FE"+g;case 5:var d=Un(r,48,57,!0,s);return d.length<4?"0"+d:d;case 4:return Uc(r,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",A);case 6:return Fu(r,1,3999,Rv,3,s).toLowerCase();case 7:return Fu(r,1,3999,Rv,3,s);case 8:return Un(r,945,969,!1,s);case 9:return Un(r,97,122,!1,s);case 10:return Un(r,65,90,!1,s);case 11:return Un(r,1632,1641,!0,s);case 12:case 49:return Fu(r,1,9999,Hv,3,s);case 35:return Fu(r,1,9999,Hv,3,s).toLowerCase();case 13:return Un(r,2534,2543,!0,s);case 14:case 30:return Un(r,6112,6121,!0,s);case 15:return Uc(r,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",A);case 16:return Uc(r,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",A);case 17:case 48:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Zv,"\u8CA0",A,$l|tc|$h);case 47:return yl(r,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",Pv,"\u8CA0",A,Eu|$l|tc|$h);case 42:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Zv,"\u8D1F",A,$l|tc|$h);case 41:return yl(r,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",Pv,"\u8D1F",A,Eu|$l|tc|$h);case 26:return yl(r,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",Mv,A,0);case 25:return yl(r,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",Mv,A,Eu|$l|tc);case 31:return yl(r,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",pC,o,Eu|$l|tc);case 33:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",pC,o,0);case 32:return yl(r,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",pC,o,Eu|$l|tc);case 18:return Un(r,2406,2415,!0,s);case 20:return Fu(r,1,19999,LE,3,s);case 21:return Un(r,2790,2799,!0,s);case 22:return Un(r,2662,2671,!0,s);case 22:return Fu(r,1,10999,kE,3,s);case 23:return Uc(r,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return Uc(r,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return Un(r,3302,3311,!0,s);case 28:return Uc(r,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",A);case 29:return Uc(r,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",A);case 34:return Un(r,3792,3801,!0,s);case 37:return Un(r,6160,6169,!0,s);case 38:return Un(r,4160,4169,!0,s);case 39:return Un(r,2918,2927,!0,s);case 40:return Un(r,1776,1785,!0,s);case 43:return Un(r,3046,3055,!0,s);case 44:return Un(r,3174,3183,!0,s);case 45:return Un(r,3664,3673,!0,s);case 46:return Un(r,3872,3881,!0,s);case 3:default:return Un(r,48,57,!0,s)}},N2="data-html2canvas-ignore",Nv=function(){function r(t,i,s){if(this.context=t,this.options=s,this.scrolledElements=[],this.referenceElement=i,this.counters=new FE,this.quoteDepth=0,!i.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(i.ownerDocument.documentElement,!1)}return r.prototype.toIFrame=function(t,i){var s=this,A=EE(t,i);if(!A.contentWindow)return Promise.reject("Unable to find iframe window");var o=t.defaultView.pageXOffset,g=t.defaultView.pageYOffset,d=A.contentWindow,C=d.document,v=UE(A).then(function(){return Co(s,void 0,void 0,function(){var x,T;return Js(this,function(G){switch(G.label){case 0:return this.scrolledElements.forEach(ZE),d&&(d.scrollTo(i.left,i.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(d.scrollY!==i.top||d.scrollX!==i.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(d.scrollX-i.left,d.scrollY-i.top,0,0))),x=this.options.onclone,T=this.clonedReferenceElement,typeof T>"u"?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:C.fonts&&C.fonts.ready?[4,C.fonts.ready]:[3,2];case 1:G.sent(),G.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,QE(C)]:[3,4];case 3:G.sent(),G.label=4;case 4:return typeof x=="function"?[2,Promise.resolve().then(function(){return x(C,T)}).then(function(){return A})]:[2,A]}})})});return C.open(),C.write(RE(document.doctype)+""),HE(this.referenceElement.ownerDocument,o,g),C.replaceChild(C.adoptNode(this.documentElement),C.documentElement),C.close(),v},r.prototype.createElementClone=function(t){if(GC(t,2))debugger;if(H2(t))return this.createCanvasClone(t);if(Qv(t))return this.createVideoClone(t);if(Uv(t))return this.createStyleClone(t);var i=t.cloneNode(!1);return PC(i)&&(PC(t)&&t.currentSrc&&t.currentSrc!==t.src&&(i.src=t.currentSrc,i.srcset=""),i.loading==="lazy"&&(i.loading="eager")),Gv(i)?this.createCustomElementClone(i):i},r.prototype.createCustomElementClone=function(t){var i=document.createElement("html2canvascustomelement");return fC(t.style,i),i},r.prototype.createStyleClone=function(t){try{var i=t.sheet;if(i&&i.cssRules){var s=[].slice.call(i.cssRules,0).reduce(function(o,g){return g&&typeof g.cssText=="string"?o+g.cssText:o},""),A=t.cloneNode(!1);return A.textContent=s,A}}catch(o){if(this.context.logger.error("Unable to access cssRules property",o),o.name!=="SecurityError")throw o}return t.cloneNode(!1)},r.prototype.createCanvasClone=function(t){var i;if(this.options.inlineImages&&t.ownerDocument){var s=t.ownerDocument.createElement("img");try{return s.src=t.toDataURL(),s}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",t)}}var A=t.cloneNode(!1);try{A.width=t.width,A.height=t.height;var o=t.getContext("2d"),g=A.getContext("2d");if(g)if(!this.options.allowTaint&&o)g.putImageData(o.getImageData(0,0,t.width,t.height),0,0);else{var d=(i=t.getContext("webgl2"))!==null&&i!==void 0?i:t.getContext("webgl");if(d){var C=d.getContextAttributes();C?.preserveDrawingBuffer===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",t)}g.drawImage(t,0,0)}return A}catch{this.context.logger.info("Unable to clone canvas as it is tainted",t)}return A},r.prototype.createVideoClone=function(t){var i=t.ownerDocument.createElement("canvas");i.width=t.offsetWidth,i.height=t.offsetHeight;var s=i.getContext("2d");try{return s&&(s.drawImage(t,0,0,i.width,i.height),this.options.allowTaint||s.getImageData(0,0,i.width,i.height)),i}catch{this.context.logger.info("Unable to clone video as it is tainted",t)}var A=t.ownerDocument.createElement("canvas");return A.width=t.offsetWidth,A.height=t.offsetHeight,A},r.prototype.appendChildNode=function(t,i,s){(!Uu(i)||!SE(i)&&!i.hasAttribute(N2)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(i)))&&(!this.options.copyStyles||!Uu(i)||!Uv(i))&&t.appendChild(this.cloneNode(i,s))},r.prototype.cloneChildNodes=function(t,i,s){for(var A=this,o=t.shadowRoot?t.shadowRoot.firstChild:t.firstChild;o;o=o.nextSibling)if(Uu(o)&&P2(o)&&typeof o.assignedNodes=="function"){var g=o.assignedNodes();g.length&&g.forEach(function(d){return A.appendChildNode(i,d,s)})}else this.appendChildNode(i,o,s)},r.prototype.cloneNode=function(t,i){if(G2(t))return document.createTextNode(t.data);if(!t.ownerDocument)return t.cloneNode(!1);var s=t.ownerDocument.defaultView;if(s&&Uu(t)&&(ZC(t)||Vd(t))){var A=this.createElementClone(t);A.style.transitionProperty="none";var o=s.getComputedStyle(t),g=s.getComputedStyle(t,":before"),d=s.getComputedStyle(t,":after");this.referenceElement===t&&ZC(A)&&(this.clonedReferenceElement=A),XC(A)&&NE(A);var C=this.counters.parse(new mv(this.context,o)),v=this.resolvePseudoContent(t,A,g,ng.BEFORE);Gv(t)&&(i=!0),Qv(t)||this.cloneChildNodes(t,A,i),v&&A.insertBefore(v,A.firstChild);var x=this.resolvePseudoContent(t,A,d,ng.AFTER);return x&&A.appendChild(x),this.counters.pop(C),(o&&(this.options.copyStyles||Vd(t))&&!Z2(t)||i)&&fC(o,A),(t.scrollTop!==0||t.scrollLeft!==0)&&this.scrolledElements.push([A,t.scrollLeft,t.scrollTop]),(Jd(t)||Xd(t))&&(Jd(A)||Xd(A))&&(A.value=t.value),A}return t.cloneNode(!1)},r.prototype.resolvePseudoContent=function(t,i,s,A){var o=this;if(s){var g=s.content,d=i.ownerDocument;if(!(!d||!g||g==="none"||g==="-moz-alt-content"||s.display==="none")){this.counters.parse(new mv(this.context,s));var C=new wL(this.context,s),v=d.createElement("html2canvaspseudoelement");fC(s,v),C.content.forEach(function(T){if(T.type===0)v.appendChild(d.createTextNode(T.value));else if(T.type===22){var G=d.createElement("img");G.src=T.value,G.style.opacity="1",v.appendChild(G)}else if(T.type===18){if(T.name==="attr"){var k=T.values.filter($r);k.length&&v.appendChild(d.createTextNode(t.getAttribute(k[0].value)||""))}else if(T.name==="counter"){var W=T.values.filter(Ru),K=W[0],$=W[1];if(K&&$r(K)){var O=o.counters.getCounterValue(K.value),tt=$&&$r($)?UC.parse(o.context,$.value):3;v.appendChild(d.createTextNode(ag(O,tt,!1)))}}else if(T.name==="counters"){var at=T.values.filter(Ru),K=at[0],Lt=at[1],$=at[2];if(K&&$r(K)){var Tt=o.counters.getCounterValues(K.value),Qt=$&&$r($)?UC.parse(o.context,$.value):3,Ft=Lt&&Lt.type===0?Lt.value:"",vt=Tt.map(function(At){return ag(At,Qt,!1)}).join(Ft);v.appendChild(d.createTextNode(vt))}}}else if(T.type===20)switch(T.value){case"open-quote":v.appendChild(d.createTextNode(fv(C.quotes,o.quoteDepth++,!0)));break;case"close-quote":v.appendChild(d.createTextNode(fv(C.quotes,--o.quoteDepth,!1)));break;default:v.appendChild(d.createTextNode(T.value))}}),v.className=MC+" "+NC;var x=A===ng.BEFORE?" "+MC:" "+NC;return Vd(i)?i.className.baseValue+=x:i.className+=x,v}}},r.destroy=function(t){return t.parentNode?(t.parentNode.removeChild(t),!0):!1},r}();(function(r){r[r.BEFORE=0]="BEFORE",r[r.AFTER=1]="AFTER"})(ng||(ng={}));EE=function(r,t){var i=r.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute(N2,"true"),r.body.appendChild(i),i},TE=function(r){return new Promise(function(t){if(r.complete){t();return}if(!r.src){t();return}r.onload=t,r.onerror=t})},QE=function(r){return Promise.all([].slice.call(r.images,0).map(TE))},UE=function(r){return new Promise(function(t,i){var s=r.contentWindow;if(!s)return i("No window assigned for iframe");var A=s.document;s.onload=r.onload=function(){s.onload=r.onload=null;var o=setInterval(function(){A.body.childNodes.length>0&&A.readyState==="complete"&&(clearInterval(o),t(r))},50)}})},GE=["all","d","content"],fC=function(r,t){for(var i=r.length-1;i>=0;i--){var s=r.item(i);GE.indexOf(s)===-1&&t.style.setProperty(s,r.getPropertyValue(s))}return t},RE=function(r){var t="";return r&&(t+=""),t},HE=function(r,t,i){r&&r.defaultView&&(t!==r.defaultView.pageXOffset||i!==r.defaultView.pageYOffset)&&r.defaultView.scrollTo(t,i)},ZE=function(r){var t=r[0],i=r[1],s=r[2];t.scrollLeft=i,t.scrollTop=s},PE=":before",ME=":after",MC="___html2canvas___pseudoelement_before",NC="___html2canvas___pseudoelement_after",Vv=`{ +`)}}}var o=A(","),g=o.parse,d=o.parseRows,C=o.format,v=o.formatRows,x=A(" "),T=x.parse,G=x.parseRows,k=x.format,W=x.formatRows,K=i(Object.freeze({__proto__:null,csvFormat:C,csvFormatRows:v,csvParse:g,csvParseRows:d,dsvFormat:A,tsvFormat:k,tsvFormatRows:W,tsvParse:T,tsvParseRows:G})),$={exports:{}};function O(gt,bt){var ct=tt(gt,bt);return ct.whole+"\xB0 "+(ct.minutes?ct.minutes+"' ":"")+(ct.seconds?ct.seconds+'" ':"")+ct.dir}function tt(gt,bt){var ct=({lat:["N","S"],lon:["E","W"]}[bt]||"")[gt>=0?0:1],Bt=Math.abs(gt),Kt=Math.floor(Bt),Yt=60*(Bt-Kt),ae=Math.floor(Yt);return{whole:Kt,minutes:ae,seconds:Math.floor(60*(Yt-ae)),dir:ct}}function at(gt,bt){if(bt||(bt="NSEW"),typeof gt!="string")return null;var ct=(gt=gt.toUpperCase()).match(/^[\s\,]*([NSEW])?\s*([\-|—|―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/);if(!ct)return null;var Bt,Kt=ct[0];if(ct[1]&&ct[5]?(Bt=ct[1],Kt=Kt.slice(0,-1)):Bt=ct[1]||ct[5],Bt&&bt.indexOf(Bt)===-1)return null;var Yt=ct[2]?parseFloat(ct[2]):0,ae=ct[3]?parseFloat(ct[3])/60:0,we=ct[4]?parseFloat(ct[4])/3600:0,ve=Yt<0?-1:1;return Bt!=="S"&&Bt!=="W"||(ve*=-1),{val:(Math.abs(Yt)+ae+we)*ve,dim:Bt,matched:Kt,remain:gt.slice(Kt.length)}}$.exports=function(gt,bt){var ct=at(gt,bt);return ct===null?null:ct.val},$.exports.pair=function(gt,bt){var ct=at(gt=gt.trim(),bt);if(!ct)return null;var Bt=at(gt=ct.remain.trim(),bt);return!Bt||Bt.remain?null:ct.dim?function(Kt,Yt,ae){if(ae==="N"||ae==="S")return[Kt,Yt];if(ae==="W"||ae==="E")return[Yt,Kt]}(ct.val,Bt.val,ct.dim):[ct.val,Bt.val]},$.exports.format=O,$.exports.formatPair=function(gt){return O(gt.lat,"lat")+" "+O(gt.lon,"lon")},$.exports.coordToDMS=tt;var Lt=$.exports,Tt=K,Ut=Lt,Ft=/(Lat)(itude)?/gi,vt=/(L)(on|ng)(gitude)?/i;function Jt(gt,bt){var ct,Bt,Kt;for(var Yt in gt)(Bt=Yt.match(bt))&&(!ct||Bt[0].length/Yt.length>Kt)&&(Kt=Bt[0].length/Yt.length,ct=Yt);return ct}function qt(gt){return Jt(gt,Ft)}function At(gt){return Jt(gt,vt)}function lt(gt){return typeof gt=="object"?Object.keys(gt).length:0}function kt(gt){var bt=[];return[",",";"," ","|"].forEach(function(ct){var Bt=Tt.dsvFormat(ct).parse(gt);if(Bt.length>=1){for(var Kt=lt(Bt[0]),Yt=0;Yt{ct[Bt]=Kt});return ct}function Ot(gt){return gt?.nodeType===1}function Ae(gt){return fe(gt,"line",bt=>Object.assign({},j(bt,"color",ct=>({stroke:`#${ct}`})),yt(bt,"opacity",ct=>({"stroke-opacity":ct})),yt(bt,"width",ct=>({"stroke-width":96*ct/25.4}))))}function he(gt){let bt=[];if(gt===null)return bt;for(let ct of Array.from(gt.childNodes)){if(!Ot(ct))continue;let Bt=de(ct.nodeName);if(Bt==="gpxtpx:TrackPointExtension")bt=bt.concat(he(ct));else{let Kt=wt(ct);bt.push([Bt,He(Kt)])}}return bt}function de(gt){return["heart","gpxtpx:hr","hr"].includes(gt)?"heart":gt}function He(gt){let bt=parseFloat(gt);return isNaN(bt)?gt:bt}function Ge(gt){let bt=[parseFloat(gt.getAttribute("lon")||""),parseFloat(gt.getAttribute("lat")||"")];if(isNaN(bt[0])||isNaN(bt[1]))return null;It(gt,"ele",Bt=>{bt.push(Bt)});let ct=Qt(gt,"time");return{coordinates:bt,time:ct?wt(ct):null,extendedValues:he(Qt(gt,"extensions"))}}function je(gt){let bt=Ht(gt,["name","cmt","desc","type","time","keywords"]),ct=Array.from(gt.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3","*"));for(let Kt of ct)Kt.parentNode?.parentNode===gt&&(bt[Kt.tagName.replace(":","_")]=wt(Kt));let Bt=ne(gt,"link");return Bt.length&&(bt.links=Bt.map(Kt=>Object.assign({href:Kt.getAttribute("href")},Ht(Kt,["text","type"])))),bt}function Me(gt,bt){let ct=ne(gt,bt),Bt=[],Kt=[],Yt={};for(let ae=0;ae1,ae=Object.assign({_gpxType:"trk"},je(gt),Ae(Qt(gt,"extensions")),Bt.length?{coordinateProperties:{times:Yt?Bt:Bt[0]}}:{});for(let we of Kt){ct.push(we.line),ae.coordinateProperties||(ae.coordinateProperties={});let ve=ae.coordinateProperties,Ie=Object.entries(we.extendedValues);for(let oe=0;oenew Array(Re.line.length).fill(null))),ve[ye][oe]=Be):ve[ye]=Be}}return{type:"Feature",properties:ae,geometry:Yt?{type:"MultiLineString",coordinates:ct}:{type:"LineString",coordinates:ct[0]}}}function Rt(gt){let bt=Object.assign(je(gt),Ht(gt,["sym"])),ct=Ge(gt);return ct?{type:"Feature",properties:bt,geometry:{type:"Point",coordinates:ct.coordinates}}:null}function*Li(gt){for(let bt of ne(gt,"trk")){let ct=xt(bt);ct&&(yield ct)}for(let bt of ne(gt,"rte")){let ct=gi(bt);ct&&(yield ct)}for(let bt of ne(gt,"wpt")){let ct=Rt(bt);ct&&(yield ct)}}let Qe="http://www.garmin.com/xmlschemas/ActivityExtension/v2",Ee=[["heartRate","heartRates"],["Cadence","cadences"],["Speed","speeds"],["Watts","watts"]],Ne=[["TotalTimeSeconds","totalTimeSeconds"],["DistanceMeters","distanceMeters"],["MaximumSpeed","maxSpeed"],["AverageHeartRateBpm","avgHeartRate"],["MaximumHeartRateBpm","maxHeartRate"],["AvgSpeed","avgSpeed"],["AvgWatts","avgWatts"],["MaxWatts","maxWatts"]];function Je(gt,bt){let ct=[];for(let[Bt,Kt]of bt){let Yt=Qt(gt,Bt);if(!Yt){let we=gt.getElementsByTagNameNS(Qe,Bt);we.length&&(Yt=we[0])}let ae=parseFloat(wt(Yt));isNaN(ae)||ct.push([Kt,ae])}return ct}function ze(gt){let bt=[It(gt,"LongitudeDegrees"),It(gt,"LatitudeDegrees")];if(bt[0]===void 0||isNaN(bt[0])||bt[1]===void 0||isNaN(bt[1]))return null;let ct=Qt(gt,"HeartRateBpm"),Bt=wt(Qt(gt,"Time"));return Qt(gt,"AltitudeMeters",Kt=>{let Yt=parseFloat(wt(Kt));isNaN(Yt)||bt.push(Yt)}),{coordinates:bt,time:Bt||null,heartRate:ct?parseFloat(wt(ct)):null,extensions:Je(gt,Ee)}}function ui(gt){let bt=ne(gt,"Trackpoint"),ct=[],Bt=[],Kt=[];if(bt.length<2)return null;let Yt={},ae={extendedProperties:Yt};for(let we=0;we({name:wt(ve)})));for(let ve of bt)ae=ui(ve),ae&&(ct.push(ae.line),ae.times.length&&Bt.push(ae.times),ae.heartRates.length&&Kt.push(ae.heartRates),Yt.push(ae.extendedProperties));for(let ve=0;veArray(ye.length).fill(null))),we[oe][ve]=Ie[oe])}return ct.length===0?null:((Bt.length||Kt.length)&&(we.coordinateProperties=Object.assign(Bt.length?{times:ct.length===1?Bt[0]:Bt}:{},Kt.length?{heart:ct.length===1?Kt[0]:Kt}:{})),{type:"Feature",properties:we,geometry:ct.length===1?{type:"LineString",coordinates:ct[0]}:{type:"MultiLineString",coordinates:ct}})}function*Ei(gt){for(let bt of ne(gt,"Lap")){let ct=hi(bt);ct&&(yield ct)}for(let bt of ne(gt,"Courses")){let ct=hi(bt);ct&&(yield ct)}}function Pi(gt,bt){let ct={},Bt=bt=="stroke"||bt==="fill"?bt:bt+"-color";return gt[0]==="#"&&(gt=gt.substring(1)),gt.length===6||gt.length===3?ct[Bt]="#"+gt:gt.length===8&&(ct[bt+"-opacity"]=parseInt(gt.substring(0,2),16)/255,ct[Bt]="#"+gt.substring(6,8)+gt.substring(4,6)+gt.substring(2,4)),ct}function Ce(gt,bt,ct){let Bt={};return It(gt,bt,Kt=>{Bt[ct]=Kt}),Bt}function Oi(gt,bt){return fe(gt,"color",ct=>Pi(wt(ct),bt))}function mi(gt){return fe(gt,"Icon",(bt,ct)=>(j(bt,"href",Bt=>{ct.icon=Bt}),ct))}function Vi(gt){return Object.assign({},function(bt){return fe(bt,"PolyStyle",(ct,Bt)=>Object.assign(Bt,fe(ct,"color",Kt=>Pi(wt(Kt),"fill")),j(ct,"fill",Kt=>{if(Kt==="0")return{"fill-opacity":0}}),j(ct,"outline",Kt=>{if(Kt==="0")return{"stroke-opacity":0}})))}(gt),function(bt){return fe(bt,"LineStyle",ct=>Object.assign(Oi(ct,"stroke"),Ce(ct,"width","stroke-width")))}(gt),function(bt){return fe(bt,"LabelStyle",ct=>Object.assign(Oi(ct,"label"),Ce(ct,"scale","label-scale")))}(gt),function(bt){return fe(bt,"IconStyle",ct=>Object.assign(Oi(ct,"icon"),Ce(ct,"scale","icon-scale"),Ce(ct,"heading","icon-heading"),fe(ct,"hotSpot",Bt=>{let Kt=parseFloat(Bt.getAttribute("x")||""),Yt=parseFloat(Bt.getAttribute("y")||""),ae=Bt.getAttribute("xunits")||"",we=Bt.getAttribute("yunits")||"";return isNaN(Kt)||isNaN(Yt)?{}:{"icon-offset":[Kt,Yt],"icon-offset-units":[ae,we]}}),mi(ct)))}(gt))}let We=gt=>Number(gt),Se={string:gt=>gt,int:We,uint:We,short:We,ushort:We,float:We,double:We,bool:gt=>Boolean(gt)};function $e(gt,bt){return fe(gt,"ExtendedData",(ct,Bt)=>{for(let Kt of ne(ct,"Data"))Bt[Kt.getAttribute("name")||""]=wt(Qt(Kt,"value"));for(let Kt of ne(ct,"SimpleData")){let Yt=Kt.getAttribute("name")||"",ae=bt[Yt]||Se.string;Bt[Yt]=ae(wt(Kt))}return Bt})}function di(gt){let bt=Qt(gt,"description");for(let ct of Array.from(bt?.childNodes||[]))if(ct.nodeType===4)return{description:{"@type":"html",value:wt(ct)}};return{}}function Zi(gt){return fe(gt,"TimeSpan",bt=>({timespan:{begin:wt(Qt(bt,"begin")),end:wt(Qt(bt,"end"))}}))}function qi(gt){return fe(gt,"TimeStamp",bt=>({timestamp:wt(Qt(bt,"when"))}))}function vi(gt,bt){return j(gt,"styleUrl",ct=>(ct=te(ct),bt[ct]?Object.assign({styleUrl:ct},bt[ct]):{styleUrl:ct}))}let tr=/\s*/g,kr=/^\s*|\s*$/g,ft=/\s+/;function Y(gt){return gt.replace(tr,"").split(",").map(parseFloat).filter(bt=>!isNaN(bt)).slice(0,3)}function q(gt){return gt.replace(kr,"").split(ft).map(Y).filter(bt=>bt.length>=2)}function rt(gt){let bt=ne(gt,"coord");bt.length===0&&(bt=function(Bt,Kt,Yt){return Array.from(Bt.getElementsByTagNameNS(Yt,Kt))}(gt,"coord","*"));let ct=bt.map(Bt=>wt(Bt).split(" ").map(parseFloat));return ct.length===0?null:{geometry:ct.length>2?{type:"LineString",coordinates:ct}:{type:"Point",coordinates:ct[0]},times:ne(gt,"when").map(Bt=>wt(Bt))}}function ht(gt){if(gt.length===0)return gt;let bt=gt[0],ct=gt[gt.length-1],Bt=!0;for(let Kt=0;Kt=2&&bt.push({type:"Point",coordinates:Yt});break}case"LinearRing":case"LineString":{let Yt=q(Zt(Kt));Yt.length>=2&&bt.push({type:"LineString",coordinates:Yt});break}case"Polygon":{let Yt=[];for(let ae of ne(Kt,"LinearRing")){let we=ht(q(Zt(ae)));we.length>=4&&Yt.push(we)}Yt.length&&bt.push({type:"Polygon",coordinates:Yt});break}case"Track":case"gx:Track":{let Yt=rt(Kt);if(!Yt)break;let{times:ae,geometry:we}=Yt;bt.push(we),ae.length&&ct.push(ae);break}}}return{geometries:bt,coordTimes:ct}}function Xt(gt,bt,ct,Bt){let{coordTimes:Kt,geometries:Yt}=zt(gt),ae=function(Ie){return Ie.length===0?null:Ie.length===1?Ie[0]:{type:"GeometryCollection",geometries:Ie}}(Yt);if(!ae&&Bt.skipNullGeometry)return null;let we={type:"Feature",geometry:ae,properties:Object.assign(Ht(gt,["name","address","visibility","open","phoneNumber","description"]),di(gt),vi(gt,bt),Vi(gt),$e(gt,ct),Zi(gt),qi(gt),Kt.length?{coordinateProperties:{times:Kt.length===1?Kt[0]:Kt}}:{})};we.properties?.visibility!==void 0&&(we.properties.visibility=we.properties.visibility!=="0");let ve=gt.getAttribute("id");return ve!==null&&ve!==""&&(we.id=ve),we}function Mt(gt){return Qt(gt,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ht(q(Zt(gt)))]}}:function(bt){let ct=Qt(bt,"LatLonBox");if(ct){let Bt=It(ct,"north"),Kt=It(ct,"west"),Yt=It(ct,"east"),ae=It(ct,"south"),we=It(ct,"rotation");if(typeof Bt=="number"&&typeof ae=="number"&&typeof Kt=="number"&&typeof Yt=="number"){let ve=[Kt,ae,Yt,Bt],Ie=[[[Kt,Bt],[Yt,Bt],[Yt,ae],[Kt,ae],[Kt,Bt]]];return typeof we=="number"&&(Ie=function(oe,ye,Be){let Re=[(oe[0]+oe[2])/2,(oe[1]+oe[3])/2];return[ye[0].map(Qi=>{let Ri=Qi[1]-Re[1],Pe=Qi[0]-Re[0],Ue=Math.sqrt(Math.pow(Ri,2)+Math.pow(Pe,2)),Ai=Math.atan2(Ri,Pe)+Be*re;return[Re[0]+Math.cos(Ai)*Ue,Re[1]+Math.sin(Ai)*Ue]})]}(ve,Ie,we)),{bbox:ve,geometry:{type:"Polygon",coordinates:Ie}}}}return null}(gt)}let re=Math.PI/180;function ce(gt,bt,ct,Bt){let Kt=Mt(gt),Yt=Kt?.geometry||null;if(!Yt&&Bt.skipNullGeometry)return null;let ae={type:"Feature",geometry:Yt,properties:Object.assign({"@geometry-type":"groundoverlay"},Ht(gt,["name","address","visibility","open","phoneNumber","description"]),di(gt),vi(gt,bt),Vi(gt),mi(gt),$e(gt,ct),Zi(gt),qi(gt))};Kt?.bbox&&(ae.bbox=Kt.bbox),ae.properties?.visibility!==void 0&&(ae.properties.visibility=ae.properties.visibility!=="0");let we=gt.getAttribute("id");return we!==null&&we!==""&&(ae.id=we),ae}function pe(gt){let bt=gt.getAttribute("id"),ct=gt.parentNode;return!bt&&Ot(ct)&&ct.localName==="CascadingStyle"&&(bt=ct.getAttribute("kml:id")||ct.getAttribute("id")),te(bt||"")}function me(gt){let bt={};for(let ct of ne(gt,"Style"))bt[pe(ct)]=Vi(ct);for(let ct of ne(gt,"StyleMap")){let Bt=te(ct.getAttribute("id")||"");j(ct,"styleUrl",Kt=>{Kt=te(Kt),bt[Kt]&&(bt[Bt]=bt[Kt])})}return bt}function Xe(gt){let bt={};for(let ct of ne(gt,"SimpleField"))bt[ct.getAttribute("name")||""]=Se[ct.getAttribute("type")||""]||Se.string;return bt}let oi=["name","visibility","open","address","description","phoneNumber","visibility"];function*ii(gt,bt={skipNullGeometry:!1}){let ct=me(gt),Bt=Xe(gt);for(let Kt of ne(gt,"Placemark")){let Yt=Xt(Kt,ct,Bt,bt);Yt&&(yield Yt)}for(let Kt of ne(gt,"GroundOverlay")){let Yt=ce(Kt,ct,Bt,bt);Yt&&(yield Yt)}}var Ni=Object.freeze({__proto__:null,gpx:function(gt){return{type:"FeatureCollection",features:Array.from(Li(gt))}},gpxGen:Li,kml:function(gt,bt={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(ii(gt,bt))}},kmlGen:ii,kmlWithFolders:function(gt,bt={skipNullGeometry:!1}){let ct=me(gt),Bt=Xe(gt),Kt={type:"root",children:[]};return function Yt(ae,we,ve){if(Ot(ae))switch(ae.tagName){case"GroundOverlay":{let Ie=ce(ae,ct,Bt,ve);Ie&&we.children.push(Ie);break}case"Placemark":{let Ie=Xt(ae,ct,Bt,ve);Ie&&we.children.push(Ie);break}case"Folder":{let Ie=function(oe){let ye={};for(let Be of Array.from(oe.childNodes))Ot(Be)&&oi.includes(Be.tagName)&&(ye[Be.tagName]=wt(Be));return{type:"folder",meta:ye,children:[]}}(ae);we.children.push(Ie),we=Ie;break}}if(ae.childNodes)for(let Ie=0;Ie=0?1:-1)}function Bt(Yt,ae,we){var ve=2*((Yt=ct(Yt*we))-(ae=ct(ae*we)));ve<0&&(ve=-ve-1);for(var Ie="";ve>=32;)Ie+=String.fromCharCode(63+(32|31&ve)),ve/=32;return Ie+=String.fromCharCode(63+(0|ve))}function Kt(Yt){for(var ae=[],we=0;we=32);we=1&Re?(-Re-1)/2:Re/2,Be=1,Re=0;do Re+=(31&(Qi=Yt.charCodeAt(ve++)-63))*Be,Be*=32;while(Qi>=32);Ie+=we,oe+=1&Re?(-Re-1)/2:Re/2,ye.push([Ie/Ri,oe/Ri])}return ye},bt.encode=function(Yt,ae){if(!Yt.length)return"";for(var we=Math.pow(10,Number.isInteger(ae)?ae:5),ve=Bt(Yt[0][0],0,we)+Bt(Yt[0][1],0,we),Ie=1;Ie{let gt=oe=>oe[0],bt=oe=>oe[oe.length-1],ct=oe=>oe.join(","),Bt=(oe,ye,Be)=>{let Re=oe[ye];Re?Re.push(Be):oe[ye]=[Be]},Kt=(oe,ye,Be)=>{let Re=oe[ye],Qi=null;Re&&(Qi=Re.indexOf(Be))>=0&&Re.splice(Qi,1)},Yt=(oe,ye)=>{let Be=oe[ye];return Be&&Be.length>0?Be[0]:null},ae=oe=>oe.length>3&&ct(gt(oe))===ct(bt(oe)),we=(oe,ye,Be)=>{ye=ye||0,Be=Be||1;let Re=oe.reduce((nr,ai,dr)=>oe[nr][ye]>ai[ye]?nr:dr,0),Qi=Re<=0?oe.length-2:Re-1,Ri=Re>=oe.length-1?1:Re+1,Pe=oe[Qi][ye],Ue=oe[Re][ye],Ai=oe[Ri][ye],Fi=oe[Qi][Be],Wi=oe[Re][Be];return(Ue-Pe)*(oe[Ri][Be]-Fi)-(Ai-Pe)*(Wi-Fi)<0?"clockwise":"counterclockwise"},ve=oe=>oe instanceof Array?oe.map(ve):parseFloat(oe);class Ie extends Map{constructor(){super(),this.binders=[]}add(ye,Be){this.has(ye)||this.set(ye,Be)}addBinder(ye){this.binders.push(ye)}bindAll(){this.binders.forEach(ye=>ye.bind())}}return{purgeProps:(oe,ye)=>{if(oe){let Be=Object.assign({},oe);if(ye)for(let Re of ye)delete Be[Re];return Be}return{}},mergeProps:(oe,ye)=>(oe=oe||{},ye=ye||{},Object.assign(oe,ye)),first:gt,last:bt,coordsToKey:ct,addToMap:Bt,removeFromMap:Kt,getFirstFromMap:Yt,isRing:ae,ringDirection:we,ptInsidePolygon:(oe,ye,Be,Re)=>{Be=Be||0,Re=Re||1;let Qi=!1;for(let Ri=0,Pe=ye.length-1;Ri=0){let Be=[ye,1];oe&&Be.push(oe),[].splice.apply(this.container,Be)}}else if(typeof this.container=="object"){let ye=Object.keys(this.container).find(Be=>this.container[Be]===this);ye&&(oe?this.container[ye]=oe:delete this.container[ye])}}},WayCollection:class extends Array{constructor(){super(),this.firstMap={},this.lastMap={}}addWay(oe){(oe=oe.toCoordsArray()).length>0&&(this.push(oe),Bt(this.firstMap,ct(gt(oe)),oe),Bt(this.lastMap,ct(bt(oe)),oe))}toStrings(){let oe=[],ye=null;for(;ye=this.shift();){Kt(this.firstMap,ct(gt(ye)),ye),Kt(this.lastMap,ct(bt(ye)),ye);let Be=ye,Re=null;do{let Qi=ct(bt(Be)),Ri=!1;Re=Yt(this.firstMap,Qi),Re||(Re=Yt(this.lastMap,Qi),Ri=!0),Re&&(this.splice(this.indexOf(Re),1),Kt(this.firstMap,ct(gt(Re)),Re),Kt(this.lastMap,ct(bt(Re)),Re),Ri&&(Re.length>Be.length&&([Be,Re]=[Re,Be]),Re.reverse()),Be=Be.concat(Re.slice(1)))}while(Re);oe.push(ve(Be))}return oe}toRings(oe){let ye=this.toStrings(),Be=[],Re=null;for(;Re=ye.shift();)ae(Re)&&(we(Re)!==oe&&Re.reverse(),Be.push(Re));return Be}}}})(),Cr={building:{},highway:{whitelist:["services","rest_area","escape","elevator"]},natural:{blacklist:["coastline","cliff","ridge","arete","tree_row"]},landuse:{},waterway:{whitelist:["riverbank","dock","boatyard","dam"]},amenity:{},leisure:{},barrier:{whitelist:["city_wall","ditch","hedge","retaining_wall","wall","spikes"]},railway:{whitelist:["station","turntable","roundhouse","platform"]},area:{},boundary:{},man_made:{blacklist:["cutline","embankment","pipeline"]},power:{whitelist:["plant","substation","generator","transformer"]},place:{},shop:{},aeroway:{blacklist:["taxiway"]},tourism:{},historic:{},public_transport:{},office:{},"building:part":{},military:{},ruins:{},"area:highway":{},craft:{},golf:{},indoor:{}},ki=(()=>{let{first:gt,last:bt,coordsToKey:ct,addToMap:Bt,removeFromMap:Kt,getFirstFromMap:Yt,isRing:ae,ringDirection:we,ptInsidePolygon:ve,strToFloat:Ie,LateBinder:oe,WayCollection:ye}=zi,Be=Cr;class Re{constructor(Ue,Ai,Fi){this.type=Ue,this.id=Ai,this.refElems=Fi,this.tags={},this.props={id:this.getCompositeId()},this.refCount=0,this.hasTag=!1,Fi&&Fi.add(this.getCompositeId(),this)}addTags(Ue){this.tags=Object.assign(this.tags,Ue),this.hasTag=!!Ue}addTag(Ue,Ai){this.tags[Ue]=Ai,this.hasTag=!!Ue}addProp(Ue,Ai){this.props[Ue]=Ai}addProps(Ue){this.props=Object.assign(this.props,Ue)}getCompositeId(){return`${this.type}/${this.id}`}getProps(){return Object.assign(this.props,this.tags)}toFeatureArray(){return[]}}class Qi extends Re{constructor(Ue,Ai){super("node",Ue,Ai),this.latLng=null}setLatLng(Ue){this.latLng=Ue}toFeatureArray(){return this.latLng?[{type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"Point",coordinates:Ie([this.latLng.lon,this.latLng.lat])}}]:[]}getLatLng(){return this.latLng}}class Ri extends Re{constructor(Ue,Ai){super("way",Ue,Ai),this.latLngArray=[],this.isPolygon=!1}addLatLng(Ue){this.latLngArray.push(Ue)}setLatLngArray(Ue){this.latLngArray=Ue}addNodeRef(Ue){let Ai=new oe(this.latLngArray,function(Fi){let Wi=this.refElems.get(`node/${Fi}`);if(Wi)return Wi.refCount++,Wi.getLatLng()},this,[Ue]);this.latLngArray.push(Ai),this.refElems.addBinder(Ai)}analyzeGeometryType(Ue,Ai){let Fi=Be[Ue];Fi&&(this.isPolygon=!0,Fi.whitelist?this.isPolygon=Fi.whitelist.indexOf(Ai)>=0:Fi.blacklist&&(this.isPolygon=!(Fi.blacklist.indexOf(Ai)>=0)))}addTags(Ue){super.addTags(Ue);for(let[Ai,Fi]of Object.entries(Ue))this.analyzeGeometryType(Ai,Fi)}addTag(Ue,Ai){super.addTag(Ue,Ai),this.analyzeGeometryType(Ue,Ai)}toCoordsArray(){return this.latLngArray.map(Ue=>[Ue.lon,Ue.lat])}toFeatureArray(){let Ue=this.toCoordsArray();if(Ue.length>1){Ue=Ie(Ue);let Ai={type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"LineString",coordinates:Ue}};return this.isPolygon&&ae(Ue)?(we(Ue)!=="counterclockwise"&&Ue.reverse(),Ai.geometry={type:"Polygon",coordinates:[Ue]},[Ai]):[Ai]}return[]}}return{Node:Qi,Way:Ri,Relation:class extends Re{constructor(Pe,Ue){super("relation",Pe,Ue),this.relations=[],this.nodes=[],this.bounds=null}setBounds(Pe){this.bounds=Pe}addMember(Pe){switch(Pe.type){case"relation":let Ue=new oe(this.relations,function(Wi){let nr=this.refElems.get(`relation/${Wi}`);if(nr)return nr.refCount++,nr},this,[Pe.ref]);this.relations.push(Ue),this.refElems.addBinder(Ue);break;case"way":Pe.role||(Pe.role="");let Ai=this[Pe.role];if(Ai||(Ai=this[Pe.role]=[]),Pe.geometry){let Wi=new Ri(Pe.ref,this.refElems);Wi.setLatLngArray(Pe.geometry),Wi.refCount++,Ai.push(Wi)}else if(Pe.nodes){let Wi=new Ri(Pe.ref,this.refElems);for(let nr of Pe.nodes)Wi.addNodeRef(nr);Wi.refCount++,Ai.push(Wi)}else{let Wi=new oe(Ai,function(nr){let ai=this.refElems.get(`way/${nr}`);if(ai)return ai.refCount++,ai},this,[Pe.ref]);Ai.push(Wi),this.refElems.addBinder(Wi)}break;case"node":let Fi=null;if(Pe.lat&&Pe.lon){Fi=new Qi(Pe.ref,this.refElems),Fi.setLatLng({lon:Pe.lon,lat:Pe.lat}),Pe.tags&&Fi.addTags(Pe.tags);for(let[Wi,nr]of Object.entries(Pe))["id","type","lat","lon"].indexOf(Wi)<0&&Fi.addProp(Wi,nr);Fi.refCount++,this.nodes.push(Fi)}else{let Wi=new oe(this.nodes,function(nr){let ai=this.refElems.get(`node/${nr}`);if(ai)return ai.refCount++,ai},this,[Pe.ref]);this.nodes.push(Wi),this.refElems.addBinder(Wi)}}}toFeatureArray(){let Pe=[],Ue=[],Ai=[],Fi=["outer","inner",""];for(let ai of this.relations)if(ai)for(let dr of Fi){let Or=ai[dr];if(Or){let Gr=this[dr];Gr?[].splice.apply(Gr,[Gr.length,0].concat(Or)):this[dr]=Or}}for(let ai of Fi){let dr=this[ai];if(dr){this[ai]=new ye;for(let Or of dr)this[ai].addWay(Or)}}let Wi=null,nr={type:"Feature",id:this.getCompositeId(),bbox:this.bounds,properties:this.getProps()};this.bounds||delete nr.bbox,this.outer?(Wi=((ai,dr)=>{let Or=ai?ai.toRings("counterclockwise"):[],Gr=dr?dr.toRings("clockwise"):[];if(Or.length>0){let xn=[],vn=null;for(vn of Or)xn.push([vn]);for(;vn=Gr.shift();)for(let ws in Or)if(ve(gt(vn),Or[ws])){xn[ws].push(vn);break}return xn.length===1?{type:"Polygon",coordinates:xn[0]}:{type:"MultiPolygon",coordinates:xn}}return null})(this.outer,this.inner),Wi&&(nr.geometry=Wi,Pe.push(nr))):this[""]&&(Wi=(ai=>{let dr=ai?ai.toStrings():[];return dr.length>0?dr.length===1?{type:"LineString",coordinates:dr[0]}:{type:"MultiLineString",coordinates:dr}:null})(this[""]),Wi&&(nr.geometry=Wi,Ue.push(nr)));for(let ai of this.nodes)Ai=Ai.concat(ai.toFeatureArray());return Pe.concat(Ue).concat(Ai)}}}})(),fr=(()=>{function gt(ct){return ct.match(/^(.+?)\[(.+?)\]>$/g)!=null}function bt(ct){let Bt=/^(.+?)\[(.+?)\]>$/g.exec(ct);return Bt?{evt:Bt[1]+">",exp:Bt[2]}:{evt:ct}}return class{constructor(ct){ct&&(this.queryParent=!!ct.queryParent,this.progressive=ct.progressive,this.queryParent&&(this.parentMap=new WeakMap)),this.evtListeners={}}parse(ct,Bt,Kt){Kt=Kt?Kt+".":"";let Yt=/<([^ >\/]+)(.*?)>/gm,ae=null,we=[];for(;ae=Yt.exec(ct);){let ve=ae[1],Ie={$tag:ve},oe=Kt+ve,ye=ae[2].trim(),Be=!1;(ye.endsWith("/")||ve.startsWith("?")||ve.startsWith("!"))&&(Be=!0);let Re=/([^ ]+?)="(.+?)"/g,Qi=/([^ ]+?)='(.+?)'/g,Ri=null,Pe=!1;for(;Ri=Re.exec(ye);)Pe=!0,Ie[Ri[1]]=Ri[2];if(!Pe)for(;Ri=Qi.exec(ye);)Pe=!0,Ie[Ri[1]]=Ri[2];if(Pe||ye===""||(Ie.text=ye),this.progressive&&this.emit(`<${oe}>`,Ie,Bt),!Be){let Ue=new RegExp(`([^]+?)`,"g");Ue.lastIndex=Yt.lastIndex;let Ai=Ue.exec(ct);if(Ai&&Ai[1]){Yt.lastIndex=Ue.lastIndex;let Fi=this.parse(Ai[1],Ie,oe);Fi.length>0?Ie.$innerNodes=Fi:Ie.$innerText=Ai[1]}}this.queryParent&&Bt&&this.parentMap.set(Ie,Bt),this.progressive&&this.emit(``,Ie,Bt),we.push(Ie)}return we}getParent(ct){return this.queryParent?this.parentMap.get(ct):null}#t(ct,Bt){let Kt=this.evtListeners[ct];Kt?Kt.push(Bt):this.evtListeners[ct]=[Bt]}addListener(ct,Bt){gt(ct)&&(ct=bt(ct),Bt.condition=function(Kt){let Yt="return "+Kt.replace(/(\$.+?)(?=[=!.])/g,"node.$&")+";";return new Function("node",Yt)}(ct.exp),ct=ct.evt),this.#t(ct,Bt)}#e(ct,Bt){let Kt=this.evtListeners[ct],Yt=null;Kt&&(Yt=Kt.indexOf(Bt))>=0&&Kt.splice(Yt,1)}removeListener(ct,Bt){gt(ct)&&(ct=(ct=bt(ct)).evt),this.#e(ct,Bt)}emit(ct,...Bt){let Kt=this.evtListeners[ct];if(Kt)for(let Yt of Kt)Yt.condition?Yt.condition.apply(null,Bt)===!0&&Yt.apply(null,Bt):Yt.apply(null,Bt)}on(ct,Bt){this.addListener(ct,Bt)}off(ct,Bt){this.removeListener(ct,Bt)}}})();let{Node:br,Way:Er,Relation:Dt}=ki,{purgeProps:Ke,RefElements:Te}=zi,or=fr;var Lr=(gt,bt)=>{let ct=!1,Bt=!1,Kt=!0;(ve=>{if(ve){ct=!(!ve.completeFeature&&!ve.allFeatures),Bt=!!ve.renderTagged;let Ie=ve.suppressWay||ve.excludeWay;Ie===void 0||Ie||(Kt=!1)}})(bt);let Yt=(ve=>ve.elements?"json":ve.indexOf("=0?"xml":ve.trim().startsWith("{")?"json-raw":"invalid")(gt),ae=new Te,we=[];Yt==="json-raw"&&(Yt=(gt=JSON.parse(gt)).elements?"json":"invalid"),Yt==="json"?(ve=>{for(let Ie of ve.elements)switch(Ie.type){case"node":let oe=new br(Ie.id,ae);Ie.tags&&oe.addTags(Ie.tags),oe.addProps(Ke(Ie,["id","type","tags","lat","lon"])),oe.setLatLng(Ie);break;case"way":let ye=new Er(Ie.id,ae);if(Ie.tags&&ye.addTags(Ie.tags),ye.addProps(Ke(Ie,["id","type","tags","nodes","geometry"])),Ie.nodes)for(let Re of Ie.nodes)ye.addNodeRef(Re);else Ie.geometry&&ye.setLatLngArray(Ie.geometry);break;case"relation":let Be=new Dt(Ie.id,ae);if(Ie.bounds&&Be.setBounds([parseFloat(Ie.bounds.minlon),parseFloat(Ie.bounds.minlat),parseFloat(Ie.bounds.maxlon),parseFloat(Ie.bounds.maxlat)]),Ie.tags&&Be.addTags(Ie.tags),Be.addProps(Ke(Ie,["id","type","tags","bounds","members"])),Ie.members)for(let Re of Ie.members)Be.addMember(Re)}})(gt):Yt==="xml"&&(ve=>{let Ie=new or({progressive:!0});Ie.on("",oe=>{let ye=new br(oe.id,ae);for(let[Be,Re]of Object.entries(oe))!Be.startsWith("$")&&["id","lon","lat"].indexOf(Be)<0&&ye.addProp(Be,Re);if(ye.setLatLng(oe),oe.$innerNodes)for(let Be of oe.$innerNodes)Be.$tag==="tag"&&ye.addTag(Be.k,Be.v)}),Ie.on("",oe=>{let ye=new Er(oe.id,ae);for(let[Be,Re]of Object.entries(oe))!Be.startsWith("$")&&["id"].indexOf(Be)<0&&ye.addProp(Be,Re);if(oe.$innerNodes)for(let Be of oe.$innerNodes)Be.$tag==="nd"?Be.lon&&Be.lat?ye.addLatLng(Be):Be.ref&&ye.addNodeRef(Be.ref):Be.$tag==="tag"&&ye.addTag(Be.k,Be.v)}),Ie.on("",oe=>{new Dt(oe.id,ae)}),Ie.on("",(oe,ye)=>{let Be=ae.get(`relation/${ye.id}`),Re={type:oe.type,role:oe.role?oe.role:"",ref:oe.ref};if(oe.lat&&oe.lon){Re.lat=oe.lat,Re.lon=oe.lon,Re.tags={};for(let[Qi,Ri]of Object.entries(oe))!Qi.startsWith("$")&&["type","lat","lon"].indexOf(Qi)<0&&(Re[Qi]=Ri)}if(oe.$innerNodes){let Qi=[],Ri=[];for(let Pe of oe.$innerNodes)Pe.lat&&Pe.lon?Qi.push(Pe):Ri.push(Pe.ref);Qi.length>0?Re.geometry=Qi:Ri.length>0&&(Re.nodes=Ri)}Be.addMember(Re)}),Ie.on("",(oe,ye)=>{ae.get(`relation/${ye.id}`).setBounds([parseFloat(oe.minlon),parseFloat(oe.minlat),parseFloat(oe.maxlon),parseFloat(oe.maxlat)])}),Ie.on("",(oe,ye)=>{ae.get(`relation/${ye.id}`).addTag(oe.k,oe.v)}),Ie.parse(ve)})(gt),ae.bindAll();for(let ve of ae.values())if(ve.refCount<=0||ve.hasTag&&Bt&&!(ve instanceof Er&&Kt)){let Ie=ve.toFeatureArray();if(ve instanceof Dt&&!ct&&Ie.length>0)return Ie[0].geometry;we=we.concat(Ie)}return{type:"FeatureCollection",features:we}},Ji=t(Lr);let Zr=["topojson","osm","kml","gpx","tcx","csv","tsv","polyline"];class bs{constructor(bt,ct,Bt={}){this.blankGeoJSON=()=>({type:"FeatureCollection",features:[]}),this._rawData=ct,this._format=bt,this._options=Bt;let Kt={topojson:this.loadTopoJson,osm:this.loadOsm,kml:this.loadXml,gpx:this.loadXml,tcx:this.loadXml,csv:this.loadCsv,tsv:this.loadCsv,polyline:this.loadPolyline};this._conversionFn=Kt[bt]}async convert(){return this._conversionFn?this._conversionFn():new Promise((bt,ct)=>ct(`No converter exists for ${this._format}`))}async loadXml(){return Ni[this._format](new DOMParser().parseFromString(this._rawData,"text/xml"))}async loadCsv(){let bt=this._options.csvOptions||{};return this._format==="tsv"&&(bt.delimiter=" "),await new Promise((ct,Bt)=>{_t.csv2geojson(this._rawData,bt,(Kt,Yt)=>{Kt?Bt(Kt):ct(Yt)})})}async loadTopoJson(){let bt={};try{bt=JSON.parse(this._rawData)}catch{throw"Invalid TopoJson"}let ct=this.blankGeoJSON();return bt.type==="Topology"&&bt.objects!==void 0&&(ct={type:"FeatureCollection",features:ct.features=Object.keys(bt.objects).map(Bt=>{return Kt=bt,typeof(Yt=Bt)=="string"&&(Yt=Kt.objects[Yt]),Yt.type==="GeometryCollection"?{type:"FeatureCollection",features:Yt.geometries.map(function(ae){return ie(Kt,ae)})}:ie(Kt,Yt);var Kt,Yt}).reduce((Bt,Kt)=>[...Bt,...Kt.features],[])}),ct}async loadOsm(){return Ji(this._rawData)}async loadPolyline(){let bt=this._options.polylineOptions||{};return await new Promise((ct,Bt)=>{try{let Kt=rr.toGeoJSON(this._rawData,bt.precision),Yt=Kt;bt.type==="point"?Kt.coordinates.length===1?Yt={type:"Point",coordinates:Kt.coordinates[0]}:console.warn("Cannot convert polyline to "+bt.type):bt.type==="polygon"&&(Kt.coordinates[0][0]===Kt.coordinates[Kt.coordinates.length-1][0]&&Kt.coordinates[0][1]===Kt.coordinates[Kt.coordinates.length-1][1]?Yt={type:"Polygon",coordinates:[Kt.coordinates]}:console.warn("Cannot convert polyline to "+bt.type)),ct({type:"FeatureCollection",features:[{type:"Feature",geometry:Yt,properties:bt.properties||{}}]})}catch(Kt){Bt(Kt)}})}}var Sr=null;try{var xr=typeof md<"u"&&typeof md.require=="function"&&gd("worker_threads")||typeof __non_webpack_require__=="function"&&__non_webpack_require__("worker_threads")||typeof gd=="function"&&gd("worker_threads");Sr=xr.Worker}catch{}function Wo(gt,bt,ct){var Bt=function(ae,we){return Buffer.from(ae,"base64").toString("utf8")}(gt),Kt=Bt.indexOf(` +`,10)+1,Yt=Bt.substring(Kt)+"";return function(ae){return new Sr(Yt,Object.assign({},ae,{eval:!0}))}}function an(gt,bt,ct){var Bt=function(we,ve){return atob(we)}(gt),Kt=Bt.indexOf(` +`,10)+1,Yt=Bt.substring(Kt)+"",ae=new Blob([Yt],{type:"application/javascript"});return URL.createObjectURL(ae)}var Kn=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Oo,Gs=(Oo="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewoJJ3VzZ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U6IHF1b3RlcwoJICAgICAgdmFyIGogPSBJLCBjOwoJICAgICAgaWYgKHRleHQuY2hhckNvZGVBdChqKSA9PT0gMzQpIHsKCSAgICAgICAgdmFyIGkgPSBqOwoJICAgICAgICB3aGlsZSAoaSsrIDwgTikgewoJICAgICAgICAgIGlmICh0ZXh0LmNoYXJDb2RlQXQoaSkgPT09IDM0KSB7CgkgICAgICAgICAgICBpZiAodGV4dC5jaGFyQ29kZUF0KGkgKyAxKSAhPT0gMzQpIGJyZWFrOwoJICAgICAgICAgICAgKytpOwoJICAgICAgICAgIH0KCSAgICAgICAgfQoJICAgICAgICBJID0gaSArIDI7CgkgICAgICAgIGMgPSB0ZXh0LmNoYXJDb2RlQXQoaSArIDEpOwoJICAgICAgICBpZiAoYyA9PT0gMTMpIHsKCSAgICAgICAgICBlb2wgPSB0cnVlOwoJICAgICAgICAgIGlmICh0ZXh0LmNoYXJDb2RlQXQoaSArIDIpID09PSAxMCkgKytJOwoJICAgICAgICB9IGVsc2UgaWYgKGMgPT09IDEwKSB7CgkgICAgICAgICAgZW9sID0gdHJ1ZTsKCSAgICAgICAgfQoJICAgICAgICByZXR1cm4gdGV4dC5zbGljZShqICsgMSwgaSkucmVwbGFjZSgvIiIvZywgIlwiIik7CgkgICAgICB9CgoJICAgICAgLy8gY29tbW9uIGNhc2U6IGZpbmQgbmV4dCBkZWxpbWl0ZXIgb3IgbmV3bGluZQoJICAgICAgd2hpbGUgKEkgPCBOKSB7CgkgICAgICAgIHZhciBrID0gMTsKCSAgICAgICAgYyA9IHRleHQuY2hhckNvZGVBdChJKyspOwoJICAgICAgICBpZiAoYyA9PT0gMTApIGVvbCA9IHRydWU7IC8vIFxuCgkgICAgICAgIGVsc2UgaWYgKGMgPT09IDEzKSB7IGVvbCA9IHRydWU7IGlmICh0ZXh0LmNoYXJDb2RlQXQoSSkgPT09IDEwKSArK0ksICsrazsgfSAvLyBccnxcclxuCgkgICAgICAgIGVsc2UgaWYgKGMgIT09IGRlbGltaX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9kZXRlY3QgZGVsaW1pdGVyJwoJICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICByZXR1cm47CgkgICAgICAgIH0KCSAgICB9CgoJICAgIHZhciBudW1lcmljRmllbGRzID0gb3B0aW9ucy5udW1lcmljRmllbGRzID8gb3B0aW9ucy5udW1lcmljRmllbGRzLnNwbGl0KCcsJykgOiBudWxsOwoKCSAgICB2YXIgcGFyc2VkID0gKHR5cGVvZiB4ID09ICdzdHJpbmcnKSA/CgkgICAgICAgIGRzdi5kc3ZGb3JtYXQob3B0aW9ucy5kZWxpbWl0ZXIpLnBhcnNlKHgsIGZ1bmN0aW9uIChkKSB7CgkgICAgICAgICAgICBpZiAobnVtZXJpY0ZpZWxkcykgewoJICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBkKSB7CgkgICAgICAgICAgICAgICAgICAgIGlmIChudW1lcmljRmllbGRzLmluY2x1ZGVzKGtleSkpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGRba2V5XSA9ICtkW2tleV07CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9CgkgICAgICAgICAgICByZXR1cm4gZDsKCSAgICAgICAgfSkgOiB4OwoKCSAgICBpZiAoIXBhcnNlZC5sZW5ndGgpIHsKCSAgICAgICAgY2FsbGJhY2sobnVsbCwgZmVhdHVyZWNvbGxlY3Rpb24pOwoJICAgICAgICByZXR1cm47CgkgICAgfQoKCSAgICB2YXIgZXJyb3JzID0gW107CgkgICAgdmFyIGk7CgoKCSAgICBpZiAoIWxhdGZpZWxkKSBsYXRmaWVsZCA9IGd1ZXNzTGF0SGVhZGVyKHBhcnNlZFswXSk7CgkgICAgaWYgKCFsb25maWVsZCkgbG9uZmllbGQgPSBndWVzc0xvbkhlYWRlcihwYXJzZWRbMF0pOwoJICAgIHZhciBub0dlb21ldHJ5ID0gKCFsYXRmaWVsZCB8fCAhbG9uZmllbGQpOwoKCSAgICBpZiAobm9HZW9tZXRyeSkgewoJICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGFyc2VkLmxlbmd0aDsgaSsrKSB7CgkgICAgICAgICAgICBmZWF0dXJlcy5wdXNoKHsKCSAgICAgICAgICAgICAgICB0eXBlOiAnRmVhdHVyZScsCgkgICAgICAgICAgICAgICAgcHJvcGVydGllczogcGFyc2VkW2ldLAoJICAgICAgICAgICAgICAgIGdlb21ldHJ5OiBudWxsCgkgICAgICAgICAgICB9KTsKCSAgICAgICAgfQoJICAgICAgICBjYWxsYmFjayhlcnJvcnMubGVuZ3RoID8gZXJyb3JzIDogbnVsbCwgZmVhdHVyZWNvbGxlY3Rpb24pOwoJICAgICAgICByZXR1cm47CgkgICAgfQoKCSAgICBmb3IgKGkgPSAwOyBpIDwgcGFyc2VkLmxlbmd0aDsgaSsrKSB7CgkgICAgICAgIGlmIChwYXJzZWRbaV1bbG9uZmllbGRdICE9PSB1bmRlZmluZWQgJiYKCSAgICAgICAgICAgIHBhcnNlZFtpXVtsYXRmaWVsZF0gIT09IHVuZGVmaW5lZCkgewoKCSAgICAgICAgICAgIHZhciBsb25rID0gcGFyc2VkW2ldW2xvbmZpZWxkXSwKCSAgICAgICAgICAgICAgICBsYXRrID0gcGFyc2VkW2ldW2xhdGZpZWxkXSwKCSAgICAgICAgICAgICAgICBsb25mLCBsYXRmLAoJICAgICAgICAgICAgICAgIGE7CgoJICAgICAgICAgICAgYSA9IHNleGFnZXNpbWFsKGxvbmssICdFVycpOwoJICAgICAgICAgICAgaWYgKGEpIGxvbmsgPSBhOwoJICAgICAgICAgICAgYSA9IHNleGFnZXNpbWFsKGxhdGssICdOUycpOwoJICAgICAgICAgICAgaWYgKGEpIGxhdGsgPSBhOwoKCSAgICAgICAgICAgIGxvbmYgPSBwYXJzZUZsb2F0KGxvbmspOwoJICAgICAgICAgICAgbGF0ZiA9IHBhcnNlRmxvYXQobGF0ayk7CgoJICAgICAgICAgICAgaWYgKGlzTmFOKGxvbmYpIHx8CgkgICAgICAgICAgICAgICAgaXNOYU4obGF0ZikpIHsKCSAgICAgICAgICAgICAgICBlcnJvcnMucHVzaCh7CgkgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2U6ICdBIHJvdyBjb250YWluZWQgYW4gaW52YWxpZCB2YWx1ZSBmb3IgbGF0aXR1ZGUgb3IgbG9uZ2l0dWRlJywKCSAgICAgICAgICAgICAgICAgICAgcm93OiBwYXJzZWRbaV0sCgkgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpCgkgICAgICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICB9IGVsc2UgewoJICAgICAgICAgICAgICAgIGlmICghb3B0aW9ucy5pbmNsdWRlTGF0TG9uKSB7CgkgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwYXJzZWRbaV1bbG9uZmllbGRdOwoJICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGFyc2VkW2ldW2xhdGZpZWxkXTsKCSAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgIGZlYXR1cmVzLnB1c2goewoJICAgICAgICAgICAgICAgICAgICB0eXBlOiAnRmVhdHVyZScsCgkgICAgICAgICAgICAgICAgICAgIHByb3BlcnRpZXM6IHBhcnNlZFtpXSwKCSAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cnk6IHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6ICdQb2ludCcsCgkgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlczogWwoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlRmxvYXQobG9uZiksCgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VGbG9hdChsYXRmKQoJICAgICAgICAgICAgICAgICAgICAgICAgXQoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCSAgICB9CgoJICAgIGNhbGxiYWNrKGVycm9ycy5sZW5ndGggPyBlcnJvcnMgOiBudWxsL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HRvUG9seWdvbihnaikgewoJICAgIHZhciBmZWF0dXJlcyA9IGdqLmZlYXR1cmVzOwoJICAgIHZhciBwb2x5ID0gewoJICAgICAgICB0eXBlOiAnRmVhdHVyZScsCgkgICAgICAgIGdlb21ldHJ5OiB7CgkgICAgICAgICAgICB0eXBlOiAnUG9seWdvbicsCgkgICAgICAgICAgICBjb29yZGluYXRlczogW1tdXQoJICAgICAgICB9CgkgICAgfTsKCSAgICBmb3IgKHZhciBpID0gMDsgaSA8IGZlYXR1cmVzLmxlbmd0aDsgaSsrKSB7CgkgICAgICAgIHBvbHkuZ2VvbWV0cnkuY29vcmRpbmF0ZXNbMF0ucHVzaChmZWF0dXJlc1tpXS5nZW9tZXRyeS5jb29yZGluYXRlcyk7CgkgICAgfQoJICAgIHBvbHkucHJvcGVydGllcyA9IGZlYXR1cmVzLnJlZHVjZShmdW5jdGlvbiAoYWdncmVnYXRlZFByb3BlcnRpZXMsIG5ld0ZlYXR1cmUpIHsKCSAgICAgICAgZm9yICh2YXIga2V5IGluIG5ld0ZlYXR1cmUucHJvcGVydGllcykgewoJICAgICAgICAgICAgaWYgKCFhZ2dyZWdhdGVkUHJvcGVydGllc1trZXldKSB7CgkgICAgICAgICAgICAgICAgYWdncmVnYXRlZFByb3BlcnRpZXNba2V5XSA9IFtdOwoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgYWdncmVnYXRlZFByb3BlcnRpZXNba2V5XS5wdXNoKG5ld0ZlYXR1cmUucHJvcGVydGllc1trZXldKTsKCSAgICAgICAgfQoJICAgICAgICByZXR1cm4gYWdncmVnYXRlZFByb3BlcnRpZXM7CgkgICAgfSwge30pOwoJICAgIHJldHVybiB7CgkgICAgICAgIHR5cGU6ICdGZWF0dXJlQ29sbGVjdGlvbicsCgkgICAgICAgIGZlYXR1cmVzOiBbcG9seV0KCSAgICB9OwoJfQoKCXZhciBjc3YyZ2VvanNvbl8xID0gewoJICAgIGlzTG9uOiBpc0xvbiwKCSAgICBpc0xhdDogaX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aW5lU3R5bGUoZ2V0MShub2RlLCAiZXh0ZW5zaW9ucyIpKSwgdGltZXMubGVuZ3RoCgkgICAgICAgID8gewoJICAgICAgICAgICAgY29vcmRpbmF0ZVByb3BlcnRpZXM6IHsKCSAgICAgICAgICAgICAgICB0aW1lczogbXVsdGkgPyB0aW1lcyA6IHRpbWVzWzBdLAoJICAgICAgICAgICAgfSwKCSAgICAgICAgfQoJICAgICAgICA6IHt9KTsKCSAgICBmb3IgKGNvbnN0IGxpbmUgb2YgZXh0cmFjdGVkTGluZXMpIHsKCSAgICAgICAgdHJhY2sucHVzaChsaW5lLmxpbmUpOwoJICAgICAgICBpZiAoIXByb3BlcnRpZXMuY29vcmRpbmF0ZVByb3BlcnRpZXMpIHsKCSAgICAgICAgICAgIHByb3BlcnRpZXMuY29vcmRpbmF0ZVByb3BlcnRpZXMgPSB7fTsKCSAgICAgICAgfQoJICAgICAgICBjb25zdCBwcm9wcyA9IHByb3BlcnRpZXMuY29vcmRpbmF0ZVByb3BlcnRpZXM7CgkgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhsaW5lLmV4dGVuZGVkVmFsdWVzKTsKCSAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBlbnRyaWVzLmxlbmd0aDsgaSsrKSB7CgkgICAgICAgICAgICBjb25zdCBbbmFtZSwgdmFsXSA9IGVudHJpZXNbaV07CgkgICAgICAgICAgICBpZiAobXVsdGkpIHsKCSAgICAgICAgICAgICAgICBpZiAoIXByb3BzW25hbWVdKSB7CgkgICAgICAgICAgICAgICAgICAgIHByb3BzW25hbWVdID0gZXh0cmFjdGVkTGluZXMubWFwKChsaW5lKSA9PiBuZXcgQXJyYXkobGluZS5saW5lLmxlbmd0aCkuZmlsbChudWxsKSk7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIHByb3BzW25hbWVdW2ldID0gdmFsOwoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgZWxzZSB7CgkgICAgICAgICAgICAgICAgcHJvcHNbbmFtZV0gPSB2YWw7CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCSAgICB9CgkgICAgcmV0dXJuIHsKCSAgICAgICAgdHlwZTogIkZlYXR1cmUiLAoJICAgICAgICBwcm9wZXJ0aWVzOiBwcm9wZXJ0aWVzLAoJICAgICAgICBnZW9tZXRyeTogbXVsdGkKCSAgICAgICAgICAgID8gewoJICAgICAgICAgICAgICAgIHR5cGU6ICJNdWx0aUxpbmVTdHJpbmciLAoJICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiB0cmFjaywKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIDogewoJICAgICAgICAgICAgICAgIHR5cGU6ICJMaW5lU3RyaW5nIiwKCSAgICAgICAgICAgICAgICBjb29yZGluYXRlczogdHJhY2tbMF0sCgkgICAgICAgICAgICB9LAoJICAgIH07Cgl9CgkvKioKCSAqIEV4dHJhY3QgYSBwb2ludCwgaWYgcG9zc2libGUsIGZyb20gYSBnaXZlbiBub2RlLAoJICogd2hpY2ggaXMgdXN1YWxseSBhIHdwdCBvciB0cmtwdAoJICovCglmdW5jdGlvbiBnZXRQb2ludChub2RlKSB7CgkgICAgY29uc3QgcHJvcGVydGllcyA9IE9iamVjdC5hc3NpZ24oZXh0cmFjdFByb3BlcnRpZXMobm9kZSksIGdldE11bHRpKG5vZGUsIFsic3ltIl0pKTsKCSAgICBjb25zdCBwYWlyID0gY29vcmRQYWlyJDEobm9kZSk7CgkgICAgaWYgKCFwYWlyKQoJICAgICAgICByZXR1cm4gbnVsbDsKCSAgICByZXR1cm4gewoJICAgICAgICB0eXBlOiAiRmVhdHVyZSIsCgkgICAgICAgIHByb3BlcnRpZXMsCgkgICAgICAgIGdlb21ldHJ5OiB7CgkgICAgICAgICAgICB0eXBlOiAiUG9pbnQiLAoJICAgICAgICAgICAgY29vcmRpbmF0ZXM6IHBhaXIuY29vcmRpbmF0ZXMsCgkgICAgICAgIH0sCgkgICAgfTsK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UmF0ZXMucHVzaChsaW5lLmhlYXJ0UmF0ZXMpOwoJICAgICAgICAgICAgYWxsRXh0ZW5kZWRQcm9wZXJ0aWVzLnB1c2gobGluZS5leHRlbmRlZFByb3BlcnRpZXMpOwoJICAgICAgICB9CgkgICAgfQoJICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYWxsRXh0ZW5kZWRQcm9wZXJ0aWVzLmxlbmd0aDsgaSsrKSB7CgkgICAgICAgIGNvbnN0IGV4dGVuZGVkUHJvcGVydGllcyA9IGFsbEV4dGVuZGVkUHJvcGVydGllc1tpXTsKCSAgICAgICAgZm9yIChjb25zdCBwcm9wZXJ0eSBpbiBleHRlbmRlZFByb3BlcnRpZXMpIHsKCSAgICAgICAgICAgIGlmIChzZWdtZW50cy5sZW5ndGggPT09IDEpIHsKCSAgICAgICAgICAgICAgICBpZiAobGluZSkgewoJICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzW3Byb3BlcnR5XSA9IGxpbmUuZXh0ZW5kZWRQcm9wZXJ0aWVzW3Byb3BlcnR5XTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9CgkgICAgICAgICAgICBlbHNlIHsKCSAgICAgICAgICAgICAgICBpZiAoIXByb3BlcnRpZXNbcHJvcGVydHldKSB7CgkgICAgICAgICAgICAgICAgICAgIHByb3BlcnRpZXNbcHJvcGVydHldID0gdHJhY2subWFwKCh0cmFjaykgPT4gQXJyYXkodHJhY2subGVuZ3RoKS5maWxsKG51bGwpKTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgcHJvcGVydGllc1twcm9wZXJ0eV1baV0gPSBleHRlbmRlZFByb3BlcnRpZXNbcHJvcGVydHldOwoJICAgICAgICAgICAgfQoJICAgICAgICB9CgkgICAgfQoJICAgIGlmICh0cmFjay5sZW5ndGggPT09IDApCgkgICAgICAgIHJldHVybiBudWxsOwoJICAgIGlmICh0aW1lcy5sZW5ndGggfHwgaGVhcnRSYXRlcy5sZW5ndGgpIHsKCSAgICAgICAgcHJvcGVydGllcy5jb29yZGluYXRlUHJvcGVydGllcyA9IE9iamVjdC5hc3NpZ24odGltZXMubGVuZ3RoCgkgICAgICAgICAgICA/IHsKCSAgICAgICAgICAgICAgICB0aW1lczogdHJhY2subGVuZ3RoID09PSAxID8gdGltZXNbMF0gOiB0aW1lcywKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIDoge30sIGhlYXJ0UmF0ZXMubGVuZ3RoCgkgICAgICAgICAgICA/IHsKCSAgICAgICAgICAgICAgICBoZWFydDogdHJhY2subGVuZ3RoID09PSAxID8gaGVhcnRSYXRlc1swXSA6IGhlYXJ0UmF0ZXMsCgkgICAgICAgICAgICB9CgkgICAgICAgICAgICA6IHt9KTsKCSAgICB9CgkgICAgcmV0dXJuIHsKCSAgICAgICAgdHlwZTogIkZlYXR1cmUiLAoJICAgICAgICBwcm9wZXJ0aWVzOiBwcm9wZXJ0aWVzLAoJICAgICAgICBnZW9tZXRyeTogdHJhY2subGVuZ3RoID09PSAxCgkgICAgICAgICAgICA/IHsKCSAgICAgICAgICAgICAgICB0eXBlOiAiTGluZVN0cmluZyIsCgkgICAgICAgICAgICAgICAgY29vcmRpbmF0ZXM6IHRyYWNrWzBdLAoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgOiB7CgkgICAgICAgICAgICAgICAgdHlwZTogIk11bHRpTGluZVN0cmluZyIsCgkgICAgICAgICAgICAgICAgY29vcmRpbmF0ZXM6IHRyYWNrLAoJICAgICAgICAgICAgfSwKCSAgICB9OwoJfQoJLyoqCgkgKiBJbmNyZW1lbnRhbGx5IGNvbnZlcnQgYSBUQ1ggZG9jdW1lbnQgdG8gR2VvSlNPTi4gVGhlCgkgKiBmaXJzdCBhcmd1bWVudCwgYGRvY2AsIG11c3QgYmUgYSBUQ1gKCSAqIGRvY3VtZW50IGFzIGFuIFhNTCBET00gLSBub3QgYXMgYSBzdHJpbmcuCgkgKi8KCWZ1bmN0aW9uKiB0Y3hHZW4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GUpIHsKCSAgICByZXR1cm4gZ2V0KG5vZGUsICJJY29uU3R5bGUiLCAoaWNvblN0eWxlKSA9PiB7CgkgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGdldENvbG9yKGljb25TdHlsZSwgImljb24iKSwgbnVtZXJpY1Byb3BlcnR5KGljb25TdHlsZSwgInNjYWxlIiwgImljb24tc2NhbGUiKSwgbnVtZXJpY1Byb3BlcnR5KGljb25TdHlsZSwgImhlYWRpbmciLCAiaWNvbi1oZWFkaW5nIiksIGdldChpY29uU3R5bGUsICJob3RTcG90IiwgKGhvdHNwb3QpID0+IHsKCSAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBwYXJzZUZsb2F0KGhvdHNwb3QuZ2V0QXR0cmlidXRlKCJ4IikgfHwgIiIpOwoJICAgICAgICAgICAgY29uc3QgdG9wID0gcGFyc2VGbG9hdChob3RzcG90LmdldEF0dHJpYnV0ZSgieSIpIHx8ICIiKTsKCSAgICAgICAgICAgIGNvbnN0IHh1bml0cyA9IGhvdHNwb3QuZ2V0QXR0cmlidXRlKCJ4dW5pdHMiKSB8fCAiIjsKCSAgICAgICAgICAgIGNvbnN0IHl1bml0cyA9IGhvdHNwb3QuZ2V0QXR0cmlidXRlKCJ5dW5pdHMiKSB8fCAiIjsKCSAgICAgICAgICAgIGlmICghaXNOYU4obGVmdCkgJiYgIWlzTmFOKHRvcCkpCgkgICAgICAgICAgICAgICAgcmV0dXJuIHsKCSAgICAgICAgICAgICAgICAgICAgImljb24tb2Zmc2V0IjogW2xlZnQsIHRvcF0sCgkgICAgICAgICAgICAgICAgICAgICJpY29uLW9mZnNldC11bml0cyI6IFt4dW5pdHMsIHl1bml0c10sCgkgICAgICAgICAgICAgICAgfTsKCSAgICAgICAgICAgIHJldHVybiB7fTsKCSAgICAgICAgfSksIGV4dHJhY3RJY29uSHJlZihpY29uU3R5bGUpKTsKCSAgICB9KTsKCX0KCWZ1bmN0aW9uIGV4dHJhY3RMYWJlbChub2RlKSB7Cg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IiI7CgkgICAgICAgICAgICBjb25zdCB0eXBlQ29udmVydGVyID0gc2NoZW1hW25hbWVdIHx8IHR5cGVDb252ZXJ0ZXJzLnN0cmluZzsKCSAgICAgICAgICAgIHByb3BlcnRpZXNbbmFtZV0gPSB0eXBlQ29udmVydGVyKG5vZGVWYWwoc2ltcGxlRGF0YSkpOwoJICAgICAgICB9CgkgICAgICAgIHJldHVybiBwcm9wZXJ0aWVzOwoJICAgIH0pOwoJfQoJZnVuY3Rpb24gZ2V0TWF5YmVIVE1MRGVzY3JpcHRpb24obm9kZSkgewoJICAgIGNvbnN0IGRlc2NyaXB0aW9uTm9kZSA9IGdldDEobm9kZSwgImRlc2NyaXB0aW9uIik7CgkgICAgZm9yIChjb25zdCBjIG9mIEFycmF5LmZyb20oZGVzY3JpcHRpb25Ob2RlPy5jaGlsZE5vZGVzIHx8IFtdKSkgewoJICAgICAgICBpZiAoYy5ub2RlVHlwZSA9PT0gNCkgewoJICAgICAgICAgICAgcmV0dXJuIHsKCSAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbjogewoJICAgICAgICAgICAgICAgICAgICAiQHR5cGUiOiAiaHRtbCIsCgkgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBub2RlVmFsKGMpLAoJICAgICAgICAgICAgICAgIH0sCgkgICAgICAgICAgICB9OwoJICAgICAgICB9CgkgICAgfQoJICAgIHJldHVybiB7fTsKCX0KCWZ1bmN0aW9uIGV4dHJhY3RUaW1lU3Bhbihub2RlKSB7CgkgICAgcmV0dXJuIGdldChub2RlLCAiVGltZVNwYW4iLCAodGltZVNwYW4pID0+IHsKCSAgICAgICAgcmV0dXJuIHsKCSAgICAgICAgICAgIHRpbWVzcGFuOiB7CgkgICAgICAgICAgICAgICAgYmVnaW46IG5vZGVWYWwoZ2V0MSh0aW1lU3BhbiwgImJlZ2luIikpLAoJICAgICAgICAgICAgICAgIGVuZDogbm9kZVZhbChnZXQxKHRpbWVTcGFuLCAiZW5kIikpLAoJICAgICAgICA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AgICAgICAgICAgICAgICBjb29yZGluYXRlcywKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIDogewoJICAgICAgICAgICAgICAgIHR5cGU6ICJQb2ludCIsCgkgICAgICAgICAgICAgICAgY29vcmRpbmF0ZXM6IGNvb3JkaW5hdGVzWzBdLAoJICAgICAgICAgICAgfSwKCSAgICAgICAgdGltZXM6ICQobm9kZSwgIndoZW4iKS5tYXAoKGVsZW0pID0+IG5vZGVWYWwoZWxlbSkpLAoJICAgIH07Cgl9CglmdW5jdGlvbiBmaXhSaW5nKHJpbmcpIHsKCSAgICBpZiAocmluZy5sZW5ndGggPT09IDApCgkgICAgICAgIHJldHVybiByaW5nOwoJICAgIGNvbnN0IGZpcnN0ID0gcmluZ1swXTsKCSAgICBjb25zdCBsYXN0ID0gcmluZ1tyaW5nLmxlbmd0aCAtIDFdOwoJICAgIGxldCBlcXVhbCA9IHRydWU7CgkgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBNYXRoLm1heChmaXJzdC5sZW5ndGgsIGxhc3QubGVuZ3RoKTsgaSsrKSB7CgkgICAgICAgIGlmIChmaXJzdFtpXSAhPT0gbGFzdFtpXSkgewoJICAgICAgICAgICAgZXF1YWwgPSBmYWxzZTsKCSAgICAgICAgICAgIGJyZWFrOwoJICAgICAgICB9CgkgICAgfQoJICAgIGlmICghZXF1YWwpIHsKCSAgICAgICAgcmV0dXJuIHJpbmcuY29uY2F0KFtyaW5nWzBdXSk7CgkgICAgfQoJICAgIHJldHVybiByaW5nOwoJfQoJZnVuY3Rpb24gZ2V0Q29vcmRpbmF0ZXMobm9kZSkgewoJICAgIHJldHVybiBub2RlVmFsKGdldDEobm9kZSwgImNvb3JkaW5hdGVzIikpOwoJfQoJZnVuY3Rpb24gZ2V0R2VvbWV0cnkobm9kZSkgewoJICAgIGxldCBnZW9tZXRyaWVzID0gW107CgkgICAgbGV0IGNvb3JkVGltZXMgPSBbXTsKCSAgICBmb3IgKGxldCBpID0gMDsgaSA8IG5vZGUuY2hpbGROb2Rlcy5sZW5ndGg7IGkrKykgewoJICAgICAgICBjb25zdCBjaGlsZCA9IG5vZGUuY2hpbGROb2Rlcy5pdGVtKGkpOwoJICAgICAgICBpZiAoaXNFbGVtZW50KGNoaWxkKSkgewoJICAgICAgICAgICAgc3dpdGNoIChjaGlsZC50YWdOYW1lKSB7CgkgICAgICAgICAgICAgICAgY2FzZSAiTXVsdGlHZW9tZXRyeSI6CgkgICAgICAgICAgICAgICAgY2FzZSAiTXVsdGlUcmFjayI6CgkgICAgICAgICAgICAgICAgY2FzZSAiZ3g6TXVsdGlUcmFjayI6IHsKCSAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGRHZW9tZXRyaWVzID0gZ2V0R2VvbWV0cnkoY2hpbGQpOwoJICAgICAgICAgICAgICAgICAgICBnZW9tZXRyaWVzID0gZ2VvbWV0cmllcy5jb25jYXQoY2hpbGRHZW9tZXRyaWVzLmdlb21ldHJpZXMpOwoJICAgICAgICAgICAgICAgICAgICBjb29yZFRpbWVzID0gY29vcmRUaW1lcy5jb25jYXQoY2hpbGRHZW9tZXRyaWVzLmNvb3JkVGltZXMpOwoJICAgICAgICAgICAgICAgICAgICBicmVhazsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgY2FzZSAiUG9pbnQiOiB7CgkgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvb3JkaW5hdGVzID0gY29vcmQxKGdldENvb3JkaW5hdGVzKGNoaWxkKSk7CgkgICAgICAgICAgICAgICAgICAgIGlmIChjb29yZGluYXRlcy5sZW5ndGggPj0gMikgewoJICAgICAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cmllcy5wdXNoKHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiAiUG9pbnQiLAoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzLAoJICAgICAgICAgICAgICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIGNhc2UgIkxpbmVhclJpbmciOgoJICAgICAgICAgICAgICAgIGNhc2UgIkxpbmVTdHJpbmciOiB7CgkgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvb3JkaW5hdGVzID0gY29vcmQoZ2V0Q29vcmRpbmF0ZXMoY2hpbGQpKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGNvb3JkaW5hdGVzLmxlbmd0aCA+PSAyKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBnZW9tZXRyaWVzLnB1c2goewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6ICJMaW5lU3RyaW5nIiwKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlcywKCSAgICAgICAgICAgICAgICAgICAgICAgIH0pOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGJyZWFrOwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICBjYXNlICJQb2x5Z29uIjogewoJICAgICAgICAgICAgICAgICAgICBjb25zdCBjb29yZHMgPSBbXTsKCSAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsaW5lYXJSaW5nIG9mICQoY2hpbGQsICJMaW5lYXJSaW5nIikpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJpbmcgPSBmaXhSaW5nKGNvb3JkKGdldENvb3JkaW5hdGVzKGxpbmVhclJpbmcpKSk7CgkgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmluZy5sZW5ndGggPj0gNCkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvb3Jkcy5wdXNoKHJpbmcpOwoJICAgICAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGlmIChjb29yZHMubGVuZ3RoKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBnZW9tZXRyaWVzLnB1c2goewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6ICJQb2x5Z29uIiwKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlczogY29vcmRzLAoJICAgICAgICAgICAgICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIGNhc2UgIlRyYWNrIjoKCSAgICAgICAgICAgICAgICBjYXNlICJneDpUcmFjayI6IHsKCSAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3ggPSBneENvb3JkcyhjaGlsZCk7CgkgICAgICAgICAgICAgICAgICAgIGlmICghZ3gpCgkgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKCSAgICAgICAgICAgICAgICAgICAgY29uc3QgeyB0aW1lcywgZ2VvbWV0cnkgfSA9IGd4OwoJICAgICAgICAgICAgICAgICAgICBnZW9tZXRyaWVzLnB1c2goZ2VvbWV0cnkpOwoJICAgICAgICAgICAgICAgICAgICBpZiAodGltZXMubGVuZ3RoKQoJICAgICAgICAgICAgICAgICAgICAgICAgY29vcmRUaW1lcy5wdXNoKHRpbWVzKTsKCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoJICAgICAgICB9CgkgICAgfQoJICAgIHJldHVybiB7CgkgICAgICAgIGdlb21ldHJpZXMsCgkgICAgICAgIGNvb3JkVGltZXMsCgkgICAgfTsKCX0KCglmdW5jdGlvbiBnZW9tZXRyeUxpc3RUb0dlb21ldHJ5KGdlb21ldHJpZXMpIHsKCSAgICByZXR1cm4gZ2VvbWV0cmllcy5sZW5ndGggPT09IDAKCSAgICAgICAgPyBudWxsCgkgICAgICAgIDogZ2VvbWV0cmllcy5sZW5ndGggPT09IDEKCSAgICAgICAgICAgID8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mRUaW1lcy5sZW5ndGgKCSAgICAgICAgICAgID8gewoJICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVQcm9wZXJ0aWVzOiB7CgkgICAgICAgICAgICAgICAgICAgIHRpbWVzOiBjb29yZFRpbWVzLmxlbmd0aCA9PT0gMSA/IGNvb3JkVGltZXNbMF0gOiBjb29yZFRpbWVzLAoJICAgICAgICAgICAgICAgIH0sCgkgICAgICAgICAgICB9CgkgICAgICAgICAgICA6IHt9KSwKCSAgICB9OwoJICAgIGlmIChmZWF0dXJlLnByb3BlcnRpZXM/LnZpc2liaWxpdHkgIT09IHVuZGVmaW5lZCkgewoJICAgICAgICBmZWF0dXJlLnByb3BlcnRpZXMudmlzaWJpbGl0eSA9IGZlYXR1cmUucHJvcGVydGllcy52aXNpYmlsaXR5ICE9PSAiMCI7CgkgICAgfQoJICAgIGNvbnN0IGlkID0gbm9kZS5nZXRBdHRyaWJ1dGUoImlkIik7CgkgICAgaWYgKGlkICE9PSBudWxsICYmIGlkICE9PSAiIikKCSAgICAgICAgZmVhdHVyZS5pZCA9IGlkOwoJICAgIHJldHVybiBmZWF0dXJlOwoJfQoKCWZ1bmN0aW9uIGdldEdyb3VuZE92ZXJsYXlCb3gobm9kZSkgewoJICAgIGNvbnN0IGxhdExvblF1YWQgPSBnZXQxKG5vZGUsICJneDpMYXRMb25RdWFkIik7CgkgICAgaWYgKGxhdExvblF1YWQpIHsKCSAgICAgICAgY29uc3QgcmluZyA9IGZpeFJpbmcoY29vcmQoZ2V0Q29vcmRpbmF0ZXMobm9kZSkpKTsKCSAgICAgICAgcmV0dXJuIHsKCSAgICAgICAgICAgIGdlb21ldHJ5OiB7CgkgICAgICAgICAgICAgICAgdHlwZTogIlBvbHlnb24iLAoJICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiBbcmluZ10sCgkgICAgICAgICAgICB9LAoJICAgICAgICB9OwoJICAgIH0KCSAgICByZXR1cm4gZ2V0TGF0TG9uQm94KG5vZGUpOwoJfQoJY29uc3QgREVHUkVFU19UT19SQURJQU5TID0gTWF0aC5QSSAvIDE4MDsKCWZ1bmN0aW9uIHJvdGF0ZUJveChiYm94LCBjb29yZGluYXRlcywgcm90YXRpb24pIHsKCSAgICBjb25zdCBjZW50ZXIgPSBbKGJib3hbMF0gKyBiYm94WzJdKSAvIDIsIChiYm94WzFdICsgYmJveFszXSkgLyAyXTsKCSAgICByZXR1cm4gWwoJICAgICAgICBjb29yZGluYXRlc1swXS5tYXAoKGNvb3JkaW5hdGUpID0+IHsKCSAgICAgICAgICAgIGNvbnN0IGR5ID0gY29vcmRpbmF0ZVsxXSAtIGNlbnRlclsxXTsKCSAgICAgICAgICAgIGNvbnN0IGR4ID0gY29vcmRpbmF0ZVswXSAtIGNlbnRlclswXTsKCSAgICAgICAgICAgIGNvbnN0IGRpc3RhbmNlID0gTWF0aC5zcXJ0KE1hdGgucG93KGR5LCAyKSArIE1hdGgucG93KGR4LCAyKSk7CgkgICAgICAgICAgICBjb25zdCBhbmdsZSA9IE1hdGguYXRhbjIoZHksIGR4KSArIHJvdGF0aW9uICogREVHUkVFU19UT19SQURJQU5TOwoJICAgICAgICAgICAgcmV0dXJuIFsKCSAgICAgICAgICAgICAgICBjZW50ZXJbMF0gKyBNYXRoLmNvcyhhbmdsZSkgKiBkaXN0YW5jZSwKCSAgICAgICAgICAgICAgICBjZW50ZXJbMV0gKyBNYXRoLnNpbihhbmdsZSkgKiBkaXN0YW5jZSwKCSAgICAgICAgICAgIF07CgkgICAgICAgIH0pLAoJICAgIF07Cgl9CglmdW5jdGlvbiBnZXRMYXRMb25Cb3gobm9kZSkgewoJICAgIGNvbnN0IGxhdExvbkJveCA9IGdldDEobm9kZSwgIkxhdExvbkJveCIpOwoJICAgIGlmIChsYXRMb25Cb3gpIHsKCSAgICAgICAgY29uc3Qgbm9ydGggPSBudW0xKGxhdExvbkJveCwgIm5vcnRoIik7CgkgICAgICAgIGNvbnN0IHdlc3QgPSBudW0xKGxhdExvbkJveCwgIndlc3QiKTsKCSAgICAgICAgY29uc3QgZWFzdCA9IG51bTEobGF0TG9uQm94LCAiZWFzdCIpOwoJICAgICAgICBjb25zdCBzb3V0aCA9IG51bTEobGF0TG9uQm94LCAic291dGgiKTsKCSAgICAgICAgY29uc3Qgcm90YXRpb24gPSBudW0xKGxhdExvbkJveCwgInJvdGF0aW9uIik7CgkgICAgICAgIGlmICh0eXBlb2Ygbm9ydGggPT09ICJudW1iZXIiICYmCgkgICAgICAgICAgICB0eXBlb2Ygc291dGggPT09ICJudW1iZXIiICYmCgkgICAgICAgICAgICB0eXBlb2Ygd2VzdCA9PT0gIm51bWJlciIgJiYKCSAgICAgICAgICAgIHR5cGVvZiBlYXN0ID09PSAibnVtYmVyIikgewoJICAgICAgICAgICAgY29uc3QgYmJveCA9IFt3ZXN0LCBzb3V0aCwgZWFzdCwgbm9ydGhdOwoJICAgICAgICAgICAgbGV0IGNvb3JkaW5hdGVzID0gWwoJICAgICAgICAgICAgICAgIFsKCSAgICAgICAgICAgICAgICAgICAgW3dlc3QsIG5vcnRoXSwKCSAgICAgICAgICAgICAgICAgICAgW2Vhc3QsIG5vcnRoXSwKCSAgICAgICAgICAgICAgICAgICAgW2Vhc3QsIHNvdXRoXSwKCSAgICAgICAgICAgICAgICAgICAgW3dlc3QsIHNvdXRoXSwKCSAgICAgICAgICAgICAgICAgICAgW3dlc3QsIG5vcnRoXSwgLy8gdG9wIGxlZnQgKGFnYWluKQoJICAgICAgICAgICAgICAgIF0sCgkgICAgICAgICAgICBdOwoJICAgICAgICAgICAgaWYgKHR5cGVvZiByb3RhdGlvbiA9PT0gIm51bWJlciIpIHsKCSAgICAgICAgICAgICAgICBjb29yZGluYXRlcyA9IHJvdGF0ZUJveChiYm94LCBjb29yZGluYXRlcywgcm90YXRpb24pOwoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgcmV0dXJuIHsKCSAgICAgICAgICAgICAgICBiYm94LAoJICAgICAgICAgICAgICAgIGdlb21ldHJ5OiB7CgkgICAgICAgICAgICAgICAgICAgIHR5cGU6ICJQb2x5Z29uIiwKCSAgICAgICAgICAgICAgICAgICAgY29vcmRpbmF0ZXMsCgkgICAgICAgICAgICAgICAgfSwKCSAgICAgICAgICAgIH07CgkgICAgICAgIH0KCSAgICB9CgkgICAgcmV0dXJuIG51bGw7Cgl9CglmdW5jdGlvbiBnZXRHcm91bmRPdmVybGF5KG5vZGUsIHN0eWxlTWFwLCBzY2hlbWEsIG9wdGlvbnMpIHsKCSAgICBjb25zdCBib3ggPSBnZXRHcm91bmRPdmVybGF5Qm94KG5vZGUpOwoJICAgIGNvbnN0IGdlb21ldHJ5ID0gYm94Py5nZW9tZXRyeSB8fCBudWxsOwoJICAgIGlmICghZ2VvbWV0cnkgJiYgb3B0aW9ucy5za2lwTnVsbEdlb21ldHJ5KSB7CgkgICAgICAgIHJldHVybiBudWxsOwoJICAgIH0KCSAgICBjb25zdCBmZWF0dXJlID0gewoJICAgICAgICB0eXBlOiAiRmVhdHVyZSIsCgkgICAgICAgIGdlb21ldHJ5LAoJICAgICAgICBwcm9wZXJ0aWVzOiBPYmplY3QuYXNzaWduKAoJICAgICAgICAvKioKCSAgICAgICAgICogUmVsYXRlZCB0bwoJICAgICAgICAgKiBodHRwczovL2dpc3QuZ2l0aHViLmNvbS90bWN3LzAzN2ExY2I2NjYwZDc0YTM5MmU5ZGE3NDQ2NTQwZjQ2CgkgICAgICAgICAqLwoJICAgICAgICB7ICJAZ2VvbWV0cnktdHlwZSI6ICJncm91bmRvdmVybGF5IiB9LCBnZXRNdWx0aShub2RlLCBbCgkgICAgICAgICAgICAibmFtZSIsCgkgICAgICAgICAgICAiYWRkcmVzcyIsCgkgICAgICAgICAgICAidmlzaWJpbGl0eSIsCgkgICAgICAgICAgICAib3BlbiIsCgkgICAgICAgICAgICAicGhvbmVOdW1iZXIiLAoJICAgICAgICAgICAgImRlc2NyaXB0aW9uIiwKCSAgICAgICAgXSksIGdldE1heWJlSFRNTERlc2NyaXB0aW9uKG5vZ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gIHN3aXRjaCAobm9kZS50YWdOYW1lKSB7CgkgICAgICAgICAgICAgICAgY2FzZSAiR3JvdW5kT3ZlcmxheSI6IHsKCSAgICAgICAgICAgICAgICAgICAgY29uc3QgcGxhY2VtYXJrID0gZ2V0R3JvdW5kT3ZlcmxheShub2RlLCBzdHlsZU1hcCwgc2NoZW1hLCBvcHRpb25zKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKHBsYWNlbWFyaykgewoJICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlci5jaGlsZHJlbi5wdXNoKHBsYWNlbWFyayk7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIGNhc2UgIlBsYWNlbWFyayI6IHsKCSAgICAgICAgICAgICAgICAgICAgY29uc3QgcGxhY2VtYXJrID0gZ2V0UGxhY2VtYXJrKG5vZGUsIHN0eWxlTWFwLCBzY2hlbWEsIG9wdGlvbnMpOwoJICAgICAgICAgICAgICAgICAgICBpZiAocGxhY2VtYXJrKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBwb2ludGVyLmNoaWxkcmVuLnB1c2gocGxhY2VtYXJrKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICBicmVhazsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgY2FzZSAiRm9sZGVyIjogewoJICAgICAgICAgICAgICAgICAgICBjb25zdCBmb2xkZXIgPSBnZXRGb2xkZXIobm9kZSk7CgkgICAgICAgICAgICAgICAgICAgIHBvaW50ZXIuY2hpbGRyZW4ucHVzaChmb2xkZXIpOwoJICAgICAgICAgICAgICAgICAgICBwb2ludGVyID0gZm9sZGVyOwoJICAgICAgICAgICAgICAgICAgICBicmVhazsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCSAgICAgICAgaWYgKG5vZGUuY2hp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0xpbmVTdHJpbmcnLAoJCSAgICAgICAgY29vcmRpbmF0ZXM6IGZsaXBwZWQoY29vcmRzKQoJCSAgICB9OwoJCX07CgoJCWlmIChtb2R1bGUuZXhwb3J0cykgewoJCSAgICBtb2R1bGUuZXhwb3J0cyA9IHBvbHlsaW5lOwoJCX0gCgl9IChwb2x5bGluZSkpOwoKCXZhciBwb2x5bGluZUV4cG9ydHMgPSBwb2x5bGluZS5leHBvcnRzOwoKCXZhciB1dGlscyA9ICgoKSA9PiB7CgoJICAgIGNvbnN0IHB1cmdlUHJvcHMgPSAob2JqLCBibGFja2xpc3QpID0+IHsKCSAgICAgICAgaWYgKG9iaikgewoJICAgICAgICAgICAgbGV0IHJzID0gT2JqZWN0LmFzc2lnbih7fSwgb2JqKTsKCSAgICAgICAgICAgIGlmIChibGFja2xpc3QpIHsKCSAgICAgICAgICAgICAgICBmb3IgKGxldCBwcm9wIG9mIGJsYWNrbGlzdCkgewoJICAgICAgICAgICAgICAgICAgICBkZWxldGUgcnNbcHJvcF07CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgcmV0dXJuIHJzOwoJICAgICAgICB9CgkgICAgICAgIHJldHVybiB7fTsKCSAgICB9OwoKCSAgICBjb25zdCBtZXJnZVByb3BzID0gKG9iajEsIG9iajIpID0+IHsKCSAgICAgICAgb2JqMSA9IG9iajEgPyBvYmoxIDoge307CgkgICAgICAgIG9iajIgPSBvYmoyID8gb2JqMiA6IHt9OwoJICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihvYmoxLCBvYmoyKTsKCSAgICB9OwoKCSAgICBjb25zdCBmaXJzdCA9IGEgPT4gYVswXTsKCSAgICBjb25zdCBsYXN0ID0gYSA9PiBhW2EubGVuZ3RoIC0gMV07CgkgICAgY29uc3QgY29vcmRzVG9LZXkgPSBhID0+IGEuam9pbignLCcpOwoKCSAgICBjb25zdCBhZGRUb01hcCA9IChtLCBrLCB2KSA9PiB7CgkgICAgIC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ICAgICAgLy8gdGhyb3cgYEVycm9yOiBhZGRpbmcgZHVwbGljYXRlZCBrZXkgJyR7a30nIHRvIFJlZkVsZW1lbnRzYDsKCSAgICAgICAgfQoKCSAgICAgICAgYWRkQmluZGVyKGJpbmRlcikgewoJICAgICAgICAgICAgdGhpcy5iaW5kZXJzLnB1c2goYmluZGVyKTsKCSAgICAgICAgfQoKCSAgICAgICAgYmluZEFsbCgpIHsKCSAgICAgICAgICAgIHRoaXMuYmluZGVycy5mb3JFYWNoKGJpbmRlciA9PiBiaW5kZXIuYmluZCgpKTsKCSAgICAgICAgfQoJICAgIH0KCgkgICAgY2xhc3MgTGF0ZUJpbmRlciB7CgkgICAgICAgIGNvbnN0cnVjdG9yKGNvbnRhaW5lciwgdmFsdWVGdW5jLCBjdHgsIGFyZ3MpIHsKCSAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gY29udGFpbmVyOwoJICAgICAgICAgICAgdGhpcy52YWx1ZUZ1bmMgPSB2YWx1ZUZ1bmM7CgkgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKCSAgICAgICAgICAgIHRoaXMuYXJncyA9IGFyZ3M7CgkgICAgICAgIH0KCgkgICAgICAgIGJpbmQoKSB7CgkgICAgICAgICAgICBsZXQgdiA9IHRoaXMudmFsdWVGdW5jLmFwcGx5KHRoaXMuY3R4LCB0aGlzLmFyZ3MpOwoJICAgICAgICAgICAgaWYgKHRoaXMuY29udGFpbmVyIGluc3RhbmNlb2YgQXJyYXkpIHsKCSAgICAgICAgICAgICAgICBsZXQgaWR4ID0gdGhpcy5jb250YWluZXIuaW5kZXhPZih0aGlzKTsKCSAgICAgICAgICAgICAgICBpZiAoaWR4ID49IDApIHsKCSAgICAgICAgICAgICAgICAgICAgbGV0IGFyZ3MgPSBbaWR4LCAxXTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3MucHVzaCh2KTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICBbXS5zcGxpY2UuYXBwbHkodGhpcy5jb250YWluZXIsIGFyZ3MpOwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHRoaXMuY29udGFpbmVyID09PSAnb2JqZWN0JykgewoJICAgICAgICAgICAgICAgIGxldCBrID0gT2JqZWN0LmtleXModGhpcy5jb250YWluZXIpLmZpbmQodiA9PiB0aGlzLmNvbnRhaW5lclt2XSA9PT0gdGhpcyk7CgkgICAgICAgICAgICAgICAgaWYgKGspIHsKCSAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyW2tdID0gdjsKCSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNvbnRhaW5lcltrXTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCSAgICAgICAgfQoJICAgIH0KCgkgICAgY2xhc3MgV2F5Q29sbGVjdGlvbiBleHRlbmRzIEFycmF5IHsKCSAgICAgICAgY29uc3RydWN0b3IoKSB7CgkgICAgICAgICAgICBzdXBlcigpOwoJICAgICAgICAgICAgdGhpcy5maXJzdE1hcCA9IHt9OwoJICAgICAgICAgICAgdGhpcy5sYXN0TWFwID0ge307CgkgICAgICAgIH0KCgkgICAgICAgIGFkZFdheSh3YXkpIHsKCSAgICAgICAgICAgIHdheSA9IHdheS50b0Nvb3Jkc0FycmF5KCk7CgkgICAgICAgICAgICBpZiAod2F5Lmxlbmd0aCA+IDApIHsKCSAgICAgICAgICAgICAgICB0aGlzLnB1c2god2F5KTsKCSAgICAgICAgICAgICAgICBhZGRUb01hcCh0aGlzLmZpcnN0TWFwLCBjb29yZHNUb0tleShmaXJzdCh3YXkpKSwgd2F5KTsKCSAgICAgICAgICAgICAgICBhZGRUb01hcCh0aGlzLmxhc3RNYXAsIGNvb3Jkc1RvS2V5KGxhc3Qod2F5KSksIHdheSk7CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCgkgICAgICAgIHRvU3RyaW5ncygpIHsKCSAgICAgICAgICAgIGxldCBzdHJpbmdzID0gW10sIHdheSA9IG51bGw7CgkgICAgICAgICAgICB3aGlsZSAod2F5ID0gdGhpcy5zaGlmdCgpKSB7CgkgICAgICAgICAgICAgICAgcmVtb3ZlRnJvbU1hcCh0aGlzLmZpcnN0TWFwLCBjb29yZHNUb0tleShmaXJzdCh3YXkpKSwgd2F5KTsKCSAgICAgICAgICAgICAgICByZW1vdmVGcm9tTWFwKHRoaXMubGFzdE1hcCwgY29vcmRzVG9LZXkobGFzdCh3YXkpKSwgd2F5KTsKCSAgICAgICAgICAgICAgICBsZXQgY3VycmVudCA9IHdheSwgbmV4dCA9IG51bGw7CgkgICAgICAgICAgICAgICAgZG8gewoJICAgICAgICAgICAgICAgICAgICBsZXQga2V5ID0gY29vcmRzVG9LZXkobGFzdChjdXJyZW50KSksIHNob3VsZFJldmVyc2UgPSBmYWxzZTsKCgkgICAgICAgICAgICAgICAgICAgIG5leHQgPSBnZXRGaXJzdEZyb21NYXAodGhpcy5maXJzdE1hcCwga2V5KTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKCFuZXh0KSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBuZXh0ID0gZ2V0Rmlyc3RGcm9tTWFwKHRoaXMubGFzdE1hcCwga2V5KTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHNob3VsZFJldmVyc2UgPSB0cnVlOwoJICAgICAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCkgewoJICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zcGxpY2UodGhpcy5pbmRleE9mKG5leHQpLCAxKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZUZyb21NYXAodGhpcy5maXJzdE1hcCwgY29vcmRzVG9LZXkoZmlyc3QobmV4dCkpLCBuZXh0KTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZUZyb21NYXAodGhpcy5sYXN0TWFwLCBjb29yZHNUb0tleShsYXN0KG5leHQpKSwgbmV4dCk7CgkgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkUmV2ZXJzZSkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFsd2F5cyByZXZlcnNlIHNob3J0ZXIgb25lIHRvIHNhdmUgdGltZQoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0Lmxlbmd0aCA+IGN1cnJlbnQubGVuZ3RoKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtjdXJyZW50LCBuZXh0XSA9IFtuZXh0LCBjdXJyZW50XTsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5yZXZlcnNlKCk7CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnQuY29uY2F0KG5leHQuc2xpY2UoMSkpOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgfSB3aGlsZSAobmV4dCk7CgkgICAgICAgICAgICAgICAgc3RyaW5ncy5wdXNoKHN0clRvRmxvYXQoY3VycmVudCkpOwoJICAgICAgICAgICAgfQoKCSAgICAgICAgICAgIHJldHVybiBzdHJpbmdzOwoJICAgICAgICB9CgoJICAgICAgICB0b1JpbmdzKGRpcmVjdGlvbikgewoJICAgICAgICAgICAgbGV0IHN0cmluZ3MgPSB0aGlzLnRvU3RyaW5ncygpOwoJICAgICAgICAgICAgbGV0IHJpbmdzID0gW10sIHN0cmluZyA9IG51bGw7CgkgICAgICAgICAgICB3aGlsZSAoc3RyaW5nID0gc3RyaW5ncy5zaGlmdCgpKSB7Cg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kgICAgICAgIHBvbHlnb25UYWdzID0gcmVxdWlyZSQkMTsKCgkgICAgY2xhc3MgT3NtT2JqZWN0IHsKCSAgICAgICAgY29uc3RydWN0b3IodHlwZSwgaWQsIHJlZkVsZW1zKSB7CgkgICAgICAgICAgICB0aGlzLnR5cGUgPSB0eXBlOwoJICAgICAgICAgICAgdGhpcy5pZCA9IGlkOwoJICAgICAgICAgICAgdGhpcy5yZWZFbGVtcyA9IHJlZkVsZW1zOwoJICAgICAgICAgICAgdGhpcy50YWdzID0ge307CgkgICAgICAgICAgICB0aGlzLnByb3BzID0geyBpZDogdGhpcy5nZXRDb21wb3NpdGVJZCgpIH07CgkgICAgICAgICAgICB0aGlzLnJlZkNvdW50ID0gMDsKCSAgICAgICAgICAgIHRoaXMuaGFzVGFnID0gZmFsc2U7CgkgICAgICAgICAgICBpZiAocmVmRWxlbXMpIHsKCSAgICAgICAgICAgICAgICByZWZFbGVtcy5hZGQodGhpcy5nZXRDb21wb3NpdGVJZCgpLCB0aGlzKTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfQoKCSAgICAgICAgYWRkVGFncyh0YWdzKSB7CgkgICAgICAgICAgICB0aGlzLnRhZ3MgPSBPYmplY3QuYXNzaWduKHRoaXMudGFncywgdGFncyk7CgkgICAgICAgICAgICB0aGlzLmhhc1RhZyA9IHRhZ3MgPyB0cnVlIDogZmFsc2U7CgkgICAgICAgIH0KCgkgICAgICAgIGFkZFRhZyhrLCB2KSB7CgkgICAgICAgICAgICB0aGlzLnRhZ3Nba10gPSB2OwoJICAgICAgICAgICAgdGhpcy5oYXNUYWcgPSBrID8gdHJ1ZSA6IGZhbHNlOwoJICAgICAgICB9CgoJICAgICAgICBhZGRQcm9wKGssIHYpIHsKCSAgICAgICAgICAgIHRoaXMucHJvcHNba10gPSB2OwoJICAgICAgICB9CgoJICAgICAgICBhZGRQcm9wcyhwcm9wcykgewoJICAgICAgICAgICAgdGhpcy5wcm9wcyA9IE9iamVjdC5hc3NpZ24odGhpcy5wcm9wcywgcHJvcHMpOwoJICAgICAgICB9CgoJICAgICAgICBnZXRDb21wb3NpdGVJZCgpIHsKCSAgICAgICAgICAgIHJldHVybiBgJHt0aGlzLnR5cGV9LyR7dGhpcy5pZH1gOwoJICAgICAgICB9CgoJICAgICAgICBnZXRQcm9wcygpIHsKCSAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKHRoaXMucHJvcHMsIHRoaXMudGFncyk7CgkgICAgICAgIH0KCgkgICAgICAgIHRvRmVhdHVyZUFycmF5KCkgewoJICAgICAgICAgICAgcmV0dXJuIFtdOwoJICAgICAgICB9CgkgICAgfQoKCSAgICBjbGFzcyBOb2RlIGV4dGVuZHMgT3NtT2JqZWN0IHsKCSAgICAgICAgY29uc3RydWN0b3IoaWQsIHJlZkVsZW1zKSB7CgkgICAgICAgICAgICBzdXBlcignbm9kZScsIGlkLCByZWZFbGVtcyk7CgkgICAgICAgICAgICB0aGlzLmxhdExuZyA9IG51bGw7CgkgICAgICAgIH0KCgkgICAgICAgIHNldExhdExuZyhsYXRMbmcpIHsKCSAgICAgICAgICAgIHRoaXMubGF0TG5nID0gbGF0TG5nOwoJICAgICAgICB9CgoJICAgICAgICB0b0ZlYXR1cmVBcnJheSgpIHsKCSAgICAgICAgICAgIGlmICh0aGlzLmxhdExuZykgewoJICAgICAgICAgICAgICAgIHJldHVybiBbewoJICAgICAgICAgICAgICAgICAgICB0eXBlOiAnRmVhdHVyZScsCgkgICAgICAgICAgICAgICAgICAgIGlkOiB0aGlzLmdldENvbXBvc2l0ZUlkKCksCgkgICAgICAgICAgICAgICAgICAgIHByb3BlcnRpZXM6IHRoaXMuZ2V0UHJvcHMoKSwKCSAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cnk6IHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6ICdQb2ludCcsCgkgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlczogc3RyVG9GbG9hdChbdGhpcy5sYXRMbmcubG9uLCB0aGlzLmxhdExuZy5sYXRdKQoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgfV07CgkgICAgICAgICAgICB9CgoJICAgICAgICAgICAgcmV0dXJuIFtdOwoJICAgICAgICB9CgoJICAgICAgICBnZXRMYXRMbmcoKSB7CgkgICAgICAgICAgICByZXR1cm4gdGhpcy5sYXRMbmc7CgkgICAgICAgIH0KCSAgICB9CgoJICAgIGNsYXNzIFdheSBleHRlbmRzIE9zbU9iamVjdCB7CgkgICAgICAgIGNvbnN0cnVjdG9yKGlkLCByZWZFbGVtcykgewoJICAgICAgICAgICAgc3VwZXIoJ3dheScsIGlkLCByZWZFbGVtcyk7CgkgICAgICAgICAgICB0aGlzLmxhdExuZ0FycmF5ID0gW107CgkgICAgICAgICAgICB0aGlzLmlzUG9seWdvbiA9IGZhbHNlOwoJICAgICAgICB9CgoJICAgICAgICBhZGRMYXRMbmcobGF0TG5nKSB7CgkgICAgICAgICAgICB0aGlzLmxhdExuZ0FycmF5LnB1c2gobGF0TG5nKTsKCSAgICAgICAgfQoKCSAgICAgICAgc2V0TGF0TG5nQXJyYXkobGF0TG5nQXJyYXkpIHsKCSAgICAgICAgICAgIHRoaXMubGF0TG5nQXJyYXkgPSBsYXRMbmdBcnJheTsKCSAgICAgICAgfQoKCSAgICAgICAgYWRkTm9kZVJlZihyZWYpIHsKCSAgICAgICAgICAgIGxldCBiaW5kZXIgPSBuZXcgTGF0ZUJpbmRlcih0aGlzLmxhdExuZ0FycmF5LCBmdW5jdGlvbiAoaWQpIHsKCSAgICAgICAgICAgICAgICBsZXQgbm9kZSA9IHRoaXMucmVmRWxlbXMuZ2V0KGBub2RlLyR7aWR9YCk7CgkgICAgICAgICAgICAgICAgaWYgKG5vZGUpIHsKCSAgICAgICAgICAgICAgICAgICAgbm9kZS5yZWZDb3VudCsrOwoJICAgICAgICAgICAgICAgICAgICByZXR1cm4gbm9kZS5nZXRMYXRMbmcoKTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9LCB0aGlzLCBbcmVmXSk7CgoJICAgICAgICAgICAgdGhpcy5sYXRMbmdBcnJheS5wdXNoKGJpbmRlcik7CgkgICAgICAgICAgICB0aGlzLnJlZkVsZW1zLmFkZEJpbmRlcihiaW5kZXIpOwoJICAgICAgICB9CgoJICAgICAgICBhbmFseXplR2VvbWV0cnlUeXBlKGssIHYpIHsKCSAgICAgICAgICAgIGxldCBvID0gcG9seWdvblRhZ3Nba107CgkgICAgICAgICAgICBpZiAobykgewoJICAgICAgICAgICAgICAgIHRoaXMuaXNQb2x5Z29uID0gdHJ1ZTsKCSAgICAgICAgICAgICAgICBpZiAoby53aGl0ZWxpc3QpIHsKCSAgICAgICAgICAgICAgICAgICAgdGhpcy5pc1BvbHlnb24gPSBvLndoaXRlbGlzdC5pbmRleE9mKHYpID49IDAgPyB0cnVlIDogZmFsc2U7CgkgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChvLmJsYWNrbGlzdCkgewoJICAgICAgICAgICAgICAgICAgICB0aGlzLmlzUG9seWdvbiA9IG8uYmxhY2tsaXN0LmluZGV4T2YodikgPj0gMCA/IGZhbHNlIDogdHJ1ZTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCgkgICAgICAgIGFkZFRhZ3ModGFncykgewoJICAgICAgICAgICAgc3VwZXIuYWRkVGFncyh0YWdzKTsKCSAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyh0YWdzKSkgewoJICAgICAgICAgICAgICAgIHRoaXMuYW5hbHl6ZUdlb21ldHJ5VHlwZShrLCB2KTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfQoKCSAgICAgICAgYWRkVGFnKGssIHYpIHsKCSAgICAgICAgICAgIHN1cGVyLmFkZFRhZyhrLCB2KTsKCSAgICAgICAgICAgIHRoaXMuYW5hbHl6ZUdlb21ldHJ5VHlwZShrLCB2KTsKCSAgICAgICAgfQoKCSAgICAgICAgdG9Db29yZHNBcnJheSgpIHsKCSAgICAgICAgICAgIHJldHVybiB0aGlzLmxhdExuZ0FycmF5Lm1hcChsYXRMbmcgPT4gW2xhdExuZy5sb24sIGxhdExuZy5sYXRdKTsKCSAgICAgICAgfQoKCSAgICAgICAgdG9GZWF0dXJlQXJyYXkoKSB7CgkgICAgICAgICAgICBsZXQgY29vcmRzQXJyYXkgPSB0aGlzLnRvQ29vcmRzQXJyYXkoKTsKCSAgICAgICAgICAgIGlmIChjb29yZHNBcnJheS5sZW5ndGggPiAxKSB7CgkgICAgICAgICAgICAgICAgY29vcmRzQXJyYXkgPSBzdHJUb0Zsb2F0KGNvb3Jkc0FycmF5KTsKCSAgICAgICAgICAgICAgICBsZXQgZmVhdHVyZSA9IHsKCSAgICAgICAgICAgICAgICAgICAgdHlwZTogJ0ZlYXR1cmUnLAoJICAgICAgICAgICAgICAgICAgICBpZDogdGhpcy5nZXRDb21wb3NpdGVJZCgpLAoJICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzOiB0aGlzLmdldFByb3BzKCksCgkgICAgICAgICAgICAgICAgICAgIGdlb21ldHJ5OiB7CgkgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiAnTGluZVN0cmluZycsCgkgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlczogY29vcmRzQXJyYXkKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH07CgoJICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzUG9seWdvbiAmJiBpc1JpbmcoY29vcmRzQXJyYXkpKSB7CgkgICAgICAgICAgICAgICAgICAgIGlmIChyaW5nRGlyZWN0aW9uKGNvb3Jkc0FycmF5KSAhPT0gJ2NvdW50ZXJjbG9ja3dpc2UnKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBjb29yZHNBcnJheS5yZXZlcnNlKCk7CgkgICAgICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgICAgIGZlYXR1cmUuZ2VvbWV0cnkgPSB7CgkgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiAnUG9seWdvbicsCgkgICAgICAgICAgICAgICAgICAgICAgICBjb29yZGluYXRlczogW2Nvb3Jkc0FycmF5XQoJICAgICAgICAgICAgICAgICAgICB9OwoKCSAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtmZWF0dXJlXTsKCSAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgIHJldHVybiBbZmVhdHVyZV07CgkgICAgICAgICAgICB9CgoJICAgICAgICAgICAgcmV0dXJuIFtdOwoJICAgICAgICB9CgkgICAgfQoKCSAgICBjbGFzcyBSZWxhdGlvbiBleHRlbmRzIE9zbU9iamVjdCB7CgkgICAgICAgIGNvbnN0cnVjdG9yKGlkLCByZWZFbGVtcykgewoJICAgICAgICAgICAgc3VwZXIoJ3JlbGF0aW9uJywgaWQsIHJlZkVsZW1zKTsKCSAgICAgICAgICAgIHRoaXMucmVsYXRpb25zID0gW107CgkgICAgICAgICAgICB0aGlzLm5vZGVzID0gW107CgkgICAgICAgICAgICB0aGlzLmJvdW5kcyA9IG51bGw7CgkgICAgICAgIH0KCgkgICAgICAgIHNldEJvdW5kcyhib3VuZHMpIHsKCSAgICAgICAgICAgIHRoaXMuYm91bmRzID0gYm91bmRzOwoJICAgICAgICB9CgoJICAgICAgICBhZGRNZW1iZXIobWVtYmVyKSB7CgkgICAgICAgICAgICBzd2l0Y2ggKG1lbWJlci50eXBlKSB7CgkgICAgICAgICAgICAgICAgLy8gc3VwZXIgcmVsYXRpb24sIG5lZWQgdG8gZG8gY29tYmluYXRpb24KCSAgICAgICAgICAgICAgICBjYXNlICdyZWxhdGlvbic6CgkgICAgICAgICAgICAgICAgICAgIGxldCBiaW5kZXIgPSBuZXcgTGF0ZUJpbmRlcih0aGlzLnJlbGF0aW9ucywgZnVuY3Rpb24gKGlkKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVsYXRpb24gPSB0aGlzLnJlZkVsZW1zLmdldChgcmVsYXRpb24vJHtpZH1gKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWxhdGlvbikgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbGF0aW9uLnJlZkNvdW50Kys7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbGF0aW9uOwoJICAgICAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLCBbbWVtYmVyLnJlZl0pOwoJICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbGF0aW9ucy5wdXNoKGJpbmRlcik7CgkgICAgICAgICAgICAgICAgICAgIHRoaXMucmVmRWxlbXMuYWRkQmluZGVyKGJpbmRlcik7CgkgICAgICAgICAgICAgICAgICAgIGJyZWFrOwoKCSAgICAgICAgICAgICAgICBjYXNlICd3YXknOgoJICAgICAgICAgICAgICAgICAgICBpZiAoIW1lbWJlci5yb2xlKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBtZW1iZXIucm9sZSA9ICcnOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGxldCB3YXlzID0gdGhpc1ttZW1iZXIucm9sZV07CgkgICAgICAgICAgICAgICAgICAgIGlmICghd2F5cykgewoJICAgICAgICAgICAgICAgICAgICAgICAgd2F5cyA9IHRoaXNbbWVtYmVyLnJvbGVdID0gW107CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgaWYgKG1lbWJlci5nZW9tZXRyeSkgewoJICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdheSA9IG5ldyBXYXkobWVtYmVyLnJlZiwgdGhpcy5yZWZFbGVtcyk7CgkgICAgICAgICAgICAgICAgICAgICAgICB3YXkuc2V0TGF0TG5nQXJyYXkobWVtYmVyLmdlb21ldHJ5KTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHdheS5yZWZDb3VudCsrOwoJICAgICAgICAgICAgICAgICAgICAgICAgd2F5cy5wdXNoKHdheSk7CgkgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobWVtYmVyLm5vZGVzKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2F5ID0gbmV3IFdheShtZW1iZXIucmVmLCB0aGlzLnJlZkVsZW1zKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IG5pZCBvZiBtZW1iZXIubm9kZXMpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB3YXkuYWRkTm9kZVJlZihuaWQpOwoJICAgICAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICAgICAgd2F5LnJlZkNvdW50Kys7CgkgICAgICAgICAgICAgICAgICAgICAgICB3YXlzLnB1c2god2F5KTsKCSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGxldCBiaW5kZXIgPSBuZXcgTGF0ZUJpbmRlcih3YXlzLCBmdW5jdGlvbiAoaWQpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2F5ID0gdGhpcy5yZWZFbGVtcy5nZXQoYHdheS8ke2lkfWApOwoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3YXkpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2F5LnJlZkNvdW50Kys7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB3YXk7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICAgICAgfSwgdGhpcywgW21lbWJlci5yZWZdKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHdheXMucHVzaChiaW5kZXIpOwoJICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZWZFbGVtcy5hZGRCaW5kZXIoYmluZGVyKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICBicmVhazsKCgkgICAgICAgICAgICAgICAgY2FzZSAnbm9kZSc6CgkgICAgICAgICAgICAgICAgICAgIGxldCBub2RlID0gbnVsbDsKCSAgICAgICAgICAgICAgICAgICAgaWYgKG1lbWJlci5sYXQgJiYgbWVtYmVyLmxvbikgewoJICAgICAgICAgICAgICAgICAgICAgICAgbm9kZSA9IG5ldyBOb2RlKG1lbWJlci5yZWYsIHRoaXMucmVmRWxlbXMpOwoJICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5zZXRMYXRMbmcoeyBsb246IG1lbWJlci5sb24sIGxhdDogbWVtYmVyLmxhdCB9KTsKCSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtZW1iZXIudGFncykgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYWRkVGFncyhtZW1iZXIudGFncyk7CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMobWVtYmVyKSkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChbJ2lkJywgJ3R5cGUnLCAnbGF0JywgJ2xvbiddLmluZGV4T2YoaykgPCAwKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYWRkUHJvcChrLCB2KTsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5yZWZDb3VudCsrOwoJICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ub2Rlcy5wdXNoKG5vZGUpOwoJICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJpbmRlciA9IG5ldyBMYXRlQmluZGVyKHRoaXMubm9kZXMsIGZ1bmN0aW9uIChpZCkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBub2RlID0gdGhpcy5yZWZFbGVtcy5nZXQoYG5vZGUvJHtpZH1gKTsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobm9kZSkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLnJlZkNvdW50Kys7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBub2RlOwoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMsIFttZW1iZXIucmVmXSk7CgkgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5vZGVzLnB1c2goYmluZGVyKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVmRWxlbXMuYWRkQmluZGVyKGJpbmRlcik7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCgkgICAgICAgIHRvRmVhdHVyZUFycmF5KCkgewoJICAgICAgICAgICAgY29uc3QgY29uc3RydWN0U3RyaW5nR2VvbWV0cnkgPSAod3MpID0+IHsKCSAgICAgICAgICAgICAgICBsZXQgc3RyaW5ncyA9IHdzID8gd3MudG9TdHJpbmdzKCkgOiBbXTsKCSAgICAgICAgICAgICAgICBpZiAoc3RyaW5ncy5sZW5ndGggPiAwKSB7CgkgICAgICAgICAgICAgICAgICAgIGlmIChzdHJpbmdzLmxlbmd0aCA9PT0gMSkgcmV0dXJuIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6ICdMaW5lU3RyaW5nJywKCSAgICAgICAgICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiBzdHJpbmdzWzBdCgkgICAgICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CgkgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiAnTXVsdGlMaW5lU3RyaW5nJywKCSAgICAgICAgICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiBzdHJpbmdzCgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CgkgICAgICAgICAgICB9OwoKCSAgICAgICAgICAgIGNvbnN0IGNvbnN0cnVjdFBvbHlnb25HZW9tZXRyeSA9IChvd3MsIGl3cykgPT4gewoJICAgICAgICAgICAgICAgIGxldCBvdXRlclJpbmdzID0gb3dzID8gb3dzLnRvUmluZ3MoJ2NvdW50ZXJjbG9ja3dpc2UnKSA6IFtdLAoJICAgICAgICAgICAgICAgICAgICBpbm5lclJpbmdzID0gaXdzID8gaXdzLnRvUmluZ3MoJ2Nsb2Nrd2lzZScpIDogW107CgoJICAgICAgICAgICAgICAgIGlmIChvdXRlclJpbmdzLmxlbmd0aCA+IDApIHsKCSAgICAgICAgICAgICAgICAgICAgbGV0IGNvbXBvc2l0UG9seW9ucyA9IFtdOwoKCSAgICAgICAgICAgICAgICAgICAgbGV0IHJpbmcgPSBudWxsOwoJICAgICAgICAgICAgICAgICAgICBmb3IgKHJpbmcgb2Ygb3V0ZXJSaW5ncykKCSAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2l0UG9seW9ucy5wdXNoKFtyaW5nXSk7CgoJICAgICAgICAgICAgICAgICAgICAvLyBsaW5rIGlubmVyIHBvbHlnb25zIHRvIG91dGVyIGNvbnRhaW5lcnMKCSAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHJpbmcgPSBpbm5lclJpbmdzLnNoaWZ0KCkpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGlkeCBpbiBvdXRlclJpbmdzKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHB0SW5zaWRlUG9seWdvbihmaXJzdChyaW5nKSwgb3V0ZXJSaW5nc1tpZHhdKSkgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wb3NpdFBvbHlvbnNbaWR4XS5wdXNoKHJpbmcpOwoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgICAgIC8vIGNvbnN0cnVjdCB0aGUgUG9seWdvbi9NdWx0aVBvbHlnb24gZ2VvbWV0cnkKCSAgICAgICAgICAgICAgICAgICAgaWYgKGNvbXBvc2l0UG9seW9ucy5sZW5ndGggPT09IDEpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogJ1BvbHlnb24nLAoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiBjb21wb3NpdFBvbHlvbnNbMF0KCSAgICAgICAgICAgICAgICAgICAgICAgIH07CgkgICAgICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CgkgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiAnTXVsdGlQb2x5Z29uJywKCSAgICAgICAgICAgICAgICAgICAgICAgIGNvb3JkaW5hdGVzOiBjb21wb3NpdFBvbHlvbnMKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CgkgICAgICAgICAgICB9OwoKCSAgICAgICAgICAgIGxldCBwb2x5Z29uRmVhdHVyZXMgPSBbXSwgc3RyaW5nRmVhdHVyZXMgPSBbXSwgcG9pbnRGZWF0dXJlcyA9IFtdOwoJICAgICAgICAgICAgY29uc3Qgd2F5c0ZpZWxkTmFtZXMgPSBbJ291dGVyJywgJ2lubmVyJywgJyddOwoJICAgICAgICAgICAgLy8gbmVlZCB0byBkbyBjb21iaW5hdGlvbiB3aGVuIHRoZXJlJ3JlIG5lc3RlZCByZWxhdGlvbnMKCSAgICAgICAgICAgIGZvciAobGV0IHJlbGF0aW9uIG9mIHRoaXMucmVsYXRpb25zKSB7CgkgICAgICAgICAgICAgICAgaWYgKHJlbGF0aW9uKSB7CgkgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGZpZWxkTmFtZSBvZiB3YXlzRmllbGROYW1lcykgewoJICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdheXMgPSByZWxhdGlvbltmaWVsZE5hbWVdOwoJICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdheXMpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGhpc1dheXMgPSB0aGlzW2ZpZWxkTmFtZV07CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXNXYXlzKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtdLnNwbGljZS5hcHBseSh0aGlzV2F5cywgW3RoaXNXYXlzLmxlbmd0aCwgMF0uY29uY2F0KHdheXMpKTsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2ZpZWxkTmFtZV0gPSB3YXlzOwoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCgkgICAgICAgICAgICBmb3IgKGxldCBmaWVsZE5hbWUgb2Ygd2F5c0ZpZWxkTmFtZXMpIHsKCSAgICAgICAgICAgICAgICBsZXQgd2F5cyA9IHRoaXNbZmllbGROYW1lXTsKCSAgICAgICAgICAgICAgICBpZiAod2F5cykgewoJICAgICAgICAgICAgICAgICAgICB0aGlzW2ZpZWxkTmFtZV0gPSBuZXcgV2F5Q29sbGVjdGlvbigpOwoJICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB3YXkgb2Ygd2F5cykgewoJICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1tmaWVsZE5hbWVdLmFkZFdheSh3YXkpOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoKCSAgICAgICAgICAgIGxldCBnZW9tZXRyeSA9IG51bGw7CgoJICAgICAgICAgICAgbGV0IGZlYXR1cmUgPSB7CgkgICAgICAgICAgICAgICAgdHlwZTogJ0ZlYXR1cmUnLAoJICAgICAgICAgICAgICAgIGlkOiB0aGlzLmdldENvbXBvc2l0ZUlkKCksCgkgICAgICAgICAgICAgICAgYmJveDogdGhpcy5ib3VuZHMsCgkgICAgICAgICAgICAgICAgcHJvcGVydGllczogdGhpcy5nZXRQcm9wcygpCgkgICAgICAgICAgICB9OwoKCSAgICAgICAgICAgIGlmICghdGhpcy5ib3VuZHMpIHsKCSAgICAgICAgICAgICAgICBkZWxldGUgZmVhdHVyZS5iYm94OwoJICAgICAgICAgICAgfQoKCSAgICAgICAgICAgIGlmICh0aGlzLm91dGVyKSB7CgkgICAgICAgICAgICAgICAgZ2VvbWV0cnkgPSBjb25zdHJ1Y3RQb2x5Z29uR2VvbWV0cnkodGhpcy5vdXRlciwgdGhpcy5pbm5lcik7CgkgICAgICAgICAgICAgICAgaWYgKGdlb21ldHJ5KSB7CgkgICAgICAgICAgICAgICAgICAgIGZlYXR1cmUuZ2VvbWV0cnkgPSBnZW9tZXRyeTsKCSAgICAgICAgICAgICAgICAgICAgcG9seWdvbkZlYXR1cmVzLnB1c2goZmVhdHVyZSk7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgZWxzZSBpZiAodGhpc1snJ10pIHsKCSAgICAgICAgICAgICAgICBnZW9tZXRyeSA9IGNvbnN0cnVjdFN0cmluZ0dlb21ldHJ5KHRoaXNbJyddKTsKCSAgICAgICAgICAgICAgICBpZiAoZ2VvbWV0cnkpIHsKCSAgICAgICAgICAgICAgICAgICAgZmVhdHVy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LCAnbm9kZS4kJicpICsgJzsnOwoJICAgICAgICByZXR1cm4gbmV3IEZ1bmN0aW9uKCdub2RlJywgYm9keSk7CgkgICAgfQoKCSAgICByZXR1cm4gY2xhc3MgewoJICAgICAgICBjb25zdHJ1Y3RvcihvcHRzKSB7CgkgICAgICAgICAgICBpZiAob3B0cykgewoJICAgICAgICAgICAgICAgIHRoaXMucXVlcnlQYXJlbnQgPSBvcHRzLnF1ZXJ5UGFyZW50ID8gdHJ1ZSA6IGZhbHNlOwoJICAgICAgICAgICAgICAgIHRoaXMucHJvZ3Jlc3NpdmUgPSBvcHRzLnByb2dyZXNzaXZlOwoJICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1ZXJ5UGFyZW50KSB7CgkgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50TWFwID0gbmV3IFdlYWtNYXAoKTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9CgkgICAgICAgICAgICB0aGlzLmV2dExpc3RlbmVycyA9IHt9OwoJICAgICAgICB9CgoJICAgICAgICBwYXJzZSh4bWwsIHBhcmVudCwgZGlyKSB7CgkgICAgICAgICAgICBkaXIgPSBkaXIgPyBkaXIgKyAnLicgOiAnJzsKCSAgICAgICAgICAgIGxldCBub2RlUmVnRXggPSAvPChbXiA+XC9dKykoLio/KT4vbWcsIG5vZGVNYXRjaCA9IG51bGwsIG5vZGVzID0gW107CgkgICAgICAgICAgICB3aGlsZSAobm9kZU1hdGNoID0gbm9kZVJlZ0V4LmV4ZWMoeG1sKSkgewoJICAgICAgICAgICAgICAgIGxldCB0YWcgPSBub2RlTWF0Y2hbMV0sIG5vZGUgPSB7ICR0YWc6IHRhZyB9LCBmdWxsVGFnID0gZGlyICsgdGFnOwoKCSAgICAgICAgICAgICAgICBsZXQgYXR0clRleHQgPSBub2RlTWF0Y2hbMl0udHJpbSgpLCBjbG9zZWQgPSBmYWxzZTsKCSAgICAgICAgICAgICAgICBpZiAoYXR0clRleHQuZW5kc1dpdGgoJy8nKSB8fCB0YWcuc3RhcnRzV2l0aCgnPycpIHx8IHRhZy5zdGFydHNXaXRoKCchJykpIHsKCSAgICAgICAgICAgICAgICAgICAgY2xvc2VkID0gdHJ1ZTsKCSAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgIGxldCBhdHRSZWdFeDEgPSAvKFteIF0rPyk9IiguKz8pIi9nLCBhdHRSZWdFeDIgPSAvKFteIF0rPyk9JyguKz8pJy9nOwoJICAgICAgICAgICAgICAgIGxldCBhdHRNYXRjaCA9IG51bGwsIGhhc0F0dHJzID0gZmFsc2U7CgkgICAgICAgICAgICAgICAgd2hpbGUgKGF0dE1hdGNoID0gYXR0UmVnRXgxLmV4ZWMoYXR0clRleHQpKSB7CgkgICAgICAgICAgICAgICAgICAgIGhhc0F0dHJzID0gdHJ1ZTsKCSAgICAgICAgICAgICAgICAgICAgbm9kZVthdHRNYXRjaFsxXV0gPSBhdHRNYXRjaFsyXTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgaWYgKCFoYXNBdHRycykKCSAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGF0dE1hdGNoID0gYXR0UmVnRXgyLmV4ZWMoYXR0clRleHQpKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBoYXNBdHRycyA9IHRydWU7CgkgICAgICAgICAgICAgICAgICAgICAgICBub2RlW2F0dE1hdGNoWzFdXSA9IGF0dE1hdGNoWzJdOwoJICAgICAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgIGlmICghaGFzQXR0cnMgJiYgYXR0clRleHQgIT09ICcnKSB7CgkgICAgICAgICAgICAgICAgICAgIG5vZGUudGV4dCA9IGF0dHJUZXh0OwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICBpZiAodGhpcy5wcm9ncmVzc2l2ZSkgewoJICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoYDwke2Z1bGxUYWd9PmAsIG5vZGUsIHBhcmVudCk7CgkgICAgICAgICAgICAgICAgfQoKCSAgICAgICAgICAgICAgICBpZiAoIWNsb3NlZCkgewoJICAgICAgICAgICAgICAgICAgICBsZXQgaW5uZXJSZWdFeCA9IG5ldyBSZWdFeHAoYChbXl0rPyk8XC8ke3RhZ30+YCwgJ2cnKTsKCSAgICAgICAgICAgICAgICAgICAgaW5uZXJSZWdFeC5sYXN0SW5kZXggPSBub2RlUmVnRXgubGFzdEluZGV4OwoJICAgICAgICAgICAgICAgICAgICBsZXQgaW5uZXJNYXRjaCA9IGlubmVyUmVnRXguZXhlYyh4bWwpOwoJICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJNYXRjaCAmJiBpbm5lck1hdGNoWzFdKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBub2RlUmVnRXgubGFzdEluZGV4ID0gaW5uZXJSZWdFeC5sYXN0SW5kZXg7CgkgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaW5uZXJOb2RlcyA9IHRoaXMucGFyc2UoaW5uZXJNYXRjaFsxXSwgbm9kZSwgZnVsbFRhZyk7CgkgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJOb2Rlcy5sZW5ndGggPiAwKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS4kaW5uZXJOb2RlcyA9IGlubmVyTm9kZXM7CgkgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuJGlubmVyVGV4dCA9IGlubmVyTWF0Y2hbMV07CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVlcnlQYXJlbnQgJiYgcGFyZW50KSB7CgkgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50TWFwLnNldChub2RlLCBwYXJlbnQpOwoJICAgICAgICAgICAgICAgIH0KCgkgICAgICAgICAgICAgICAgaWYgKHRoaXMucHJvZ3Jlc3NpdmUpIHsKCSAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KGA8LyR7ZnVsbFRhZ30+YCwgbm9kZSwgcGFyZW50KTsKCSAgICAgICAgICAgICAgICB9CgoJICAgICAgICAgICAgICAgIG5vZGVzLnB1c2gobm9kZSk7CgkgICAgICAgICAgICB9CgoJICAgICAgICAgICAgcmV0dXJuIG5vZGVzOwoJICAgICAgICB9CgoJICAgICAgICBnZXRQYXJlbnQobm9kZSkgewoJICAgICAgICAgICAgaWYgKHRoaXMucXVlcnlQYXJlbnQpIHsKCSAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJlbnRNYXAuZ2V0KG5vZGUpOwoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgcmV0dXJuIG51bGw7CgkgICAgICAgIH0KCgkgICAgICAgICNhZGRMaXN0ZW5lcihldnQsIGZ1bmMpIHsKCSAgICAgICAgICAgIGxldCBmdW5jcyA9IHRoaXMuZXZ0TGlzdGVuZXJzW2V2dF07CgkgICAgICAgICAgICBpZiAoZnVuY3MpIHsKCSAgICAgICAgICAgICAgICBmdW5jcy5wdXNoKGZ1bmMpOwoJICAgICAgICAgICAgfSBlbHNlIHsKCSAgICAgICAgICAgICAgICB0aGlzLmV2dExpc3RlbmVyc1tldnRdID0gW2Z1bmNdOwoJICAgICAgICAgICAgfQoJICAgICAgICB9CgoJICAgICAgICAvLyBzdXBwb3J0IGphdmFzY3JpcHQgY29uZGl0aW9uIGZvciB0aGUgbGFzdCB0YWcKCSAgICAgICAgYWRkTGlzdGVuZXIoZXZ0LCBmdW5jKSB7CgkgICAgICAgICAgICBpZiAoY29uZGl0aW9uZWQoZXZ0KSkgewoJICAgICAgICAgICAgICAgIC8vIGZ1bmMucHJvdG90eXBlID0gZXZ0OwoJICAgICAgICAgICAgICAgIGV2dCA9IHBhcnNlRXZlbnQoZXZ0KTsKCSAgICAgICAgICAgICAgICBmdW5jLmNvbmRpdGlvbiA9IGdlbkNvbmRpdGlvbkZ1bmMoZXZ0LmV4cCk7CgkgICAgICAgICAgICAgICAgZXZ0ID0gZXZ0LmV2dDsKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIHRoaXMuI2FkZExpc3RlbmVyKGV2dCwgZnVuYyk7CgkgICAgICAgIH0KCgkgICAgICAgICNyZW1vdmVMaXN0ZW5lcihldnQsIGZ1bmMpIHsKCSAgICAgICAgICAgIGxldCBmdW5jcyA9IHRoaXMuZXZ0TGlzdGVuZXJzW2V2dF07CgkgICAgICAgICAgICBsZXQgaWR4ID0gbnVsbDsKCSAgICAgICAgICAgIGlmIChmdW5jcyAmJiAoaWR4ID0gZnVuY3MuaW5kZXhPZihmdW5jKSkgPj0gMCkgewoJICAgICAgICAgICAgICAgIGZ1bmNzLnNwbGljZShpZHgsIDEpOwoJICAgICAgICAgICAgfQoJICAgICAgICB9CgoJICAgICAgICByZW1vdmVMaXN0ZW5lcihldnQsIGZ1bmMpIHsKCSAgICAgICAgICAgIGlmIChjb25kaXRpb25lZChldnQpKSB7CgkgICAgICAgICAgICAgICAgZXZ0ID0gcGFyc2VFdmVudChldnQpOwoJICAgICAgICAgICAgICAgIGV2dCA9IGV2dC5ldnQ7CgkgICAgICAgICAgICB9CgkgICAgICAgICAgICB0aGlzLiNyZW1vdmVMaXN0ZW5lcihldnQsIGZ1bmMpOwoJICAgICAgICB9CgoJICAgICAgICBlbWl0KGV2dCwgLi4uYXJncykgewoJICAgICAgICAgICAgbGV0IGZ1bmNzID0gdGhpcy5ldnRMaXN0ZW5lcnNbZXZ0XTsKCSAgICAgICAgICAgIGlmIChmdW5jcykgewoJICAgICAgICAgICAgICAgIGZvciAobGV0IGZ1bmMgb2YgZnVuY3MpIHsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGZ1bmMuY29uZGl0aW9uKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZnVuYy5jb25kaXRpb24uYXBwbHkobnVsbCwgYXJncykgPT09IH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AgICAgICBsZXQgd2F5T3B0ID0gb3B0cy5zdXBwcmVzc1dheSB8fCBvcHRzLmV4Y2x1ZGVXYXk7CgkgICAgICAgICAgICBpZiAod2F5T3B0ICE9PSB1bmRlZmluZWQgJiYgIXdheU9wdCkgewoJICAgICAgICAgICAgICAgIGV4Y2x1ZGVXYXkgPSBmYWxzZTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfQoJICAgIH07CgoJICAgIHBhcnNlT3B0cyhvcHRzKTsKCgkgICAgY29uc3QgZGV0ZWN0Rm9ybWF0ID0gb3NtID0+IHsKCSAgICAgICAgaWYgKG9zbS5lbGVtZW50cykgewoJICAgICAgICAgICAgcmV0dXJuICdqc29uJzsKCSAgICAgICAgfQoJICAgICAgICBpZiAob3NtLmluZGV4T2YoJzxvc20nKSA+PSAwKSB7CgkgICAgICAgICAgICByZXR1cm4gJ3htbCc7CgkgICAgICAgIH0KCSAgICAgICAgaWYgKG9zbS50cmltKCkuc3RhcnRzV2l0aCgneycpKSB7CgkgICAgICAgICAgICByZXR1cm4gJ2pzb24tcmF3JzsKCSAgICAgICAgfQoJICAgICAgICByZXR1cm4gJ2ludmFsaWQnOwoJICAgIH07CgoJICAgIGxldCBmb3JtYXQgPSBkZXRlY3RGb3JtYXQob3NtKTsKCgkgICAgbGV0IHJlZkVsZW1lbnRzID0gbmV3IFJlZkVsZW1lbnRzKCksIGZlYXR1cmVBcnJheSA9IFtdOwoKCSAgICBjb25zdCBhbmFseXplRmVhdHVyZXNGcm9tSnNvbiA9IG9zbSA9PiB7CgkgICAgICAgIGZvciAobGV0IGVsZW0gb2Ygb3NtLmVsZW1lbnRzKSB7CgkgICAgICAgICAgICBzd2l0Y2ggKGVsZW0udHlwZSkgewoJICAgICAgICAgICAgICAgIGNhc2UgJ25vZGUnOgoJICAgICAgICAgICAgICAgICAgICBsZXQgbm9kZSA9IG5ldyBOb2RlKGVsZW0uaWQsIHJlZkVsZW1lbnRzKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW0udGFncykgewoJICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hZGRUYWdzKGVsZW0udGFncyk7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgbm9kZS5hZGRQcm9wcyhwdXJnZVByb3BzKGVsZW0sIFsnaWQnLCAndHlwZScsICd0YWdzJywgJ2xhdCcsICdsb24nXSkpOwoJICAgICAgICAgICAgICAgICAgICBub2RlLnNldExhdExuZyhlbGVtKTsKCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgoJICAgICAgICAgICAgICAgIGNhc2UgJ3dheSc6CgkgICAgICAgICAgICAgICAgICAgIGxldCB3YXkgPSBuZXcgV2F5KGVsZW0uaWQsIHJlZkVsZW1lbnRzKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW0udGFncykgewoJICAgICAgICAgICAgICAgICAgICAgICAgd2F5LmFkZFRhZ3MoZWxlbS50YWdzKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICB3YXkuYWRkUHJvcHMocHVyZ2VQcm9wcyhlbGVtLCBbJ2lkJywgJ3R5cGUnLCAndGFncycsICdub2RlcycsICdnZW9tZXRyeSddKSk7CgkgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtLm5vZGVzKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBuIG9mIGVsZW0ubm9kZXMpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICB3YXkuYWRkTm9kZVJlZihuKTsKCSAgICAgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbGVtLmdlb21ldHJ5KSB7CgkgICAgICAgICAgICAgICAgICAgICAgICB3YXkuc2V0TGF0TG5nQXJyYXkoZWxlbS5nZW9tZXRyeSk7CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgoJICAgICAgICAgICAgICAgIGNhc2UgJ3JlbGF0aW9uJzoKCSAgICAgICAgICAgICAgICAgICAgbGV0IHJlbGF0aW9uID0gbmV3IFJlbGF0aW9uKGVsZW0uaWQsIHJlZkVsZW1lbnRzKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW0uYm91bmRzKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICByZWxhdGlvbi5zZXRCb3VuZHMoW3BhcnNlRmxvYXQoZWxlbS5ib3VuZHMubWlubG9uKSwgcGFyc2VGbG9hdChlbGVtLmJvdW5kcy5taW5sYXQpLCBwYXJzZUZsb2F0KGVsZW0uYm91bmRzLm1heGxvbiksIHBhcnNlRmxvYXQoZWxlbS5ib3VuZHMubWF4bGF0KV0pOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtLnRhZ3MpIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIHJlbGF0aW9uLmFkZFRhZ3MoZWxlbS50YWdzKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICByZWxhdGlvbi5hZGRQcm9wcyhwdXJnZVByb3BzKGVsZW0sIFsnaWQnLCAndHlwZScsICd0YWdzJywgJ2JvdW5kcycsICdtZW1iZXJzJ10pKTsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW0ubWVtYmVycykgewoJICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgbWVtYmVyIG9mIGVsZW0ubWVtYmVycykgewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbGF0aW9uLmFkZE1lbWJlcihtZW1iZXIpOwoJICAgICAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGJyZWFrOwoJICAgICAgICAgICAgfQoJICAgICAgICB9CgkgICAgfTsKCgkgICAgY29uc3QgYW5hbHl6ZUZlYXR1cmVzRnJvbVhtbCA9IG9zbSA9PiB7CgkgICAgICAgIGNvbnN0IHhtbFBhcnNlciA9IG5ldyBYbWxQYXJzZXIoeyBwcm9ncmVzc2l2ZTogdHJ1ZSB9KTsKCgkgICAgICAgIHhtbFBhcnNlci5vbignPC9vc20ubm9kZT4nLCBub2RlID0+IHsKCSAgICAgICAgICAgIGxldCBuZCA9IG5ldyBOb2RlKG5vZGUuaWQsIHJlZkVsZW1lbnRzKTsKCSAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyhub2RlKSkKCSAgICAgICAgICAgICAgICBpZiAoIWsuc3RhcnRzV2l0aCgnJCcpICYmIFsnaWQnLCAnbG9uJywgJ2xhdCddLmluZGV4T2YoaykgPCAwKSB7CgkgICAgICAgICAgICAgICAgICAgIG5kLmFkZFByb3Aoaywgdik7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgbmQuc2V0TGF0TG5nKG5vZGUpOwoJICAgICAgICAgICAgaWYgKG5vZGUuJGlubmVyTm9kZXMpIHsKCSAgICAgICAgICAgICAgICBmb3IgKGxldCBpbmQgb2Ygbm9kZS4kaW5uZXJOb2RlcykgewoJICAgICAgICAgICAgICAgICAgICBpZiAoaW5kLiR0YWcgPT09ICd0YWcnKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBuZC5hZGRUYWcoaW5kLmssIGluZC52KTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCSAgICAgICAgfSk7CgoJICAgICAgICB4bWxQYXJzZXIub24oJzwvb3NtLndheT4nLCBub2RlID0+IHsKCSAgICAgICAgICAgIGxldCB3YXkgPSBuZXcgV2F5KG5vZGUuaWQsIHJlZkVsZW1lbnRzKTsKCSAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyhub2RlKSkgewoJICAgICAgICAgICAgICAgIGlmICghay5zdGFydHNXaXRoKCckJykgJiYgWydpZCddLmluZGV4T2YoaykgPCAwKSB7CgkgICAgICAgICAgICAgICAgICAgIHdheS5hZGRQcm9wKGssIHYpOwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIGlmIChub2RlLiRpbm5lck5vZGVzKSB7CgkgICAgICAgICAgICAgICAgZm9yIChsZXQgaW5kIG9mIG5vZGUuJGlubmVyTm9kZXMpIHsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGluZC4kdGFnID09PSAnbmQnKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5kLmxvbiAmJiBpbmQubGF0KSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2F5LmFkZExhdExuZyhpbmQpOwoJICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpbmQucmVmKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2F5LmFkZE5vZGVSZWYoaW5kLnJlZik7CgkgICAgICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5kLiR0YWcgPT09ICd0YWcnKQoJICAgICAgICAgICAgICAgICAgICAgICAgd2F5LmFkZFRhZyhpbmQuaywgaW5kLnYpOwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCSAgICAgICAgfSk7CgoJICAgICAgICB4bWxQYXJzZXIub24oJzxvc20ucmVsYXRpb24+Jywgbm9kZSA9PiB7CgkgICAgICAgICAgICBuZXcgUmVsYXRpb24obm9kZS5pZCwgcmVmRWxlbWVudHMpOwoJICAgICAgICB9KTsKCgkgICAgICAgIHhtbFBhcnNlci5vbignPC9vc20ucmVsYXRpb24ubWVtYmVyPicsIChub2RlLCBwYXJlbnQpID0+IHsKCSAgICAgICAgICAgIGxldCByZWxhdGlvbiA9IHJlZkVsZW1lbnRzLmdldChgcmVsYXRpb24vJHtwYXJlbnQuaWR9YCk7CgkgICAgICAgICAgICBsZXQgbWVtYmVyID0gewoJICAgICAgICAgICAgICAgIHR5cGU6IG5vZGUudHlwZSwKCSAgICAgICAgICAgICAgICByb2xlOiBub2RlLnJvbGUgPyBub2RlLnJvbGUgOiAnJywKCSAgICAgICAgICAgICAgICByZWY6IG5vZGUucmVmCgkgICAgICAgICAgICB9OwoJICAgICAgICAgICAgaWYgKG5vZGUubGF0ICYmIG5vZGUubG9uKSB7CgkgICAgICAgICAgICAgICAgbWVtYmVyLmxhdCA9IG5vZGUubGF0LCBtZW1iZXIubG9uID0gbm9kZS5sb24sIG1lbWJlci50YWdzID0ge307CgkgICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKG5vZGUpKSB7CgkgICAgICAgICAgICAgICAgICAgIGlmICghay5zdGFydHNXaXRoKCckJykgJiYgWyd0eXBlJywgJ2xhdCcsICdsb24nXS5pbmRleE9mKGspIDwgMCkgewoJICAgICAgICAgICAgICAgICAgICAgICAgbWVtYmVyW2tdID0gdjsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIGlmIChub2RlLiRpbm5lck5vZGVzKSB7CgkgICAgICAgICAgICAgICAgbGV0IGdlb21ldHJ5ID0gW107CgkgICAgICAgICAgICAgICAgbGV0IG5vZGVzID0gW107CgkgICAgICAgICAgICAgICAgZm9yIChsZXQgaW5kIG9mIG5vZGUuJGlubmVyTm9kZXMpIHsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGluZC5sYXQgJiYgaW5kLmxvbikgewoJICAgICAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cnkucHVzaChpbmQpOwoJICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXMucHVzaChpbmQucmVmKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICBpZiAoZ2VvbWV0cnkubGVuZ3RoID4gMCkgewoJICAgICAgICAgICAgICAgICAgICBtZW1iZXIuZ2VvbWV0cnkgPSBnZW9tZXRyeTsKCSAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGVzLmxlbmd0aCA+IDApIHsKCSAgICAgICAgICAgICAgICAgICAgbWVtYmVyLm5vZGVzID0gbm9kZXM7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgcmVsYXRpb24uYWRkTWVtYmVyKG1lbWJlcik7CgkgICAgICAgIH0pOwoKCSAgICAgICAgeG1sUGFyc2VyLm9uKCc8L29zbS5yZWxhdGlvbi5ib3VuZHM+JywgKG5vZGUsIHBhcmVudCkgPT4gewoJICAgICAgICAgICAgcmVmRWxlbWVudHMuZ2V0KGByZWxhdGlvbi8ke3BhcmVudC5pZH1gKS5zZXRCb3VuZHMoW3BhcnNlRmxvYXQobm9kZS5taW5sb24pLCBwYXJzZUZsb2F0KG5vZGUubWlubGF0KSwgcGFyc2VGbG9hdChub2RlLm1heGxvbiksIHBhcnNlRmxvYXQobm9kZS5tYXhsYXQpXSk7CgkgICAgICAgIH0pOwoKCSAgICAgICAgeG1sUGFyc2VyLm9uKCc8L29zbS5yZWxhdGlvbi50YWc+JywgKG5vZGUsIHBhcmVudCkgPT4gewoJICAgICAgICAgICAgcmVmRWxlbWVudHMuZ2V0KGByZWxhdGlvbi8ke3BhcmVudC5pZH1gKS5hZGRUYWcobm9kZS5rLCBub2RlLnYpOwoJICAgICAgICB9KTsKCgkgICAgICAgIHhtbFBhcnNlci5wYXJzZShvc20pOwoJICAgIH07CgoJICAgIGlmIChmb3JtYXQgPT09ICdqc29uLXJhdycpIHsKCSAgICAgICAgb3NtID0gSlNPTi5wYXJzZShvc20pOwoJICAgICAgICBpZiAob3NtLmVsZW1lbnRzKSB7CgkgICAgICAgICAgICBmb3JtYXQgPSAnanNvbic7CgkgICAgICAgIH0gZWxzZSB7CgkgICAgICAgICAgICBmb3JtYXQgPSAnaW52YW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W9ucy5jc3ZPcHRpb25zIHx8IHt9OyAvLyBUT0RPIGFsbG93IENTViBvcHRpb25zCgkgICAgICAgIGlmICh0aGlzLl9mb3JtYXQgPT09ICd0c3YnKSB7CgkgICAgICAgICAgICBvcHRpb25zLmRlbGltaXRlciA9ICdcdCc7CgkgICAgICAgIH0KCSAgICAgICAgLy8gVXNlIHRoZSBjc3YyZ2VvanNvbiBsaWJyYXJ5IHRvIGNvbnZlcnQgdGhlIENTViB0byBHZW9KU09OCgkgICAgICAgIGNvbnN0IGdlb2pzb24gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CgkgICAgICAgICAgICBjc3YyZ2VvanNvbl8xLmNzdjJnZW9qc29uKHRoaXMuX3Jhd0RhdGEsIG9wdGlvbnMsIChlcnIsIGRhdGEpID0+IHsKCSAgICAgICAgICAgICAgICBpZiAoZXJyKSB7CgkgICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnIpOwoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICBlbHNlIHsKCSAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShkYXRhKTsKCSAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICB9KTsKCSAgICAgICAgfSk7CgkgICAgICAgIHJldHVybiBnZW9qc29uOwoJICAgIH0KCSAgICAvKioKCSAgICAgKiBMb2FkcyBUb3BvSlNPTiBkYXRhIGFuZCBjb252ZXJ0cyBpdCBpbnRvIGEgR2VvSlNPTiBGZWF0dXJlQ29sbGVjdGlvbgoJICAgICAqIEByZXR1cm5zIEEgUHJvbWlzZSB0aGF0IHJlc29sdmVzIHdpdGggdGhlIEdlb0pTT04gRmVhdHVyZUNvbGxlY3Rpb24uCgkgICAgICovCgkgICAgYXN5bmMgbG9hZFRvcG9Kc29uKCkgewoJICAgICAgICBsZXQgdG9wb0pzb25EYXRhID0ge307CgkgICAgICAgIHRyeSB7CgkgICAgICAgICAgICB0b3BvSnNvbkRhd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kIHBhcnNlcyBQb2x5bGluZSBkYXRhIGludG8gYSBHZW9KU09OIEZlYXR1cmVDb2xsZWN0aW9uLgoJICAgICAqIEByZXR1cm5zIEEgUHJvbWlzZSB0aGF0IHJlc29sdmVzIHdpdGggdGhlIEdlb0pTT04gRmVhdHVyZUNvbGxlY3Rpb24uCgkgICAgICovCgkgICAgYXN5bmMgbG9hZFBvbHlsaW5lKCkgewoJICAgICAgICBsZXQgb3B0aW9ucyA9IHRoaXMuX29wdGlvbnMucG9seWxpbmVPcHRpb25zIHx8IHt9OwoJICAgICAgICAvLyBVc2UgdGhlIEBtYXBib3gvcG9seWxpbmUgbGlicmFyeSB0byBjb252ZXJ0IHRoZSBwb2x5bGluZSB0byBHZW9KU09OCgkgICAgICAgIGNvbnN0IGdlb2pzb24gPSBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CgkgICAgICAgICAgICB0cnkgewoJICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTdHJpbmcgPSBwb2x5bGluZUV4cG9ydHMudG9HZW9KU09OKHRoaXMuX3Jhd0RhdGEsIG9wdGlvbnMucHJlY2lzaW9uKTsKCSAgICAgICAgICAgICAgICBsZXQgZ2VvbWV0cnkgPSBsaW5lU3RyaW5nOwoJICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLnR5cGUgPT09ICdwb2ludCcpIHsKCSAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVTdHJpbmcuY29vcmRpbmF0ZXMubGVuZ3RoID09PSAxKSB7CgkgICAgICAgICAgICAgICAgICAgICAgICAvLyBNYWtlIGl0IGEgcG9pbnQKCSAgICAgICAgICAgICAgICAgICAgICAgIGdlb21ldHJ5ID0gewoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICd0eXBlJzogJ1BvaW50JywKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29vcmRpbmF0ZXMnOiBsaW5lU3RyaW5nLmNvb3JkaW5hdGVzWzBdCgkgICAgICAgICAgICAgICAgICAgICAgICB9OwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgICAgIGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdDYW5ub3QgY29udmVydCBwb2x5bGluZSB0byAnICsgb3B0aW9ucy50eXBlKTsKCSAgICAgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICBlbHNlIGlmIChvcHRpb25zLnR5cGUgPT09ICdwb2x5Z29uJykgewoJICAgICAgICAgICAgICAgICAgICBpZiAobGluZVN0cmluZy5jb29yZGluYXRlc1swXVswXSA9PT0gbGluZVN0cmluZy5jb29yZGluYXRlc1tsaW5lU3RyaW5nLmNvb3JkaW5hdGVzLmxlbmd0aCAtIDFdWzBdICYmCgkgICAgICAgICAgICAgICAgICAgICAgICBsaW5lU3RyaW5nLmNvb3JkaW5hdGVzWzBdWzFdID09PSBsaW5lU3RyaW5nLmNvb3JkaW5hdGVzW2xpbmVTdHJpbmcuY29vcmRpbmF0ZXMubGVuZ3RoIC0gMV1bMV0pIHsKCSAgICAgICAgICAgICAgICAgICAgICAgIC8vIE1ha2UgaXQgYSBwb2x5Z29uCgkgICAgICAgICAgICAgICAgICAgICAgICBnZW9tZXRyeSA9IHsKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAndHlwZSc6ICdQb2x5Z29uJywKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29vcmRpbmF0ZXMnOiBbbGluZVN0cmluZy5jb29yZGluYXRlc10KCSAgICAgICAgICAgICAgICAgICAgICAgIH07CgkgICAgICAgICAgICAgICAgICAgIH0KCSAgICAgICAgICAgICAgICAgICAgZWxzZSB7CgkgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ0Nhbm5vdCBjb252ZXJ0IHBvbHlsaW5lIHRvICcgKyBvcHRpb25zLnR5cGUpOwoJICAgICAgICAgICAgICAgICAgICB9CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIHJlc29sdmUoewoJICAgICAgICAgICAgICAgICAgICB0eXBlOiAiRmVhdHVyZUNvbGxlY3Rpb24iLAoJICAgICAgICAgICAgICAgICAgICBmZWF0dXJlczogW3sKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAidHlwZSI6ICJGZWF0dXJlIiwKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZ2VvbWV0cnkiOiBnZW9tZXRyeSwKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAicHJvcGVydGllcyI6IG9wdGlvbnMucHJvcGVydGllcyB8fCB7fQoJICAgICAgICAgICAgICAgICAgICAgICAgfV0KCSAgICAgICAgICAgICAgICB9KTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIGNhdGNoIChlcnIpIHsKCSAgICAgICAgICAgICAgICByZWplY3QoZXJyKTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfSk7CgkgICAgICAgIHJldHVybiBnZW9qc29uOwoJICAgIH0KCX0KCgljb25zdCBsaWJyYXJpZXMgPSB7CgkgICAgJ0NvbnZlcnRlcic6IENvbnZlcnRlcgoJfTsKCWxldCBzdWJDbGFzczsKCXNlbGYuYWRkRXZlbnRMaXN0ZW5lcignbWVzc2FnZScsIGUgPT4gewoJICAgIGNvbnN0IGRhdGEgPSAoZS5kYXRhIHx8IGUpOwoJICAgIGNvbnN0IHBvc3QgPSAoaWQsIGVyciwgcmVzLCB0eXBlKSA9PiB7CgkgICAgICAgIHBvc3RNZXNzYWdlKHsKCSAgICAgICAgICAgIHR5cGU6IHR5cGUgPyB0eXBlIDogKGVyciA/ICdlcnJvcicgOiAncmVzcG9uc2UnKSwKCSAgICAgICAgICAgIGlkOiBpZCwKCSAgICAgICAgICAgIG1lc3NhZ2U6IHJlcywKCSAgICAgICAgICAgIGVycm9yOiBlcnIKCSAgICAgICAgfSk7CgkgICAgfTsKCSAgICBjb25zdCBjb21tYW5kcyA9IHsKCSAgICAgICAgJ2luaXQnOiAobXNnKSA9PiB7CgkgICAgICAgICAgICBjb25zdCB7IGlkLCBjb21tYW5kLCBtZXNzYWdlIH0gPSBtc2c7CgkgICAgICAgICAgICBzdWJDbGFzcyA9IG5ldyBsaWJyYXJpZXNbY29tbWFuZF0obWVzc2FnZVswXSwgbWVzc2FnZVsxXSk7CgkgICAgICAgICAgICAvLyByZXR1cm4gdGhlIGNsYXNzJyBtZXRob2RzCgkgICAgICAgICAgICBjb25zdCBmbnMgPSBbCgkgICAgICAgICAgICAgICAgLi4uT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMobGlicmFyaWVzW2NvbW1hbmRdLnByb3RvdHlwZSksCgkgICAgICAgICAgICAgICAgLi4uT2JqZWN0LmtleXMoc3ViQ2xhc3MpCgkgICAgICAgICAgICBdLm1hcChrZXkgPT4gW2tleSwgdHlwZW9mIGxpYnJhcmllc1tjb21tYW5kXS5wcm90b3R5cGVba2V5XV0pCgkgICAgICAgICAgICAgICAgLnJlZHVjZSgoYSwgYykgPT4gKHsgLi4uYSwgLi4ueyBbY1swXV06IGNbMV0gfSB9KSwge30pOwoJICAgICAgICAgICAgcG9zdChpZCwgdW5kZWZpbmVkLCBmbnMsICdpbml0X3Jlc3BvbnNlJyk7CgkgICAgICAgIH0sCgkgICAgICAgICdnZXQnOiBmdW5jdGlvbiAobXNnKSB7CgkgICAgICAgICAgICBjb25zdCB7IGlkLCBjb21tYW5kIH0gPSBtc2c7CgkgICAgICAgICAgICBpZiAoc3ViQ2xhc3MgJiYgc3ViQ2xhc3NbY29tbWFuZF0pIHsKCSAgICAgICAgICAgICAgICBwb3N0KGlkLCB1bmRlZmluZWQsIHN1YkNsYXNzW2NvbW1hbmRdKTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgICAgIGVsc2UgewoJICAgICAgICAgICAgICAgIHBvc3QoaWQsIHVuZGVmaW5lZCwgdW5kZWZpbmVkKTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfSwKCSAgICAgICAgJ2V4ZWMnOiBmdW5jdGlvbiAobXNnKSB7CgkgICAgICAgICAgICBjb25zdCB7IGlkLCBjb21tYW5kLCBtZXNzYWdlIH0gPSBtc2c7CgkgICAgICAgICAgICBpZiAoc3ViQ2xhc3MgJiYgc3ViQ2xhc3NbY29tbWFuZF0gJiYgdHlwZW9mIHN1YkNsYXNzW2NvbW1hbmRdID09PSAnZnVuY3Rpb24nKSB7CgkgICAgICAgICAgICAgICAgY29uc3QgY21kID0gc3ViQ2xhc3NbY29tbWFuZF0KCSAgICAgICAgICAgICAgICAgICAgLmFwcGx5KHN1YkNsYXNzLCBtZXNzYWdlKTsKCSAgICAgICAgICAgICAgICBpZiAoISFjbWQgJiYgdHlwZW9mIGNtZC50aGVuID09PSAnZnVuY3Rpb24nKSB7CgkgICAgICAgICAgICAgICAgICAgIC8vIEl0J3MgYSBwcm9taXNlLCBzbyB3YWl0IGZvciBpdAoJICAgICAgICAgICAgICAgICAgICBjbWQKCSAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKHJlcyA9PiBwb3N0KGlkLCB1bmRlZmluZWQsIHJlcykpCgkgICAgICAgICAgICAgICAgICAgICAgICAuY2F0Y2goZSA9PiBwb3N0KGlkLCBlKSk7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgICAgIGVsc2UgewoJICAgICAgICAgICAgICAgICAgICAvLyBOb3QgYSBwcm9taXNlLCBqdXN0IHJldHVybiBpdAoJICAgICAgICAgICAgICAgICAgICBwb3N0KGlkLCB1bmRlZmluZWQsIGNtZCk7CgkgICAgICAgICAgICAgICAgfQoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgZWxzZSB7CgkgICAgICAgICAgICAgICAgLy8gRXJyb3IKCSAgICAgICAgICAgICAgICBwb3N0KGlkLCBuZXcgRXJyb3IoYGNvbW1hbmQgIiR7Y29tbWFuZH0iIG5vdCBmb3VuZGApKTsKCSAgICAgICAgICAgIH0KCSAgICAgICAgfQoJICAgIH07CgkgICAgaWYgKGNvbW1hbmRzW2RhdGEudHlwZV0pIHsKCSAgICAgICAgY29tbWFuZHNbZGF0YS50eXBlXShkYXRhKTsKCSAgICB9Cgl9KTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdvcmtlci5qcy5tYXAKCg==",Kn?Wo(Oo):function(gt,bt,ct){var Bt;return function(Kt){return Bt=Bt||an(gt),new Worker(Bt,Kt)}}(Oo));let Tr=()=>Math.random().toString(36).substring(2);class zo{constructor(bt,ct){this.initId=Tr()+"-"+bt,this.worker=new Gs,this.handlers=new Map,this.worker.onmessage=Bt=>{let Kt=Bt.data,Yt=this.handlers.get(Kt.id),ae=this;if(Yt){if(Kt.type==="response"&&Yt.resolve(Kt.message),Kt.type==="error"){let we=Kt.error||new Error(`Unknown error with ${bt}`);Yt.reject(we)}Kt.type==="init_response"&&(this._=Object.keys(Kt.message).map(we=>{let ve=typeof Kt.message[we]=="function";return[we,function(){return ve?ae.exec(we)(...arguments):ae.get(we)}]}).reduce((we,ve)=>({...we,[ve[0]]:ve[1]}),{}),Yt.resolve(this._))}},this.worker.postMessage({type:"init",id:this.initId,command:bt,message:ct})}onLoad(){return new Promise(bt=>{this._===void 0?this.handlers.set(this.initId,{resolve:bt,reject:bt}):bt(this._)})}exec(bt){let ct=this;return function(...Bt){return new Promise((Kt,Yt)=>{let ae=Tr()+"-"+bt;ct.handlers.set(ae,{resolve:Kt,reject:Yt}),ct.worker.postMessage({type:"exec",id:ae,command:bt,message:[...Bt]})})}}get(bt){return new Promise((ct,Bt)=>{let Kt=Tr()+"-"+bt;this.handlers.set(Kt,{resolve:ct,reject:Bt}),this.worker.postMessage({type:"get",id:Kt,command:bt,message:[]})})}}let Ur=new URL("test://http://example.com").href!=="test://http://example.com";async function Qr(gt,bt,ct){let Bt=await fetch(gt,ct?{signal:ct.signal}:void 0),Kt={},Yt=new URL(gt,window.location.href);if(Yt.hash.length){let ae=Yt.hash,we=decodeURIComponent(ae.slice(1));try{Kt=JSON.parse(we)}catch(ve){console.warn("Error parsing or reading URL:",ve)}}if(Bt.status==200){let ae=await Bt.text(),we;return["kml","tcx","gpx"].includes(bt)||!(()=>{let ve=!1;try{ve=typeof window.Worker=="function"}catch{ve=!1}return ve})()?we=new bs(bt,ae,Kt).convert():we=new zo("Converter",[bt,ae,Kt]).exec("convert")(),await we}throw new Error(`Data fetch error: ${Bt.statusText}`)}let vs=gt=>{let bt=gt.split("://")[0],ct=gt.replace(new RegExp(`^${bt}://`),""),Bt=Ur?(Kt=>{let Yt=new RegExp("^(https?)(//)");return Kt.replace(Yt,"$1:$2")})(ct):ct;return{prefix:bt,url:Bt}},_n=(gt,bt)=>bt instanceof AbortController?(async(ct,Bt)=>{let{prefix:Kt,url:Yt}=vs(ct.url);if(!Yt)throw new Error("Invalid URL: "+ct.url);try{return{data:await Qr(Yt,Kt,Bt)}}catch(ae){throw new Error(ae||"Unknown Error")}})(gt,bt):((ct,Bt)=>{let Kt=new AbortController,{prefix:Yt,url:ae}=vs(ct.url);return ae&&Qr(ae,Yt,Kt).then(we=>Bt(null,we)).catch(we=>Bt(we)),{cancel:()=>{Kt.abort()}}})(gt,bt),Bo=Zr;r.VectorTextProtocol=_n,r.addOptions=(gt,bt)=>{try{let ct=new URL(gt);return ct.hash=`#${encodeURIComponent(JSON.stringify(bt))}`,ct.toString()}catch(ct){return console.error("Error parsing or updating URL:",ct),gt}},r.addProtocols=gt=>{Zr.forEach(bt=>{gt.addProtocol(bt,_n)})},r.processData=Qr,r.vectorFormats=Bo})});var Ym=la((kK,cb)=>{cb.exports=w3;var v3=Object.prototype.hasOwnProperty;function w3(){for(var r={},t=0;t{(function(){var r=this,t={};typeof ub<"u"?hb.exports=t:r.fuzzy=t,t.simpleFilter=function(i,s){return s.filter(function(A){return t.test(i,A)})},t.test=function(i,s){return t.match(i,s)!==null},t.match=function(i,s,A){A=A||{};var o=0,g=[],d=s.length,C=0,v=0,x=A.pre||"",T=A.post||"",G=A.caseSensitive&&s||s.toLowerCase(),k;i=A.caseSensitive&&i||i.toLowerCase();for(var W=0;W{"use strict";var Mo=function(r){return this.component=r,this.items=[],this.active=r.options.noInitialSelection?-1:0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,r.el.parentNode.insertBefore(this.wrapper,r.el.nextSibling),this};Mo.prototype.show=function(){this.element.style.display="block"};Mo.prototype.hide=function(){this.element.style.display="none"};Mo.prototype.add=function(r){this.items.push(r)};Mo.prototype.clear=function(){this.items=[],this.active=this.component.options.noInitialSelection?-1:0};Mo.prototype.isEmpty=function(){return!this.items.length};Mo.prototype.isVisible=function(){return this.element.style.display==="block"};Mo.prototype.draw=function(){if(this.element.innerHTML="",this.items.length===0){this.hide();return}for(var r=0;r=this.items.length-1?0:this.active+1)};Mo.prototype.drawError=function(r){var t=document.createElement("li");t.innerHTML=r,this.element.appendChild(t),this.show()};db.exports=Mo});var mb=la((EK,fb)=>{"use strict";var B3=Ym(),_3=gb(),x3=pb(),zs=function(r,t,i){return i=i||{},this.options=B3({minLength:2,limit:5,filter:!0,hideOnBlur:!0,noInitialSelection:!0},i),this.el=r,this.data=t||[],this.list=new x3(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(s){this.handleKeyUp(s.keyCode,s)}.bind(this),!1),this.el.addEventListener("keydown",function(s){this.handleKeyDown(s)}.bind(this)),this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this)),this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this)),this.el.addEventListener("paste",function(s){this.handlePaste(s)}.bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};zs.prototype.handleKeyUp=function(r,t){if(!(r===40||r===38||r===27||r===9)){if(r===13){this.list.items[this.list.active]&&(this.list.handleMouseUp(this.list.items[this.list.active]),t.stopPropagation());return}this.handleInputChange(this.el.value)}};zs.prototype.handleKeyDown=function(r){switch(r.keyCode){case 13:this.list.active>=0&&(this.list.selectingListItem=!0);break;case 9:this.list.isEmpty()||(this.list.isVisible()&&r.preventDefault(),this.value(this.list.active>=0?this.list.items[this.list.active].original:null),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next();break}};zs.prototype.handleBlur=function(){!this.list.selectingListItem&&this.options.hideOnBlur&&this.list.hide()};zs.prototype.handlePaste=function(r){if(r.clipboardData)this.handleInputChange(r.clipboardData.getData("Text"));else{var t=this;setTimeout(function(){t.handleInputChange(r.target.value)},100)}};zs.prototype.handleInputChange=function(r){if(this.query=this.normalize(r),this.list.clear(),this.query.length-1};zs.prototype.value=function(r){if(this.selected=r,this.el.value=this.getItemValue(r||{place_name:this.query}),document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")};zs.prototype.getCandidates=function(r){var t={pre:"",post:"",extract:function(s){return this.getItemValue(s)}.bind(this)},i;this.options.filter?(i=_3.filter(this.query,this.data,t),i=i.map(function(s){return{original:s.original,string:this.render(s.original,s.string)}}.bind(this))):i=this.data.map(function(s){var A=this.render(s);return{original:s,string:A}}.bind(this)),r(i)};zs.prototype.getItemValue=function(r){return r};zs.prototype.render=function(r,t){if(t)return t;for(var i=r.original?this.getItemValue(r.original):this.getItemValue(r),s=this.normalize(i),A=s.lastIndexOf(this.query);A>-1;){var o=A+this.query.length;i=i.slice(0,A)+""+i.slice(A,o)+""+i.slice(o),A=s.slice(0,A).lastIndexOf(this.query)}return i};zs.prototype.renderError=function(r){this.list.drawError(r)};fb.exports=zs});var yb=la((TK,Ib)=>{"use strict";var Cb=mb();Ib.exports=Cb;typeof window<"u"&&(window.Suggestions=Cb)});var Bb=la((UK,wb)=>{var S3="Expected a function",bb=NaN,F3="[object Symbol]",k3=/^\s+|\s+$/g,L3=/^[-+]0x[0-9a-f]+$/i,E3=/^0b[01]+$/i,T3=/^0o[0-7]+$/i,U3=parseInt,Q3=typeof global=="object"&&global&&global.Object===Object&&global,G3=typeof self=="object"&&self&&self.Object===Object&&self,R3=Q3||G3||Function("return this")(),H3=Object.prototype,Z3=H3.toString,P3=Math.max,M3=Math.min,jm=function(){return R3.Date.now()};function N3(r,t,i){var s,A,o,g,d,C,v=0,x=!1,T=!1,G=!0;if(typeof r!="function")throw new TypeError(S3);t=vb(t)||0,qm(i)&&(x=!!i.leading,T="maxWait"in i,o=T?P3(vb(i.maxWait)||0,t):o,G="trailing"in i?!!i.trailing:G);function k(Ut){var Ft=s,vt=A;return s=A=void 0,v=Ut,g=r.apply(vt,Ft),g}function W(Ut){return v=Ut,d=setTimeout(O,t),x?k(Ut):g}function K(Ut){var Ft=Ut-C,vt=Ut-v,Jt=t-Ft;return T?M3(Jt,o-vt):Jt}function $(Ut){var Ft=Ut-C,vt=Ut-v;return C===void 0||Ft>=t||Ft<0||T&&vt>=o}function O(){var Ut=jm();if($(Ut))return tt(Ut);d=setTimeout(O,K(Ut))}function tt(Ut){return d=void 0,G&&s?k(Ut):(s=A=void 0,g)}function at(){d!==void 0&&clearTimeout(d),v=0,s=C=A=d=void 0}function Lt(){return d===void 0?g:tt(jm())}function Tt(){var Ut=jm(),Ft=$(Ut);if(s=arguments,A=this,C=Ut,Ft){if(d===void 0)return W(C);if(T)return d=setTimeout(O,t),k(C)}return d===void 0&&(d=setTimeout(O,t)),g}return Tt.cancel=at,Tt.flush=Lt,Tt}function qm(r){var t=typeof r;return!!r&&(t=="object"||t=="function")}function V3(r){return!!r&&typeof r=="object"}function D3(r){return typeof r=="symbol"||V3(r)&&Z3.call(r)==F3}function vb(r){if(typeof r=="number")return r;if(D3(r))return bb;if(qm(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=qm(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=r.replace(k3,"");var i=E3.test(r);return i||T3.test(r)?U3(r.slice(2),i?2:8):L3.test(r)?bb:+r}wb.exports=N3});var Gb=la((QK,$m)=>{"use strict";var Bu=typeof Reflect=="object"?Reflect:null,_b=Bu&&typeof Bu.apply=="function"?Bu.apply:function(t,i,s){return Function.prototype.apply.call(t,i,s)},Cd;Bu&&typeof Bu.ownKeys=="function"?Cd=Bu.ownKeys:Object.getOwnPropertySymbols?Cd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Cd=function(t){return Object.getOwnPropertyNames(t)};function K3(r){console&&console.warn&&console.warn(r)}var Sb=Number.isNaN||function(t){return t!==t};function qr(){qr.init.call(this)}$m.exports=qr;$m.exports.once=J3;qr.EventEmitter=qr;qr.prototype._events=void 0;qr.prototype._eventsCount=0;qr.prototype._maxListeners=void 0;var xb=10;function Id(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(qr,"defaultMaxListeners",{enumerable:!0,get:function(){return xb},set:function(r){if(typeof r!="number"||r<0||Sb(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");xb=r}});qr.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};qr.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Sb(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Fb(r){return r._maxListeners===void 0?qr.defaultMaxListeners:r._maxListeners}qr.prototype.getMaxListeners=function(){return Fb(this)};qr.prototype.emit=function(t){for(var i=[],s=1;s0&&(g=i[0]),g instanceof Error)throw g;var d=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw d.context=g,d}var C=o[t];if(C===void 0)return!1;if(typeof C=="function")_b(C,this,i);else for(var v=C.length,x=Ub(C,v),s=0;s0&&g.length>A&&!g.warned){g.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=r,d.type=t,d.count=g.length,K3(d)}return r}qr.prototype.addListener=function(t,i){return kb(this,t,i,!1)};qr.prototype.on=qr.prototype.addListener;qr.prototype.prependListener=function(t,i){return kb(this,t,i,!0)};function W3(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Lb(r,t,i){var s={fired:!1,wrapFn:void 0,target:r,type:t,listener:i},A=W3.bind(s);return A.listener=i,s.wrapFn=A,A}qr.prototype.once=function(t,i){return Id(i),this.on(t,Lb(this,t,i)),this};qr.prototype.prependOnceListener=function(t,i){return Id(i),this.prependListener(t,Lb(this,t,i)),this};qr.prototype.removeListener=function(t,i){var s,A,o,g,d;if(Id(i),A=this._events,A===void 0)return this;if(s=A[t],s===void 0)return this;if(s===i||s.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete A[t],A.removeListener&&this.emit("removeListener",t,s.listener||i));else if(typeof s!="function"){for(o=-1,g=s.length-1;g>=0;g--)if(s[g]===i||s[g].listener===i){d=s[g].listener,o=g;break}if(o<0)return this;o===0?s.shift():O3(s,o),s.length===1&&(A[t]=s[0]),A.removeListener!==void 0&&this.emit("removeListener",t,d||i)}return this};qr.prototype.off=qr.prototype.removeListener;qr.prototype.removeAllListeners=function(t){var i,s,A;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var o=Object.keys(s),g;for(A=0;A=0;A--)this.removeListener(t,i[A]);return this};function Eb(r,t,i){var s=r._events;if(s===void 0)return[];var A=s[t];return A===void 0?[]:typeof A=="function"?i?[A.listener||A]:[A]:i?z3(A):Ub(A,A.length)}qr.prototype.listeners=function(t){return Eb(this,t,!0)};qr.prototype.rawListeners=function(t){return Eb(this,t,!1)};qr.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):Tb.call(r,t)};qr.prototype.listenerCount=Tb;function Tb(r){var t=this._events;if(t!==void 0){var i=t[r];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}qr.prototype.eventNames=function(){return this._eventsCount>0?Cd(this._events):[]};function Ub(r,t){for(var i=new Array(t),s=0;s{Rb.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}});var Pb=la((RK,Zb)=>{"use strict";var Y3={de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"\u05DC\u05D7\u05E4\u05E9",ja:"\u30B5\u30FC\u30C1",lv:"Mekl\u0113t",pt:"Procurar",sr:"\u041F\u0440\u0435\u0442\u0440\u0430\u0433\u0430",zh:"\u641C\u7D22",cs:"Vyhled\xE1v\xE1n\xED",hu:"Keres\xE9s",ka:"\u10EB\u10D8\u10D4\u10D1\u10D0",nb:"S\xF8ke",sk:"Vyh\u013Ead\xE1vanie",th:"\u0E04\u0E49\u0E19\u0E2B\u0E32",fi:"Hae",is:"Leita",ko:"\uC218\uC0C9",pl:"Szukaj",sl:"Iskanje",fa:"\u062C\u0633\u062A\u062C\u0648",ru:"\u041F\u043E\u0438\u0441\u043A"};Zb.exports={placeholder:Y3}});var Nb=la((Mb,yd)=>{(function(r,t,i){typeof yd<"u"&&yd.exports?yd.exports=i():r[t]=i()})(Mb,"subtag",function(){var r="",t=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;function i(d){return d.match(t)||[]}function s(d){return i(d).filter(function(C,v){return C&&v})}function A(d){return d=i(d),{language:d[1]||r,extlang:d[2]||r,script:d[3]||r,region:d[4]||r}}function o(d,C,v){Object.defineProperty(d,C,{value:v,enumerable:!0})}function g(d,C,v){function x(T){return i(T)[d]||r}o(x,"pattern",C),o(A,v,x)}return g(1,/^[a-zA-Z]{2,3}$/,"language"),g(2,/^[a-zA-Z]{3}$/,"extlang"),g(3,/^[a-zA-Z]{4}$/,"script"),g(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),o(A,"split",s),A})});var Wb=la((HK,Kb)=>{"use strict";var j3=yb(),q3=Bb(),ca=Ym(),$3=Gb().EventEmitter,Vb=Hb(),tF=Pb(),eF=Nb();function Db(r,t){this._eventEmitter=new $3,this.options=ca({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null,this.geocoderApi=r}Db.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,showResultsWhileTyping:!1,minLength:2,reverseGeocode:!1,limit:5,enableEventLogging:!0,marker:!0,popup:!1,maplibregl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(r){return r.text!==void 0?r.text:r.place_name},render:function(r){if(r.geometry){var d=r.place_name.split(",");return'
'+d[0]+'
'+d.splice(1,d.length).join(",")+"
"}else{var t=r.text,i=t.toLowerCase().indexOf(this.query.toLowerCase()),s=this.query.length,A=t.substring(0,i),o=t.substring(i,i+s),g=t.substring(i+s);return'
'+A+''+o+""+g+"
"}},popupRender:function(r){var t=r.place_name.split(",");return'"},showResultMarkers:!0,debounceSearch:200},addTo:function(r){function t(s,A){if(!document.body.contains(A))throw new Error("Element provided to #addTo() exists, but is not in the DOM");var o=s.onAdd();A.appendChild(o)}if(r._controlContainer)r.addControl(this);else if(r instanceof HTMLElement)t(this,r);else if(typeof r=="string"){var i=document.querySelectorAll(r);if(i.length===0)throw new Error("Element ",r,"not found.");if(i.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,i[0])}else throw new Error("Error: addTo must be a maplibre-gl-js map, an html element, or a CSS selector query for a single html element")},onAdd:function(r){if(r&&typeof r!="string"&&(this._map=r),this.setLanguage(),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl maplibregl-ctrl-geocoder maplibregl-ctrl";var i=this.createIcon("search",'');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input maplibregl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",q3(this._onKeyDown,this.options.debounceSearch)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton);var s=document.createElement("div");s.classList.add("mapboxgl-ctrl-geocoder--pin-right","maplibregl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button maplibregl-ctrl-geocoder--button";var A=this.createIcon("close",'');return this._clearEl.appendChild(A),this._loadingEl=this.createIcon("loading",''),s.appendChild(this._clearEl),s.appendChild(this._loadingEl),t.appendChild(i),t.appendChild(this._inputEl),t.appendChild(s),this._typeahead=new j3(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit,noInitialSelection:!0}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this.resultMarkers=[],this._handleMarker=this._handleMarker.bind(this),this._handleResultMarkers=this._handleResultMarkers.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._maplibregl=this.options.maplibregl,!this._maplibregl&&this.options.marker&&(console.error("No maplibregl detected in options. Map markers are disabled. Please set options.maplibregl."),this.options.marker=!1)),t},createIcon:function(r,t){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+r+" maplibregl-ctrl-geocoder--icon maplibregl-ctrl-geocoder--icon-"+r),i.setAttribute("viewBox","0 0 18 18"),i.setAttribute("xml:space","preserve"),i.setAttribute("width",18),i.setAttribute("height",18),"innerHTML"in i)i.innerHTML=t;else{var s=document.createElement("div");s.innerHTML=""+t.valueOf().toString()+"";var A=s.firstChild,o=A.firstChild;i.appendChild(o)}return i},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onPaste:function(r){var t=(r.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(t)},_onKeyDown:function(r){var t=27,i=9;if(r.keyCode===t&&this.options.clearAndBlurOnEsc)return this._clear(r),this._inputEl.blur();var s=r.target&&r.target.shadowRoot?r.target.shadowRoot.activeElement:r.target,A=s?s.value:"";if(!A)return this.fresh=!0,r.keyCode!==i&&this.clear(r),this._clearEl.style.display="none";if(!(r.metaKey||[i,t,37,39,38,40].indexOf(r.keyCode)!==-1)){if(r.keyCode===13)if(!this.options.showResultsWhileTyping)this._typeahead.selected||this._geocode(s.value);else{this._typeahead.selected==null&&this.geocoderApi.getSuggestions?this._geocode(s.value,!0):this._typeahead.selected==null&&this.options.showResultMarkers&&this._fitBoundsForMarkers();return}s.value.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(s.value)}},_showButton:function(){this._inputEl.value.length>0&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(r){this.options.clearOnBlur&&this._clearOnBlur(r),this.options.collapsed&&this._collapse()},_onChange:function(){var r=this._typeahead.selected;if(r&&!r.geometry)r.placeId?this._geocode(r.placeId,!0,!0):this._geocode(r.text,!0);else if(r&&JSON.stringify(r)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var t;if(this._removeResultMarkers(),r.properties&&Vb[r.properties.short_code])t=ca({},this.options.flyTo),this._map&&this._map.fitBounds(Vb[r.properties.short_code].bbox,t);else if(r.bbox){var i=r.bbox;t=ca({},this.options.flyTo),this._map&&this._map.fitBounds([[i[0],i[1]],[i[2],i[3]]],t)}else{var s={zoom:this.options.zoom};t=ca({},s,this.options.flyTo),r.center?t.center=r.center:r.geometry&&r.geometry.type&&r.geometry.type==="Point"&&r.geometry.coordinates&&(t.center=r.geometry.coordinates),this._map&&this._map.flyTo(t)}}this.options.marker&&this._maplibregl&&this._handleMarker(r),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(r),this._typeahead.selected=null,this._eventEmitter.emit("result",{result:r})}},_getConfigForRequest:function(){var r=["bbox","limit","proximity","countries","types","language","reverseMode"],t=this,i=r.reduce(function(s,A){return t.options[A]&&(["countries","types","language"].indexOf(A)>-1?s[A]=t.options[A].split(/[\s,]+/):s[A]=t.options[A],A==="proximity"&&t.options[A]&&typeof t.options[A].longitude=="number"&&typeof t.options[A].latitude=="number"&&(s[A]=[t.options[A].longitude,t.options[A].latitude])),s},{});return i},_geocode:function(r,t,i){this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:r}),this.inputString=r;var s=null,A=this._getConfigForRequest(),o;if(this.options.localGeocoderOnly)o=Promise.resolve();else if(this.options.reverseGeocode&&/(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(r)){var g=r.split(/[\s(,)?]+/).map(function(v){return parseFloat(v,10)}).reverse();A.types&&A.types[0],A=ca(A,{query:g,limit:1}),"proximity"in A&&delete A.proximity,o=this.geocoderApi.reverseGeocode(A)}else A=ca(A,{query:r}),this.geocoderApi.getSuggestions?t?this.geocoderApi.searchByPlaceId&&i?o=this.geocoderApi.searchByPlaceId(A):o=this.geocoderApi.forwardGeocode(A):o=this.geocoderApi.getSuggestions(A):o=this.geocoderApi.forwardGeocode(A);var d=[];this.options.localGeocoder&&(d=this.options.localGeocoder(r),d||(d=[]));var C=[];return o.catch(function(v){s=v}.bind(this)).then(function(v){this._loadingEl.style.display="none";var x={};return v?x=v:x={type:"FeatureCollection",features:[]},x.config=A,this.fresh&&(this.fresh=!1),x.features=x.features?d.concat(x.features):d,this.options.externalGeocoder?(C=this.options.externalGeocoder(r,x.features,A)||[],C.then(function(T){return x.features=x.features?T.concat(x.features):T,x},function(){return x})):x}.bind(this)).then(function(v){if(s)throw s;this.options.filter&&v.features.length&&(v.features=v.features.filter(this.options.filter));var x=[];v.suggestions?x=v.suggestions:v.place?x=[v.place]:x=v.features,x.length?(this._clearEl.style.display="block",this._typeahead.update(x),(!this.options.showResultsWhileTyping||t)&&this.options.showResultMarkers&&(v.features.length>0||v.place)&&this._fitBoundsForMarkers(),this._eventEmitter.emit("results",v)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",v))}.bind(this)).catch(function(v){this._loadingEl.style.display="none",d.length&&this.options.localGeocoder||C.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(d)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:d}),this._eventEmitter.emit("error",{error:v})}.bind(this)),o},_clear:function(r){r&&r.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this._removeResultMarkers(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(r){this._clear(r),this._inputEl.focus()},_clearOnBlur:function(r){var t=this;r.relatedTarget&&t._clear(r)},_onQueryResult:function(r){var t=r;if(!!t.features.length){var i=t.features[0];this._typeahead.selected=i,this._inputEl.value=i.place_name,this._onChange()}},_updateProximity:function(){if(!!this._map)if(this._map.getZoom()>9){var r=this._map.getCenter().wrap();this.setProximity({longitude:r.lng,latitude:r.lat})}else this.setProximity(null)},_collapse:function(){!this._inputEl.value&&this._inputEl!==document.activeElement&&this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed","maplibregl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed","maplibregl-ctrl-geocoder--collapsed")},query:function(r){return this._geocode(r).then(this._onQueryResult),this},_renderError:function(){var r="
There was an error reaching the server
";this._renderMessage(r)},_renderNoResults:function(){var r="
No results found
";this._renderMessage(r)},_renderMessage:function(r){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(r)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var r=this.options.language.split(",")[0],t=eF.language(r),i=tF.placeholder[t];if(i)return i}return"Search"},_fitBoundsForMarkers:function(){if(!(this._typeahead.data.length<1)){var r=this._typeahead.data.filter(function(A){return typeof A!="string"}).slice(0,this.options.limit);if(this._clearEl.style.display="none",this.options.flyTo&&this._maplibregl&&this._map){var t={padding:100},i=ca({},t,this.options.flyTo),s=new this._maplibregl.LngLatBounds;r.forEach(function(A){s.extend(A.geometry.coordinates)}),this._map.fitBounds(s.toArray(),i)}return r.length>0&&this._maplibregl&&this._handleResultMarkers(r),this}},setInput:function(r){return this._inputEl.value=r,this._typeahead.selected=null,this._typeahead.clear(),r.length>=this.options.minLength&&this.options.showResultsWhileTyping&&this._geocode(r),this},setProximity:function(r){return this.options.proximity=r,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(r){return r&&typeof r=="function"&&(this._typeahead.render=r),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(r){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=r||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(r){return this.options.zoom=r,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(r){return this.options.flyTo=r,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(r){return this.placeholder=r||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(r){return this.options.bbox=r,this},getCountries:function(){return this.options.countries},setCountries:function(r){return this.options.countries=r,this},getTypes:function(){return this.options.types},setTypes:function(r){return this.options.types=r,this},getMinLength:function(){return this.options.minLength},setMinLength:function(r){return this.options.minLength=r,this._typeahead&&(this._typeahead.options.minLength=r),this},getLimit:function(){return this.options.limit},setLimit:function(r){return this.options.limit=r,this._typeahead&&(this._typeahead.options.limit=r),this},getFilter:function(){return this.options.filter},setFilter:function(r){return this.options.filter=r,this},setGeocoderApi:function(r){return this.geocoderApi=r,this},getGeocoderApi:function(){return this.geocoderApi},_handleMarker:function(r){if(!!this._map){this._removeMarker();var t={color:"#4668F2"},i=ca({},t,this.options.marker);this.mapMarker=new this._maplibregl.Marker(i);var s;if(this.options.popup){var A={},o=ca({},A,this.options.popup);s=new this._maplibregl.Popup(o).setHTML(this.options.popupRender(r))}return r.center?(this.mapMarker.setLngLat(r.center).addTo(this._map),this.options.popup&&this.mapMarker.setPopup(s)):r.geometry&&r.geometry.type&&r.geometry.type==="Point"&&r.geometry.coordinates&&(this.mapMarker.setLngLat(r.geometry.coordinates).addTo(this._map),this.options.popup&&this.mapMarker.setPopup(s)),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},_handleResultMarkers:function(r){if(!!this._map){this._removeResultMarkers();var t={color:"#4668F2"},i=ca({},t,this.options.showResultMarkers);return r.forEach(function(s){if(this.options.showResultMarkers&&this.options.showResultMarkers.element){var A=this.options.showResultMarkers.element.cloneNode(!0);i=ca(i,{element:A})}var o=new this._maplibregl.Marker(ca({},i,{element:A})),g;if(this.options.popup){var d={},C=ca({},d,this.options.popup);g=new this._maplibregl.Popup(C).setHTML(this.options.popupRender(s))}s.center?(o.setLngLat(s.center).addTo(this._map),this.options.popup&&o.setPopup(g)):s.geometry&&s.geometry.type&&s.geometry.type==="Point"&&s.geometry.coordinates&&(o.setLngLat(s.geometry.coordinates).addTo(this._map),this.options.popup&&o.setPopup(g)),this.resultMarkers.push(o)}.bind(this)),this}},_removeResultMarkers:function(){this.resultMarkers&&this.resultMarkers.length>0&&(this.resultMarkers.forEach(function(r){r.remove()}),this.resultMarkers=[])},on:function(r,t){return this._eventEmitter.on(r,t),this},off:function(r,t){return this._eventEmitter.removeListener(r,t),this}};Kb.exports=Db});var X2={};Om(X2,{default:()=>BT});function $a(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");yC(r,t);function i(){this.constructor=r}r.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function mo(r,t,i,s){function A(o){return o instanceof i?o:new i(function(g){g(o)})}return new(i||(i=Promise))(function(o,g){function d(x){try{v(s.next(x))}catch(T){g(T)}}function C(x){try{v(s.throw(x))}catch(T){g(T)}}function v(x){x.done?o(x.value):A(x.value).then(d,C)}v((s=s.apply(r,t||[])).next())})}function Js(r,t){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,A,o,g;return g={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function d(v){return function(x){return C([v,x])}}function C(v){if(s)throw new TypeError("Generator is already executing.");for(;i;)try{if(s=1,A&&(o=v[0]&2?A.return:v[0]?A.throw||((o=A.return)&&o.call(A),0):A.next)&&!(o=o.call(A,v[1])).done)return o;switch(A=0,o&&(v=[v[0]&2,o.value]),v[0]){case 0:case 1:o=v;break;case 4:return i.label++,{value:v[1],done:!1};case 5:i.label++,A=v[1],v=[0];continue;case 7:v=i.ops.pop(),i.trys.pop();continue;default:if(o=i.trys,!(o=o.length>0&&o[o.length-1])&&(v[0]===6||v[0]===2)){i=0;continue}if(v[0]===3&&(!o||v[1]>o[0]&&v[1]=1&&(i-=1),i<1/6?(t-r)*i*6+r:i<1/2?t:i<2/3?(t-r)*6*(2/3-i)+r:r}function ik(r){return!(r.type===20&&r.value==="none")&&(r.type!==18||!!w2[r.name])}var yC,bC,vl,$d,iF,tp,Rn,Ob,rF,Zh,zb,zh,Ph,nF,sF,oF,Hc,DC,tC,aF,Ov,AF,eC,lF,cF,uF,hF,gF,dF,pF,fF,Jb,mF,CF,IF,Xb,yF,Mh,bF,Yb,vF,zv,Jv,wF,BF,jb,Xv,qb,ic,vC,$b,wC,_F,Jh,BC,vd,Nh,xF,tv,_C,Vh,iC,_u,ua,Xh,Yh,xu,SF,Uu,FF,wd,Bd,xC,SC,FC,sg,kC,Pd,Md,rC,Yv,kF,LF,jv,fo,_d,LC,Il,EC,qv,ev,EF,iv,TF,UF,nC,rv,QF,GF,RF,HF,ZF,PF,Ag,nv,Dd,sv,tg,MF,NF,xd,Dh,VF,DF,KF,Sd,Fd,Kh,WF,No,OF,zF,JF,XF,YF,jF,qF,$F,kd,t4,ov,e4,i4,av,sC,Gc,r4,n4,s4,og,o4,a4,A4,l4,c4,u4,DA,$v,t2,e2,h4,g4,d4,i2,r2,n2,p4,f4,Co,m4,Su,C4,I4,y4,b4,Ld,Kd,Av,v4,ec,Ed,oC,w4,B4,_4,x4,S4,F4,k4,L4,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fC,RE,HE,ZE,PE,ME,MC,NC,Vv,NE,VE,V2,DE,KE,WE,OE,zE,mC,JE,CC,XE,yi,ku,Gd,wa,YE,Wr,Cn,Yd,jE,jd,qE,Rd,$E,tT,D2,eT,Dv,iT,K2,W2,VC,O2,rT,Kv,nT,sT,oT,Hd,_a,z2,qd,aT,AT,IC,Lu,Zd,lT,Tu,cT,uT,Wv,hT,J2,gT,dT,pT,fT,mT,CT,IT,yT,bT,vT,wT,BT,_T,xT,Y2=dd(()=>{yC=function(r,t){return yC=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,s){i.__proto__=s}||function(i,s){for(var A in s)Object.prototype.hasOwnProperty.call(s,A)&&(i[A]=s[A])},yC(r,t)};bC=function(){return bC=Object.assign||function(r){for(var t,i=1,s=arguments.length;i=55296&&A<=56319&&i>10)+55296,g%1024+56320)),(A+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Ob="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rF=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Zh=0;Zh"u"?[]:new Uint8Array(256);for(Ph=0;Ph>4,x[A++]=(g&15)<<4|d>>2,x[A++]=(d&3)<<6|C&63;return v},sF=function(r){for(var t=r.length,i=[],s=0;s>Hc,AF=1<>Hc,cF=Ov+lF,uF=cF,hF=32,gF=uF+hF,dF=65536>>DC,pF=1<=0){if(t<55296||t>56319&&t<=65535)return i=this.index[t>>Hc],i=(i<>Hc)],i=(i<>DC),i=this.index[i],i+=t>>Hc&fF,i=this.index[i],i=(i<"u"?[]:new Uint8Array(256);for(Mh=0;MhYb?(A.push(!0),d-=Yb):A.push(!1),["normal","auto","loose"].indexOf(t)!==-1&&[8208,8211,12316,12448].indexOf(o)!==-1)return s.push(g),i.push(BC);if(d===wF||d===vC){if(g===0)return s.push(g),i.push(Uu);var C=i[g-1];return EF.indexOf(C)===-1?(s.push(s[g-1]),i.push(C)):(s.push(g),i.push(Uu))}if(s.push(g),d===FF)return i.push(t==="strict"?_C:sg);if(d===Yv||d===SF)return i.push(Uu);if(d===kF)return o>=131072&&o<=196605||o>=196608&&o<=262141?i.push(sg):i.push(Uu);i.push(d)}),[s,i,A]},nC=function(r,t,i,s){var A=s[i];if(Array.isArray(r)?r.indexOf(A)!==-1:r===A)for(var o=i;o<=s.length;){o++;var g=s[o];if(g===t)return!0;if(g!==ic)break}if(A===ic)for(var o=i;o>0;){o--;var d=s[o];if(Array.isArray(r)?r.indexOf(d)!==-1:r===d)for(var C=i;C<=s.length;){C++;var g=s[C];if(g===t)return!0;if(g!==ic)break}if(d!==ic)break}return!1},rv=function(r,t){for(var i=r;i>=0;){var s=t[i];if(s===ic)i--;else return s}return 0},QF=function(r,t,i,s,A){if(i[s]===0)return fo;var o=s-1;if(Array.isArray(A)&&A[o]===!0)return fo;var g=o-1,d=o+1,C=t[o],v=g>=0?t[g]:0,x=t[d];if(C===zv&&x===Jv)return fo;if(EC.indexOf(C)!==-1)return jv;if(EC.indexOf(x)!==-1||qv.indexOf(x)!==-1)return fo;if(rv(o,t)===Xv)return _d;if(LC.get(r[o])===vC||(C===wd||C===Bd)&&LC.get(r[d])===vC||C===jb||x===jb||C===qb||[ic,wC,Jh].indexOf(C)===-1&&x===qb||[vd,Nh,xF,_u,xu].indexOf(x)!==-1||rv(o,t)===Vh||nC(iC,Vh,o,t)||nC([vd,Nh],_C,o,t)||nC($b,$b,o,t))return fo;if(C===ic)return _d;if(C===iC||x===iC)return fo;if(x===BC||C===BC)return _d;if([wC,Jh,_C].indexOf(x)!==-1||C===_F||v===FC&&TF.indexOf(C)!==-1||C===xu&&x===FC||x===tv||Il.indexOf(x)!==-1&&C===ua||Il.indexOf(C)!==-1&&x===ua||C===Yh&&[sg,wd,Bd].indexOf(x)!==-1||[sg,wd,Bd].indexOf(C)!==-1&&x===Xh||Il.indexOf(C)!==-1&&ev.indexOf(x)!==-1||ev.indexOf(C)!==-1&&Il.indexOf(x)!==-1||[Yh,Xh].indexOf(C)!==-1&&(x===ua||[Vh,Jh].indexOf(x)!==-1&&t[d+1]===ua)||[Vh,Jh].indexOf(C)!==-1&&x===ua||C===ua&&[ua,xu,_u].indexOf(x)!==-1)return fo;if([ua,xu,_u,vd,Nh].indexOf(x)!==-1)for(var T=o;T>=0;){var G=t[T];if(G===ua)return fo;if([xu,_u].indexOf(G)!==-1)T--;else break}if([Yh,Xh].indexOf(x)!==-1)for(var T=[vd,Nh].indexOf(C)!==-1?g:o;T>=0;){var G=t[T];if(G===ua)return fo;if([xu,_u].indexOf(G)!==-1)T--;else break}if(kC===C&&[kC,Pd,xC,SC].indexOf(x)!==-1||[Pd,xC].indexOf(C)!==-1&&[Pd,Md].indexOf(x)!==-1||[Md,SC].indexOf(C)!==-1&&x===Md||iv.indexOf(C)!==-1&&[tv,Xh].indexOf(x)!==-1||iv.indexOf(x)!==-1&&C===Yh||Il.indexOf(C)!==-1&&Il.indexOf(x)!==-1||C===_u&&Il.indexOf(x)!==-1||Il.concat(ua).indexOf(C)!==-1&&x===Vh&&LF.indexOf(r[d])===-1||Il.concat(ua).indexOf(x)!==-1&&C===Nh)return fo;if(C===rC&&x===rC){for(var k=i[o],W=1;k>0&&(k--,t[k]===rC);)W++;if(W%2!==0)return fo}return C===wd&&x===Bd?fo:_d},GF=function(r,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=UF(r,t.lineBreak),s=i[0],A=i[1],o=i[2];(t.wordBreak==="break-all"||t.wordBreak==="break-word")&&(A=A.map(function(d){return[ua,Uu,Yv].indexOf(d)!==-1?sg:d}));var g=t.wordBreak==="keep-all"?o.map(function(d,C){return d&&r[C]>=19968&&r[C]<=40959}):void 0;return[s,A,g]},RF=function(){function r(t,i,s,A){this.codePoints=t,this.required=i===jv,this.start=s,this.end=A}return r.prototype.slice=function(){return Rn.apply(void 0,this.codePoints.slice(this.start,this.end))},r}(),HF=function(r,t){var i=tp(r),s=GF(i,t),A=s[0],o=s[1],g=s[2],d=i.length,C=0,v=0;return{next:function(){if(v>=d)return{done:!0,value:null};for(var x=fo;v=$v&&r<=57},m4=function(r){return r>=55296&&r<=57343},Su=function(r){return Co(r)||r>=i2&&r<=n2||r>=t2&&r<=h4},C4=function(r){return r>=t2&&r<=d4},I4=function(r){return r>=i2&&r<=f4},y4=function(r){return C4(r)||I4(r)},b4=function(r){return r>=i4},Ld=function(r){return r===Dd||r===MF||r===NF},Kd=function(r){return y4(r)||b4(r)||r===WF},Av=function(r){return Kd(r)||Co(r)||r===No},v4=function(r){return r>=o4&&r<=a4||r===A4||r>=l4&&r<=c4||r===u4},ec=function(r,t){return r!==tg?!1:t!==Dd},Ed=function(r,t,i){return r===No?Kd(t)||ec(t,i):Kd(r)?!0:!!(r===tg&&ec(r,t))},oC=function(r,t,i){return r===Gc||r===No?Co(t)?!0:t===og&&Co(i):Co(r===og?t:r)},w4=function(r){var t=0,i=1;(r[t]===Gc||r[t]===No)&&(r[t]===No&&(i=-1),t++);for(var s=[];Co(r[t]);)s.push(r[t++]);var A=s.length?parseInt(Rn.apply(void 0,s),10):0;r[t]===og&&t++;for(var o=[];Co(r[t]);)o.push(r[t++]);var g=o.length,d=g?parseInt(Rn.apply(void 0,o),10):0;(r[t]===r2||r[t]===e2)&&t++;var C=1;(r[t]===Gc||r[t]===No)&&(r[t]===No&&(C=-1),t++);for(var v=[];Co(r[t]);)v.push(r[t++]);var x=v.length?parseInt(Rn.apply(void 0,v),10):0;return i*(A+d*Math.pow(10,-g))*Math.pow(10,C*x)},B4={type:2},_4={type:3},x4={type:4},S4={type:13},F4={type:8},k4={type:21},L4={type:9},E4={type:10},T4={type:11},U4={type:12},Q4={type:14},Td={type:23},G4={type:1},R4={type:25},H4={type:24},Z4={type:26},P4={type:27},M4={type:28},N4={type:29},V4={type:31},TC={type:32},s2=function(){function r(){this._value=[]}return r.prototype.write=function(t){this._value=this._value.concat(tp(t))},r.prototype.read=function(){for(var t=[],i=this.consumeToken();i!==TC;)t.push(i),i=this.consumeToken();return t},r.prototype.consumeToken=function(){var t=this.consumeCodePoint();switch(t){case xd:return this.consumeStringToken(xd);case VF:var i=this.peekCodePoint(0),s=this.peekCodePoint(1),A=this.peekCodePoint(2);if(Av(i)||ec(s,A)){var o=Ed(i,s,A)?PF:ZF,g=this.consumeName();return{type:5,value:g,flags:o}}break;case DF:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),S4;break;case Sd:return this.consumeStringToken(Sd);case Fd:return B4;case Kh:return _4;case sC:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),Q4;break;case Gc:if(oC(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case r4:return x4;case No:var d=t,C=this.peekCodePoint(0),v=this.peekCodePoint(1);if(oC(d,C,v))return this.reconsumeCodePoint(t),this.consumeNumericToken();if(Ed(d,C,v))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();if(C===No&&v===JF)return this.consumeCodePoint(),this.consumeCodePoint(),H4;break;case og:if(oC(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case sv:if(this.peekCodePoint(0)===sC)for(this.consumeCodePoint();;){var x=this.consumeCodePoint();if(x===sC&&(x=this.consumeCodePoint(),x===sv))return this.consumeToken();if(x===DA)return this.consumeToken()}break;case n4:return Z4;case s4:return P4;case zF:if(this.peekCodePoint(0)===OF&&this.peekCodePoint(1)===No&&this.peekCodePoint(2)===No)return this.consumeCodePoint(),this.consumeCodePoint(),R4;break;case XF:var T=this.peekCodePoint(0),G=this.peekCodePoint(1),k=this.peekCodePoint(2);if(Ed(T,G,k)){var g=this.consumeName();return{type:7,value:g}}break;case YF:return M4;case tg:if(ec(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();break;case jF:return N4;case qF:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),F4;break;case $F:return T4;case t4:return U4;case g4:case p4:var W=this.peekCodePoint(0),K=this.peekCodePoint(1);return W===Gc&&(Su(K)||K===kd)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(t),this.consumeIdentLikeToken();case ov:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),L4;if(this.peekCodePoint(0)===ov)return this.consumeCodePoint(),k4;break;case e4:if(this.peekCodePoint(0)===Dh)return this.consumeCodePoint(),E4;break;case DA:return TC}return Ld(t)?(this.consumeWhiteSpace(),V4):Co(t)?(this.reconsumeCodePoint(t),this.consumeNumericToken()):Kd(t)?(this.reconsumeCodePoint(t),this.consumeIdentLikeToken()):{type:6,value:Rn(t)}},r.prototype.consumeCodePoint=function(){var t=this._value.shift();return typeof t>"u"?-1:t},r.prototype.reconsumeCodePoint=function(t){this._value.unshift(t)},r.prototype.peekCodePoint=function(t){return t>=this._value.length?-1:this._value[t]},r.prototype.consumeUnicodeRangeToken=function(){for(var t=[],i=this.consumeCodePoint();Su(i)&&t.length<6;)t.push(i),i=this.consumeCodePoint();for(var s=!1;i===kd&&t.length<6;)t.push(i),i=this.consumeCodePoint(),s=!0;if(s){var A=parseInt(Rn.apply(void 0,t.map(function(C){return C===kd?$v:C})),16),o=parseInt(Rn.apply(void 0,t.map(function(C){return C===kd?n2:C})),16);return{type:30,start:A,end:o}}var g=parseInt(Rn.apply(void 0,t),16);if(this.peekCodePoint(0)===No&&Su(this.peekCodePoint(1))){this.consumeCodePoint(),i=this.consumeCodePoint();for(var d=[];Su(i)&&d.length<6;)d.push(i),i=this.consumeCodePoint();var o=parseInt(Rn.apply(void 0,d),16);return{type:30,start:g,end:o}}else return{type:30,start:g,end:g}},r.prototype.consumeIdentLikeToken=function(){var t=this.consumeName();return t.toLowerCase()==="url"&&this.peekCodePoint(0)===Fd?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Fd?(this.consumeCodePoint(),{type:19,value:t}):{type:20,value:t}},r.prototype.consumeUrlToken=function(){var t=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===DA)return{type:22,value:""};var i=this.peekCodePoint(0);if(i===Sd||i===xd){var s=this.consumeStringToken(this.consumeCodePoint());return s.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===DA||this.peekCodePoint(0)===Kh)?(this.consumeCodePoint(),{type:22,value:s.value}):(this.consumeBadUrlRemnants(),Td)}for(;;){var A=this.consumeCodePoint();if(A===DA||A===Kh)return{type:22,value:Rn.apply(void 0,t)};if(Ld(A))return this.consumeWhiteSpace(),this.peekCodePoint(0)===DA||this.peekCodePoint(0)===Kh?(this.consumeCodePoint(),{type:22,value:Rn.apply(void 0,t)}):(this.consumeBadUrlRemnants(),Td);if(A===xd||A===Sd||A===Fd||v4(A))return this.consumeBadUrlRemnants(),Td;if(A===tg)if(ec(A,this.peekCodePoint(0)))t.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Td;else t.push(A)}},r.prototype.consumeWhiteSpace=function(){for(;Ld(this.peekCodePoint(0));)this.consumeCodePoint()},r.prototype.consumeBadUrlRemnants=function(){for(;;){var t=this.consumeCodePoint();if(t===Kh||t===DA)return;ec(t,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},r.prototype.consumeStringSlice=function(t){for(var i=5e4,s="";t>0;){var A=Math.min(i,t);s+=Rn.apply(void 0,this._value.splice(0,A)),t-=A}return this._value.shift(),s},r.prototype.consumeStringToken=function(t){var i="",s=0;do{var A=this._value[s];if(A===DA||A===void 0||A===t)return i+=this.consumeStringSlice(s),{type:0,value:i};if(A===Dd)return this._value.splice(0,s),G4;if(A===tg){var o=this._value[s+1];o!==DA&&o!==void 0&&(o===Dd?(i+=this.consumeStringSlice(s),s=-1,this._value.shift()):ec(A,o)&&(i+=this.consumeStringSlice(s),i+=Rn(this.consumeEscapedCodePoint()),s=-1))}s++}while(!0)},r.prototype.consumeNumber=function(){var t=[],i=Ag,s=this.peekCodePoint(0);for((s===Gc||s===No)&&t.push(this.consumeCodePoint());Co(this.peekCodePoint(0));)t.push(this.consumeCodePoint());s=this.peekCodePoint(0);var A=this.peekCodePoint(1);if(s===og&&Co(A))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),i=nv;Co(this.peekCodePoint(0));)t.push(this.consumeCodePoint());s=this.peekCodePoint(0),A=this.peekCodePoint(1);var o=this.peekCodePoint(2);if((s===r2||s===e2)&&((A===Gc||A===No)&&Co(o)||Co(A)))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),i=nv;Co(this.peekCodePoint(0));)t.push(this.consumeCodePoint());return[w4(t),i]},r.prototype.consumeNumericToken=function(){var t=this.consumeNumber(),i=t[0],s=t[1],A=this.peekCodePoint(0),o=this.peekCodePoint(1),g=this.peekCodePoint(2);if(Ed(A,o,g)){var d=this.consumeName();return{type:15,number:i,flags:s,unit:d}}return A===KF?(this.consumeCodePoint(),{type:16,number:i,flags:s}):{type:17,number:i,flags:s}},r.prototype.consumeEscapedCodePoint=function(){var t=this.consumeCodePoint();if(Su(t)){for(var i=Rn(t);Su(this.peekCodePoint(0))&&i.length<6;)i+=Rn(this.consumeCodePoint());Ld(this.peekCodePoint(0))&&this.consumeCodePoint();var s=parseInt(i,16);return s===0||m4(s)||s>1114111?av:s}return t===DA?av:t},r.prototype.consumeName=function(){for(var t="";;){var i=this.consumeCodePoint();if(Av(i))t+=Rn(i);else if(ec(i,this.peekCodePoint(0)))t+=Rn(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(i),t}},r}(),o2=function(){function r(t){this._tokens=t}return r.create=function(t){var i=new s2;return i.write(t),new r(i.read())},r.parseValue=function(t){return r.create(t).parseComponentValue()},r.parseValues=function(t){return r.create(t).parseComponentValues()},r.prototype.parseComponentValue=function(){for(var t=this.consumeToken();t.type===31;)t=this.consumeToken();if(t.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(t);var i=this.consumeComponentValue();do t=this.consumeToken();while(t.type===31);if(t.type===32)return i;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},r.prototype.parseComponentValues=function(){for(var t=[];;){var i=this.consumeComponentValue();if(i.type===32)return t;t.push(i),t.push()}},r.prototype.consumeComponentValue=function(){var t=this.consumeToken();switch(t.type){case 11:case 28:case 2:return this.consumeSimpleBlock(t.type);case 19:return this.consumeFunction(t)}return t},r.prototype.consumeSimpleBlock=function(t){for(var i={type:t,values:[]},s=this.consumeToken();;){if(s.type===32||K4(s,t))return i;this.reconsumeToken(s),i.values.push(this.consumeComponentValue()),s=this.consumeToken()}},r.prototype.consumeFunction=function(t){for(var i={name:t.value,values:[],type:18};;){var s=this.consumeToken();if(s.type===32||s.type===3)return i;this.reconsumeToken(s),i.values.push(this.consumeComponentValue())}},r.prototype.consumeToken=function(){var t=this._tokens.shift();return typeof t>"u"?TC:t},r.prototype.reconsumeToken=function(t){this._tokens.unshift(t)},r}(),lg=function(r){return r.type===15},Hu=function(r){return r.type===17},$r=function(r){return r.type===20},D4=function(r){return r.type===0},UC=function(r,t){return $r(r)&&r.value===t},a2=function(r){return r.type!==31},Ru=function(r){return r.type!==31&&r.type!==4},KA=function(r){var t=[],i=[];return r.forEach(function(s){if(s.type===4){if(i.length===0)throw new Error("Error parsing function args, zero tokens for arg");t.push(i),i=[];return}s.type!==31&&i.push(s)}),i.length&&t.push(i),t},K4=function(r,t){return t===11&&r.type===12||t===28&&r.type===29?!0:t===2&&r.type===3},ac=function(r){return r.type===17||r.type===15},Xn=function(r){return r.type===16||ac(r)},A2=function(r){return r.length>1?[r[0],r[1]]:[r[0]]},Us={type:17,number:0,flags:Ag},KC={type:16,number:50,flags:Ag},rc={type:16,number:100,flags:Ag},jh=function(r,t,i){var s=r[0],A=r[1];return[ln(s,t),ln(typeof A<"u"?A:s,i)]},ln=function(r,t){if(r.type===16)return r.number/100*t;if(lg(r))switch(r.unit){case"rem":case"em":return 16*r.number;case"px":default:return r.number}return r.number},l2="deg",c2="grad",u2="rad",h2="turn",ep={name:"angle",parse:function(r,t){if(t.type===15)switch(t.unit){case l2:return Math.PI*t.number/180;case c2:return Math.PI/200*t.number;case u2:return t.number;case h2:return Math.PI*2*t.number}throw new Error("Unsupported angle type")}},g2=function(r){return r.type===15&&(r.unit===l2||r.unit===c2||r.unit===u2||r.unit===h2)},d2=function(r){var t=r.filter($r).map(function(i){return i.value}).join(" ");switch(t){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Us,Us];case"to top":case"bottom":return Ba(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Us,rc];case"to right":case"left":return Ba(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[rc,rc];case"to bottom":case"top":return Ba(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[rc,Us];case"to left":case"right":return Ba(270)}return 0},Ba=function(r){return Math.PI*r/180},sc={name:"color",parse:function(r,t){if(t.type===18){var i=W4[t.name];if(typeof i>"u")throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(r,t.values)}if(t.type===5){if(t.value.length===3){var s=t.value.substring(0,1),A=t.value.substring(1,2),o=t.value.substring(2,3);return nc(parseInt(s+s,16),parseInt(A+A,16),parseInt(o+o,16),1)}if(t.value.length===4){var s=t.value.substring(0,1),A=t.value.substring(1,2),o=t.value.substring(2,3),g=t.value.substring(3,4);return nc(parseInt(s+s,16),parseInt(A+A,16),parseInt(o+o,16),parseInt(g+g,16)/255)}if(t.value.length===6){var s=t.value.substring(0,2),A=t.value.substring(2,4),o=t.value.substring(4,6);return nc(parseInt(s,16),parseInt(A,16),parseInt(o,16),1)}if(t.value.length===8){var s=t.value.substring(0,2),A=t.value.substring(2,4),o=t.value.substring(4,6),g=t.value.substring(6,8);return nc(parseInt(s,16),parseInt(A,16),parseInt(o,16),parseInt(g,16)/255)}}if(t.type===20){var d=bl[t.value.toUpperCase()];if(typeof d<"u")return d}return bl.TRANSPARENT}},oc=function(r){return(255&r)===0},fs=function(r){var t=255&r,i=255&r>>8,s=255&r>>16,A=255&r>>24;return t<255?"rgba("+A+","+s+","+i+","+t/255+")":"rgb("+A+","+s+","+i+")"},nc=function(r,t,i,s){return(r<<24|t<<16|i<<8|Math.round(s*255)<<0)>>>0},lv=function(r,t){if(r.type===17)return r.number;if(r.type===16){var i=t===3?1:255;return t===3?r.number/100*i:Math.round(r.number/100*i)}return 0},cv=function(r,t){var i=t.filter(Ru);if(i.length===3){var s=i.map(lv),A=s[0],o=s[1],g=s[2];return nc(A,o,g,1)}if(i.length===4){var d=i.map(lv),A=d[0],o=d[1],g=d[2],C=d[3];return nc(A,o,g,C)}return 0};uv=function(r,t){var i=t.filter(Ru),s=i[0],A=i[1],o=i[2],g=i[3],d=(s.type===17?Ba(s.number):ep.parse(r,s))/(Math.PI*2),C=Xn(A)?A.number/100:0,v=Xn(o)?o.number/100:0,x=typeof g<"u"&&Xn(g)?ln(g,1):1;if(C===0)return nc(v*255,v*255,v*255,1);var T=v<=.5?v*(C+1):v+C-v*C,G=v*2-T,k=aC(G,T,d+1/3),W=aC(G,T,d),K=aC(G,T,d-1/3);return nc(k*255,W*255,K*255,x)},W4={hsl:uv,hsla:uv,rgb:cv,rgba:cv},eg=function(r,t){return sc.parse(r,o2.create(t).parseComponentValue())},bl={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},O4={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(r,t){return t.map(function(i){if($r(i))switch(i.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},z4={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ip=function(r,t){var i=sc.parse(r,t[0]),s=t[1];return s&&Xn(s)?{color:i,stop:s}:{color:i,stop:null}},hv=function(r,t){var i=r[0],s=r[r.length-1];i.stop===null&&(i.stop=Us),s.stop===null&&(s.stop=rc);for(var A=[],o=0,g=0;go?A.push(C):A.push(o),o=C}else A.push(null)}for(var v=null,g=0;gg.optimumDistance)?{optimumCorner:d,optimumDistance:x}:g},{optimumDistance:A?1/0:-1/0,optimumCorner:null}).optimumCorner},Y4=function(r,t,i,s,A){var o=0,g=0;switch(r.size){case 0:r.shape===0?o=g=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-A)):r.shape===1&&(o=Math.min(Math.abs(t),Math.abs(t-s)),g=Math.min(Math.abs(i),Math.abs(i-A)));break;case 2:if(r.shape===0)o=g=Math.min(qa(t,i),qa(t,i-A),qa(t-s,i),qa(t-s,i-A));else if(r.shape===1){var d=Math.min(Math.abs(i),Math.abs(i-A))/Math.min(Math.abs(t),Math.abs(t-s)),C=gv(s,A,t,i,!0),v=C[0],x=C[1];o=qa(v-t,(x-i)/d),g=d*o}break;case 1:r.shape===0?o=g=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-A)):r.shape===1&&(o=Math.max(Math.abs(t),Math.abs(t-s)),g=Math.max(Math.abs(i),Math.abs(i-A)));break;case 3:if(r.shape===0)o=g=Math.max(qa(t,i),qa(t,i-A),qa(t-s,i),qa(t-s,i-A));else if(r.shape===1){var d=Math.max(Math.abs(i),Math.abs(i-A))/Math.max(Math.abs(t),Math.abs(t-s)),T=gv(s,A,t,i,!1),v=T[0],x=T[1];o=qa(v-t,(x-i)/d),g=d*o}break}return Array.isArray(r.size)&&(o=ln(r.size[0],s),g=r.size.length===2?ln(r.size[1],A):o),[o,g]},j4=function(r,t){var i=Ba(180),s=[];return KA(t).forEach(function(A,o){if(o===0){var g=A[0];if(g.type===20&&g.value==="to"){i=d2(A);return}else if(g2(g)){i=ep.parse(r,g);return}}var d=ip(r,A);s.push(d)}),{angle:i,stops:s,type:1}},Ud=function(r,t){var i=Ba(180),s=[];return KA(t).forEach(function(A,o){if(o===0){var g=A[0];if(g.type===20&&["top","left","right","bottom"].indexOf(g.value)!==-1){i=d2(A);return}else if(g2(g)){i=(ep.parse(r,g)+Ba(270))%Ba(360);return}}var d=ip(r,A);s.push(d)}),{angle:i,stops:s,type:1}},q4=function(r,t){var i=Ba(180),s=[],A=1,o=0,g=3,d=[];return KA(t).forEach(function(C,v){var x=C[0];if(v===0){if($r(x)&&x.value==="linear"){A=1;return}else if($r(x)&&x.value==="radial"){A=2;return}}if(x.type===18){if(x.name==="from"){var T=sc.parse(r,x.values[0]);s.push({stop:Us,color:T})}else if(x.name==="to"){var T=sc.parse(r,x.values[0]);s.push({stop:rc,color:T})}else if(x.name==="color-stop"){var G=x.values.filter(Ru);if(G.length===2){var T=sc.parse(r,G[1]),k=G[0];Hu(k)&&s.push({stop:{type:16,number:k.number*100,flags:k.flags},color:T})}}}}),A===1?{angle:(i+Ba(180))%Ba(360),stops:s,type:A}:{size:g,shape:o,stops:s,position:d,type:A}},p2="closest-side",f2="farthest-side",m2="closest-corner",C2="farthest-corner",I2="circle",y2="ellipse",b2="cover",v2="contain",$4=function(r,t){var i=0,s=3,A=[],o=[];return KA(t).forEach(function(g,d){var C=!0;if(d===0){var v=!1;C=g.reduce(function(T,G){if(v)if($r(G))switch(G.value){case"center":return o.push(KC),T;case"top":case"left":return o.push(Us),T;case"right":case"bottom":return o.push(rc),T}else(Xn(G)||ac(G))&&o.push(G);else if($r(G))switch(G.value){case I2:return i=0,!1;case y2:return i=1,!1;case"at":return v=!0,!1;case p2:return s=0,!1;case b2:case f2:return s=1,!1;case v2:case m2:return s=2,!1;case C2:return s=3,!1}else if(ac(G)||Xn(G))return Array.isArray(s)||(s=[]),s.push(G),!1;return T},C)}if(C){var x=ip(r,g);A.push(x)}}),{size:s,shape:i,stops:A,position:o,type:2}},Qd=function(r,t){var i=0,s=3,A=[],o=[];return KA(t).forEach(function(g,d){var C=!0;if(d===0?C=g.reduce(function(x,T){if($r(T))switch(T.value){case"center":return o.push(KC),!1;case"top":case"left":return o.push(Us),!1;case"right":case"bottom":return o.push(rc),!1}else if(Xn(T)||ac(T))return o.push(T),!1;return x},C):d===1&&(C=g.reduce(function(x,T){if($r(T))switch(T.value){case I2:return i=0,!1;case y2:return i=1,!1;case v2:case p2:return s=0,!1;case f2:return s=1,!1;case m2:return s=2,!1;case b2:case C2:return s=3,!1}else if(ac(T)||Xn(T))return Array.isArray(s)||(s=[]),s.push(T),!1;return x},C)),C){var v=ip(r,g);A.push(v)}}),{size:s,shape:i,stops:A,position:o,type:2}},tk=function(r){return r.type===1},ek=function(r){return r.type===2},WC={name:"image",parse:function(r,t){if(t.type===22){var i={url:t.value,type:0};return r.cache.addImage(t.value),i}if(t.type===18){var s=w2[t.name];if(typeof s>"u")throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(r,t.values)}throw new Error("Unsupported image type "+t.type)}};w2={"linear-gradient":j4,"-moz-linear-gradient":Ud,"-ms-linear-gradient":Ud,"-o-linear-gradient":Ud,"-webkit-linear-gradient":Ud,"radial-gradient":$4,"-moz-radial-gradient":Qd,"-ms-radial-gradient":Qd,"-o-radial-gradient":Qd,"-webkit-radial-gradient":Qd,"-webkit-gradient":q4},rk={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(r,t){if(t.length===0)return[];var i=t[0];return i.type===20&&i.value==="none"?[]:t.filter(function(s){return Ru(s)&&ik(s)}).map(function(s){return WC.parse(r,s)})}},nk={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(r,t){return t.map(function(i){if($r(i))switch(i.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},sk={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(r,t){return KA(t).map(function(i){return i.filter(Xn)}).map(A2)}},ok={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(r,t){return KA(t).map(function(i){return i.filter($r).map(function(s){return s.value}).join(" ")}).map(ak)}},ak=function(r){switch(r){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}};(function(r){r.AUTO="auto",r.CONTAIN="contain",r.COVER="cover"})(Gu||(Gu={}));Ak={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(r,t){return KA(t).map(function(i){return i.filter(lk)})}},lk=function(r){return $r(r)||Xn(r)},rp=function(r){return{name:"border-"+r+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},ck=rp("top"),uk=rp("right"),hk=rp("bottom"),gk=rp("left"),np=function(r){return{name:"border-radius-"+r,initialValue:"0 0",prefix:!1,type:1,parse:function(t,i){return A2(i.filter(Xn))}}},dk=np("top-left"),pk=np("top-right"),fk=np("bottom-right"),mk=np("bottom-left"),sp=function(r){return{name:"border-"+r+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(t,i){switch(i){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},Ck=sp("top"),Ik=sp("right"),yk=sp("bottom"),bk=sp("left"),op=function(r){return{name:"border-"+r+"-width",initialValue:"0",type:0,prefix:!1,parse:function(t,i){return lg(i)?i.number:0}}},vk=op("top"),wk=op("right"),Bk=op("bottom"),_k=op("left"),xk={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Sk={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(r,t){switch(t){case"rtl":return 1;case"ltr":default:return 0}}},Fk={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(r,t){return t.filter($r).reduce(function(i,s){return i|kk(s.value)},0)}},kk=function(r){switch(r){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Lk={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Ek={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(r,t){return t.type===20&&t.value==="normal"?0:t.type===17||t.type===15?t.number:0}};(function(r){r.NORMAL="normal",r.STRICT="strict"})(Wd||(Wd={}));Tk={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"strict":return Wd.STRICT;case"normal":default:return Wd.NORMAL}}},Uk={name:"line-height",initialValue:"normal",prefix:!1,type:4},dv=function(r,t){return $r(r)&&r.value==="normal"?1.2*t:r.type===17?t*r.number:Xn(r)?ln(r,t):t},Qk={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(r,t){return t.type===20&&t.value==="none"?null:WC.parse(r,t)}},Gk={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(r,t){switch(t){case"inside":return 0;case"outside":default:return 1}}},QC={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},ap=function(r){return{name:"margin-"+r,initialValue:"0",prefix:!1,type:4}},Rk=ap("top"),Hk=ap("right"),Zk=ap("bottom"),Pk=ap("left"),Mk={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(r,t){return t.filter($r).map(function(i){switch(i.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},Nk={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"break-word":return"break-word";case"normal":default:return"normal"}}},Ap=function(r){return{name:"padding-"+r,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Vk=Ap("top"),Dk=Ap("right"),Kk=Ap("bottom"),Wk=Ap("left"),Ok={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(r,t){switch(t){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},zk={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(r,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Jk={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(r,t){return t.length===1&&UC(t[0],"none")?[]:KA(t).map(function(i){for(var s={color:bl.TRANSPARENT,offsetX:Us,offsetY:Us,blur:Us},A=0,o=0;o"u")throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return i(t.values)}return null}},jk=function(r){var t=r.filter(function(i){return i.type===17}).map(function(i){return i.number});return t.length===6?t:null},qk=function(r){var t=r.filter(function(C){return C.type===17}).map(function(C){return C.number}),i=t[0],s=t[1];t[2],t[3];var A=t[4],o=t[5];t[6],t[7],t[8],t[9],t[10],t[11];var g=t[12],d=t[13];return t[14],t[15],t.length===16?[i,s,A,o,g,d]:null},$k={matrix:jk,matrix3d:qk},pv={type:16,number:50,flags:Ag},tL=[pv,pv],eL={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(r,t){var i=t.filter(Xn);return i.length!==2?tL:[i[0],i[1]]}},iL={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(r,t){switch(t){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}};(function(r){r.NORMAL="normal",r.BREAK_ALL="break-all",r.KEEP_ALL="keep-all"})(ig||(ig={}));rL={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"break-all":return ig.BREAK_ALL;case"keep-all":return ig.KEEP_ALL;case"normal":default:return ig.NORMAL}}},nL={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(r,t){if(t.type===20)return{auto:!0,order:0};if(Hu(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},B2={name:"time",parse:function(r,t){if(t.type===15)switch(t.unit.toLowerCase()){case"s":return 1e3*t.number;case"ms":return t.number}throw new Error("Unsupported time type")}},sL={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(r,t){return Hu(t)?t.number:1}},oL={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},aL={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(r,t){return t.filter($r).map(function(i){switch(i.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(i){return i!==0})}},AL={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(r,t){var i=[],s=[];return t.forEach(function(A){switch(A.type){case 20:case 0:i.push(A.value);break;case 17:i.push(A.number.toString());break;case 4:s.push(i.join(" ")),i.length=0;break}}),i.length&&s.push(i.join(" ")),s.map(function(A){return A.indexOf(" ")===-1?A:"'"+A+"'"})}},lL={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},cL={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(r,t){if(Hu(t))return t.number;if($r(t))switch(t.value){case"bold":return 700;case"normal":default:return 400}return 400}},uL={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(r,t){return t.filter($r).map(function(i){return i.value})}},hL={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(r,t){switch(t){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},as=function(r,t){return(r&t)!==0},gL={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(r,t){if(t.length===0)return[];var i=t[0];return i.type===20&&i.value==="none"?[]:t}},dL={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(r,t){if(t.length===0)return null;var i=t[0];if(i.type===20&&i.value==="none")return null;for(var s=[],A=t.filter(a2),o=0;o1?1:0],this.overflowWrap=_i(t,Nk,i.overflowWrap),this.paddingTop=_i(t,Vk,i.paddingTop),this.paddingRight=_i(t,Dk,i.paddingRight),this.paddingBottom=_i(t,Kk,i.paddingBottom),this.paddingLeft=_i(t,Wk,i.paddingLeft),this.paintOrder=_i(t,IL,i.paintOrder),this.position=_i(t,zk,i.position),this.textAlign=_i(t,Ok,i.textAlign),this.textDecorationColor=_i(t,oL,(s=i.textDecorationColor)!==null&&s!==void 0?s:i.color),this.textDecorationLine=_i(t,aL,(A=i.textDecorationLine)!==null&&A!==void 0?A:i.textDecoration),this.textShadow=_i(t,Jk,i.textShadow),this.textTransform=_i(t,Xk,i.textTransform),this.transform=_i(t,Yk,i.transform),this.transformOrigin=_i(t,eL,i.transformOrigin),this.visibility=_i(t,iL,i.visibility),this.webkitTextStrokeColor=_i(t,yL,i.webkitTextStrokeColor),this.webkitTextStrokeWidth=_i(t,bL,i.webkitTextStrokeWidth),this.wordBreak=_i(t,rL,i.wordBreak),this.zIndex=_i(t,nL,i.zIndex)}return r.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},r.prototype.isTransparent=function(){return oc(this.backgroundColor)},r.prototype.isTransformed=function(){return this.transform!==null},r.prototype.isPositioned=function(){return this.position!==0},r.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},r.prototype.isFloating=function(){return this.float!==0},r.prototype.isInlineLevel=function(){return as(this.display,4)||as(this.display,33554432)||as(this.display,268435456)||as(this.display,536870912)||as(this.display,67108864)||as(this.display,134217728)},r}(),wL=function(){function r(t,i){this.content=_i(t,gL,i.content),this.quotes=_i(t,mL,i.quotes)}return r}(),mv=function(){function r(t,i){this.counterIncrement=_i(t,dL,i.counterIncrement),this.counterReset=_i(t,pL,i.counterReset)}return r}(),_i=function(r,t,i){var s=new s2,A=i!==null&&typeof i<"u"?i.toString():t.initialValue;s.write(A);var o=new o2(s.read());switch(t.type){case 2:var g=o.parseComponentValue();return t.parse(r,$r(g)?g.value:t.initialValue);case 0:return t.parse(r,o.parseComponentValue());case 1:return t.parse(r,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return ep.parse(r,o.parseComponentValue());case"color":return sc.parse(r,o.parseComponentValue());case"image":return WC.parse(r,o.parseComponentValue());case"length":var d=o.parseComponentValue();return ac(d)?d:Us;case"length-percentage":var C=o.parseComponentValue();return Xn(C)?C:Us;case"time":return B2.parse(r,o.parseComponentValue())}break}},BL="data-html2canvas-debug",_L=function(r){var t=r.getAttribute(BL);switch(t){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},GC=function(r,t){var i=_L(r);return i===1||t===i},WA=function(){function r(t,i){if(this.context=t,this.textNodes=[],this.elements=[],this.flags=0,GC(i,3))debugger;this.styles=new vL(t,window.getComputedStyle(i,null)),ZC(i)&&(this.styles.animationDuration.some(function(s){return s>0})&&(i.style.animationDuration="0s"),this.styles.transform!==null&&(i.style.transform="none")),this.bounds=$d(this.context,i),GC(i,4)&&(this.flags|=16)}return r}(),xL="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAI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AAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGV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gQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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3)<<6|C&63;return v},FL=function(r){for(var t=r.length,i=[],s=0;s>Zc,EL=1<>Zc,UL=_2+TL,QL=UL,GL=32,RL=QL+GL,HL=65536>>OC,ZL=1<=0){if(t<55296||t>56319&&t<=65535)return i=this.index[t>>Zc],i=(i<>Zc)],i=(i<>OC),i=this.index[i],i+=t>>Zc&PL,i=this.index[i],i=(i<"u"?[]:new Uint8Array(256);for(Oh=0;Oh=55296&&A<=56319&&i>10)+55296,g%1024+56320)),(A+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},JL=NL(xL),Rc="\xD7",Fv="\xF7",XL=function(r){return JL.get(r)},YL=function(r,t,i){var s=i-2,A=t[s],o=t[i-1],g=t[i];if(o===cC&&g===uC)return Rc;if(o===cC||o===uC||o===bv||g===cC||g===uC||g===bv)return Fv;if(o===wv&&[wv,hC,Bv,_v].indexOf(g)!==-1||(o===Bv||o===hC)&&(g===hC||g===gC)||(o===_v||o===gC)&&g===gC||g===xv||g===vv||g===WL||o===KL)return Rc;if(o===xv&&g===Sv){for(;A===vv;)A=t[--s];if(A===Sv)return Rc}if(o===dC&&g===dC){for(var d=0;A===dC;)d++,A=t[--s];if(d%2===0)return Rc}return Fv},jL=function(r){var t=OL(r),i=t.length,s=0,A=0,o=t.map(XL);return{next:function(){if(s>=i)return{done:!0,value:null};for(var g=Rc;sg.x||x.y>g.y;return g=x,v===0?!0:T});return r.body.removeChild(t),d},eE=function(){return typeof new Image().crossOrigin<"u"},iE=function(){return typeof new XMLHttpRequest().responseType=="string"},rE=function(r){var t=new Image,i=r.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch{return!1}return!0},kv=function(r){return r[0]===0&&r[1]===255&&r[2]===0&&r[3]===255},nE=function(r){var t=r.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var A=new Image,o=t.toDataURL();A.src=o;var g=RC(i,i,0,0,A);return s.fillStyle="red",s.fillRect(0,0,i,i),Lv(g).then(function(d){s.drawImage(d,0,0);var C=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var v=r.createElement("div");return v.style.backgroundImage="url("+o+")",v.style.height=i+"px",kv(C)?Lv(RC(i,i,0,0,v)):Promise.reject(!1)}).then(function(d){return s.drawImage(d,0,0),kv(s.getImageData(0,0,i,i).data)}).catch(function(){return!1})},RC=function(r,t,i,s,A){var o="http://www.w3.org/2000/svg",g=document.createElementNS(o,"svg"),d=document.createElementNS(o,"foreignObject");return g.setAttributeNS(null,"width",r.toString()),g.setAttributeNS(null,"height",t.toString()),d.setAttributeNS(null,"width","100%"),d.setAttributeNS(null,"height","100%"),d.setAttributeNS(null,"x",i.toString()),d.setAttributeNS(null,"y",s.toString()),d.setAttributeNS(null,"externalResourcesRequired","true"),g.appendChild(d),d.appendChild(A),g},Lv=function(r){return new Promise(function(t,i){var s=new Image;s.onload=function(){return t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r))})},Ts={get SUPPORT_RANGE_BOUNDS(){var r=$L(document);return Object.defineProperty(Ts,"SUPPORT_RANGE_BOUNDS",{value:r}),r},get SUPPORT_WORD_BREAKING(){var r=Ts.SUPPORT_RANGE_BOUNDS&&tE(document);return Object.defineProperty(Ts,"SUPPORT_WORD_BREAKING",{value:r}),r},get SUPPORT_SVG_DRAWING(){var r=rE(document);return Object.defineProperty(Ts,"SUPPORT_SVG_DRAWING",{value:r}),r},get SUPPORT_FOREIGNOBJECT_DRAWING(){var r=typeof Array.from=="function"&&typeof window.fetch=="function"?nE(document):Promise.resolve(!1);return Object.defineProperty(Ts,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:r}),r},get SUPPORT_CORS_IMAGES(){var r=eE();return Object.defineProperty(Ts,"SUPPORT_CORS_IMAGES",{value:r}),r},get SUPPORT_RESPONSE_TYPE(){var r=iE();return Object.defineProperty(Ts,"SUPPORT_RESPONSE_TYPE",{value:r}),r},get SUPPORT_CORS_XHR(){var r="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Ts,"SUPPORT_CORS_XHR",{value:r}),r},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var r=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Ts,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:r}),r}},rg=function(){function r(t,i){this.text=t,this.bounds=i}return r}(),sE=function(r,t,i,s){var A=AE(t,i),o=[],g=0;return A.forEach(function(d){if(i.textDecorationLine.length||d.trim().length>0)if(Ts.SUPPORT_RANGE_BOUNDS){var C=Ev(s,g,d.length).getClientRects();if(C.length>1){var v=zC(d),x=0;v.forEach(function(G){o.push(new rg(G,vl.fromDOMRectList(r,Ev(s,x+g,G.length).getClientRects()))),x+=G.length})}else o.push(new rg(d,vl.fromDOMRectList(r,C)))}else{var T=s.splitText(d.length);o.push(new rg(d,oE(r,s))),s=T}else Ts.SUPPORT_RANGE_BOUNDS||(s=s.splitText(d.length));g+=d.length}),o},oE=function(r,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var A=t.parentNode;if(A){A.replaceChild(s,t);var o=$d(r,s);return s.firstChild&&A.replaceChild(s.firstChild,s),o}}return vl.EMPTY},Ev=function(r,t,i){var s=r.ownerDocument;if(!s)throw new Error("Node has no owner document");var A=s.createRange();return A.setStart(r,t),A.setEnd(r,t+i),A},zC=function(r){if(Ts.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(r)).map(function(i){return i.segment})}return qL(r)},aE=function(r,t){if(Ts.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(r)).map(function(s){return s.segment})}return cE(r,t)},AE=function(r,t){return t.letterSpacing!==0?zC(r):aE(r,t)},lE=[32,160,4961,65792,65793,4153,4241],cE=function(r,t){for(var i=HF(r,{lineBreak:t.lineBreak,wordBreak:t.overflowWrap==="break-word"?"break-word":t.wordBreak}),s=[],A,o=function(){if(A.value){var g=A.value.slice(),d=tp(g),C="";d.forEach(function(v){lE.indexOf(v)===-1?C+=Rn(v):(C.length&&s.push(C),s.push(Rn(v)),C="")}),C.length&&s.push(C)}};!(A=i.next()).done;)o();return s},uE=function(){function r(t,i,s){this.text=hE(i.data,s.textTransform),this.textBounds=sE(t,this.text,s,i)}return r}(),hE=function(r,t){switch(t){case 1:return r.toLowerCase();case 3:return r.replace(gE,dE);case 2:return r.toUpperCase();default:return r}},gE=/(^|\s|:|-|\(|\))([a-z])/g,dE=function(r,t,i){return r.length>0?t+i.toUpperCase():r},x2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.src=s.currentSrc||s.src,A.intrinsicWidth=s.naturalWidth,A.intrinsicHeight=s.naturalHeight,A.context.cache.addImage(A.src),A}return t}(WA),S2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.canvas=s,A.intrinsicWidth=s.width,A.intrinsicHeight=s.height,A}return t}(WA),F2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this,o=new XMLSerializer,g=$d(i,s);return s.setAttribute("width",g.width+"px"),s.setAttribute("height",g.height+"px"),A.svg="data:image/svg+xml,"+encodeURIComponent(o.serializeToString(s)),A.intrinsicWidth=s.width.baseVal.value,A.intrinsicHeight=s.height.baseVal.value,A.context.cache.addImage(A.svg),A}return t}(WA),k2=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.value=s.value,A}return t}(WA),HC=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A.start=s.start,A.reversed=typeof s.reversed=="boolean"&&s.reversed===!0,A}return t}(WA),pE=[{type:15,flags:0,unit:"px",number:3}],fE=[{type:16,flags:0,number:50}],mE=function(r){return r.width>r.height?new vl(r.left+(r.width-r.height)/2,r.top,r.height,r.height):r.width0)i.textNodes.push(new uE(r,A,i.styles));else if(Qu(A))if(P2(A)&&A.assignedNodes)A.assignedNodes().forEach(function(d){return Nd(r,d,i,s)});else{var g=U2(r,A);g.styles.isVisible()&&(bE(A,g,s)?g.flags|=4:vE(g.styles)&&(g.flags|=2),yE.indexOf(A.tagName)!==-1&&(g.flags|=8),i.elements.push(g),A.slot,A.shadowRoot?Nd(r,A.shadowRoot,g,s):!Jd(A)&&!R2(A)&&!Xd(A)&&Nd(r,A,g,s))}},U2=function(r,t){return PC(t)?new x2(r,t):H2(t)?new S2(r,t):R2(t)?new F2(r,t):wE(t)?new k2(r,t):BE(t)?new HC(r,t):_E(t)?new JC(r,t):Xd(t)?new L2(r,t):Jd(t)?new E2(r,t):Z2(t)?new T2(r,t):new WA(r,t)},Q2=function(r,t){var i=U2(r,t);return i.flags|=4,Nd(r,t,i,i),i},bE=function(r,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||XC(r)&&i.styles.isTransparent()},vE=function(r){return r.isPositioned()||r.isFloating()},G2=function(r){return r.nodeType===Node.TEXT_NODE},Qu=function(r){return r.nodeType===Node.ELEMENT_NODE},ZC=function(r){return Qu(r)&&typeof r.style<"u"&&!Vd(r)},Vd=function(r){return typeof r.className=="object"},wE=function(r){return r.tagName==="LI"},BE=function(r){return r.tagName==="OL"},_E=function(r){return r.tagName==="INPUT"},xE=function(r){return r.tagName==="HTML"},R2=function(r){return r.tagName==="svg"},XC=function(r){return r.tagName==="BODY"},H2=function(r){return r.tagName==="CANVAS"},Uv=function(r){return r.tagName==="VIDEO"},PC=function(r){return r.tagName==="IMG"},Z2=function(r){return r.tagName==="IFRAME"},Qv=function(r){return r.tagName==="STYLE"},SE=function(r){return r.tagName==="SCRIPT"},Jd=function(r){return r.tagName==="TEXTAREA"},Xd=function(r){return r.tagName==="SELECT"},P2=function(r){return r.tagName==="SLOT"},Gv=function(r){return r.tagName.indexOf("-")>0},FE=function(){function r(){this.counters={}}return r.prototype.getCounterValue=function(t){var i=this.counters[t];return i&&i.length?i[i.length-1]:1},r.prototype.getCounterValues=function(t){var i=this.counters[t];return i||[]},r.prototype.pop=function(t){var i=this;t.forEach(function(s){return i.counters[s].pop()})},r.prototype.parse=function(t){var i=this,s=t.counterIncrement,A=t.counterReset,o=!0;s!==null&&s.forEach(function(d){var C=i.counters[d.counter];C&&d.increment!==0&&(o=!1,C.length||C.push(1),C[Math.max(0,C.length-1)]+=d.increment)});var g=[];return o&&A.forEach(function(d){var C=i.counters[d.counter];g.push(d.counter),C||(C=i.counters[d.counter]=[]),C.push(d.reset)}),g},r}(),Rv={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Hv={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},kE={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},LE={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},Fu=function(r,t,i,s,A,o){return ri?ag(r,A,o.length>0):s.integers.reduce(function(g,d,C){for(;r>=d;)r-=d,g+=s.values[C];return g},"")+o},M2=function(r,t,i,s){var A="";do i||r--,A=s(r)+A,r/=t;while(r*t>=t);return A},Gn=function(r,t,i,s,A){var o=i-t+1;return(r<0?"-":"")+(M2(Math.abs(r),o,s,function(g){return Rn(Math.floor(g%o)+t)})+A)},Qc=function(r,t,i){i===void 0&&(i=". ");var s=t.length;return M2(Math.abs(r),s,!1,function(A){return t[Math.floor(A%s)]})+i},Eu=1,$l=2,tc=4,$h=8,yl=function(r,t,i,s,A,o){if(r<-9999||r>9999)return ag(r,4,A.length>0);var g=Math.abs(r),d=A;if(g===0)return t[0]+d;for(var C=0;g>0&&C<=4;C++){var v=g%10;v===0&&as(o,Eu)&&d!==""?d=t[v]+d:v>1||v===1&&C===0||v===1&&C===1&&as(o,$l)||v===1&&C===1&&as(o,tc)&&r>100||v===1&&C>1&&as(o,$h)?d=t[v]+(C>0?i[C-1]:"")+d:v===1&&C>0&&(d=i[C-1]+d),g=Math.floor(g/10)}return(r<0?s:"")+d},Zv="\u5341\u767E\u5343\u842C",Pv="\u62FE\u4F70\u4EDF\u842C",Mv="\u30DE\u30A4\u30CA\u30B9",pC="\uB9C8\uC774\uB108\uC2A4",ag=function(r,t,i){var s=i?". ":"",A=i?"\u3001":"",o=i?", ":"",g=i?" ":"";switch(t){case 0:return"\u2022"+g;case 1:return"\u25E6"+g;case 2:return"\u25FE"+g;case 5:var d=Gn(r,48,57,!0,s);return d.length<4?"0"+d:d;case 4:return Qc(r,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",A);case 6:return Fu(r,1,3999,Rv,3,s).toLowerCase();case 7:return Fu(r,1,3999,Rv,3,s);case 8:return Gn(r,945,969,!1,s);case 9:return Gn(r,97,122,!1,s);case 10:return Gn(r,65,90,!1,s);case 11:return Gn(r,1632,1641,!0,s);case 12:case 49:return Fu(r,1,9999,Hv,3,s);case 35:return Fu(r,1,9999,Hv,3,s).toLowerCase();case 13:return Gn(r,2534,2543,!0,s);case 14:case 30:return Gn(r,6112,6121,!0,s);case 15:return Qc(r,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",A);case 16:return Qc(r,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",A);case 17:case 48:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Zv,"\u8CA0",A,$l|tc|$h);case 47:return yl(r,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",Pv,"\u8CA0",A,Eu|$l|tc|$h);case 42:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",Zv,"\u8D1F",A,$l|tc|$h);case 41:return yl(r,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",Pv,"\u8D1F",A,Eu|$l|tc|$h);case 26:return yl(r,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",Mv,A,0);case 25:return yl(r,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",Mv,A,Eu|$l|tc);case 31:return yl(r,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",pC,o,Eu|$l|tc);case 33:return yl(r,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",pC,o,0);case 32:return yl(r,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",pC,o,Eu|$l|tc);case 18:return Gn(r,2406,2415,!0,s);case 20:return Fu(r,1,19999,LE,3,s);case 21:return Gn(r,2790,2799,!0,s);case 22:return Gn(r,2662,2671,!0,s);case 22:return Fu(r,1,10999,kE,3,s);case 23:return Qc(r,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return Qc(r,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return Gn(r,3302,3311,!0,s);case 28:return Qc(r,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",A);case 29:return Qc(r,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",A);case 34:return Gn(r,3792,3801,!0,s);case 37:return Gn(r,6160,6169,!0,s);case 38:return Gn(r,4160,4169,!0,s);case 39:return Gn(r,2918,2927,!0,s);case 40:return Gn(r,1776,1785,!0,s);case 43:return Gn(r,3046,3055,!0,s);case 44:return Gn(r,3174,3183,!0,s);case 45:return Gn(r,3664,3673,!0,s);case 46:return Gn(r,3872,3881,!0,s);case 3:default:return Gn(r,48,57,!0,s)}},N2="data-html2canvas-ignore",Nv=function(){function r(t,i,s){if(this.context=t,this.options=s,this.scrolledElements=[],this.referenceElement=i,this.counters=new FE,this.quoteDepth=0,!i.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(i.ownerDocument.documentElement,!1)}return r.prototype.toIFrame=function(t,i){var s=this,A=EE(t,i);if(!A.contentWindow)return Promise.reject("Unable to find iframe window");var o=t.defaultView.pageXOffset,g=t.defaultView.pageYOffset,d=A.contentWindow,C=d.document,v=QE(A).then(function(){return mo(s,void 0,void 0,function(){var x,T;return Js(this,function(G){switch(G.label){case 0:return this.scrolledElements.forEach(ZE),d&&(d.scrollTo(i.left,i.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(d.scrollY!==i.top||d.scrollX!==i.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(d.scrollX-i.left,d.scrollY-i.top,0,0))),x=this.options.onclone,T=this.clonedReferenceElement,typeof T>"u"?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:C.fonts&&C.fonts.ready?[4,C.fonts.ready]:[3,2];case 1:G.sent(),G.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,UE(C)]:[3,4];case 3:G.sent(),G.label=4;case 4:return typeof x=="function"?[2,Promise.resolve().then(function(){return x(C,T)}).then(function(){return A})]:[2,A]}})})});return C.open(),C.write(RE(document.doctype)+""),HE(this.referenceElement.ownerDocument,o,g),C.replaceChild(C.adoptNode(this.documentElement),C.documentElement),C.close(),v},r.prototype.createElementClone=function(t){if(GC(t,2))debugger;if(H2(t))return this.createCanvasClone(t);if(Uv(t))return this.createVideoClone(t);if(Qv(t))return this.createStyleClone(t);var i=t.cloneNode(!1);return PC(i)&&(PC(t)&&t.currentSrc&&t.currentSrc!==t.src&&(i.src=t.currentSrc,i.srcset=""),i.loading==="lazy"&&(i.loading="eager")),Gv(i)?this.createCustomElementClone(i):i},r.prototype.createCustomElementClone=function(t){var i=document.createElement("html2canvascustomelement");return fC(t.style,i),i},r.prototype.createStyleClone=function(t){try{var i=t.sheet;if(i&&i.cssRules){var s=[].slice.call(i.cssRules,0).reduce(function(o,g){return g&&typeof g.cssText=="string"?o+g.cssText:o},""),A=t.cloneNode(!1);return A.textContent=s,A}}catch(o){if(this.context.logger.error("Unable to access cssRules property",o),o.name!=="SecurityError")throw o}return t.cloneNode(!1)},r.prototype.createCanvasClone=function(t){var i;if(this.options.inlineImages&&t.ownerDocument){var s=t.ownerDocument.createElement("img");try{return s.src=t.toDataURL(),s}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",t)}}var A=t.cloneNode(!1);try{A.width=t.width,A.height=t.height;var o=t.getContext("2d"),g=A.getContext("2d");if(g)if(!this.options.allowTaint&&o)g.putImageData(o.getImageData(0,0,t.width,t.height),0,0);else{var d=(i=t.getContext("webgl2"))!==null&&i!==void 0?i:t.getContext("webgl");if(d){var C=d.getContextAttributes();C?.preserveDrawingBuffer===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",t)}g.drawImage(t,0,0)}return A}catch{this.context.logger.info("Unable to clone canvas as it is tainted",t)}return A},r.prototype.createVideoClone=function(t){var i=t.ownerDocument.createElement("canvas");i.width=t.offsetWidth,i.height=t.offsetHeight;var s=i.getContext("2d");try{return s&&(s.drawImage(t,0,0,i.width,i.height),this.options.allowTaint||s.getImageData(0,0,i.width,i.height)),i}catch{this.context.logger.info("Unable to clone video as it is tainted",t)}var A=t.ownerDocument.createElement("canvas");return A.width=t.offsetWidth,A.height=t.offsetHeight,A},r.prototype.appendChildNode=function(t,i,s){(!Qu(i)||!SE(i)&&!i.hasAttribute(N2)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(i)))&&(!this.options.copyStyles||!Qu(i)||!Qv(i))&&t.appendChild(this.cloneNode(i,s))},r.prototype.cloneChildNodes=function(t,i,s){for(var A=this,o=t.shadowRoot?t.shadowRoot.firstChild:t.firstChild;o;o=o.nextSibling)if(Qu(o)&&P2(o)&&typeof o.assignedNodes=="function"){var g=o.assignedNodes();g.length&&g.forEach(function(d){return A.appendChildNode(i,d,s)})}else this.appendChildNode(i,o,s)},r.prototype.cloneNode=function(t,i){if(G2(t))return document.createTextNode(t.data);if(!t.ownerDocument)return t.cloneNode(!1);var s=t.ownerDocument.defaultView;if(s&&Qu(t)&&(ZC(t)||Vd(t))){var A=this.createElementClone(t);A.style.transitionProperty="none";var o=s.getComputedStyle(t),g=s.getComputedStyle(t,":before"),d=s.getComputedStyle(t,":after");this.referenceElement===t&&ZC(A)&&(this.clonedReferenceElement=A),XC(A)&&NE(A);var C=this.counters.parse(new mv(this.context,o)),v=this.resolvePseudoContent(t,A,g,ng.BEFORE);Gv(t)&&(i=!0),Uv(t)||this.cloneChildNodes(t,A,i),v&&A.insertBefore(v,A.firstChild);var x=this.resolvePseudoContent(t,A,d,ng.AFTER);return x&&A.appendChild(x),this.counters.pop(C),(o&&(this.options.copyStyles||Vd(t))&&!Z2(t)||i)&&fC(o,A),(t.scrollTop!==0||t.scrollLeft!==0)&&this.scrolledElements.push([A,t.scrollLeft,t.scrollTop]),(Jd(t)||Xd(t))&&(Jd(A)||Xd(A))&&(A.value=t.value),A}return t.cloneNode(!1)},r.prototype.resolvePseudoContent=function(t,i,s,A){var o=this;if(s){var g=s.content,d=i.ownerDocument;if(!(!d||!g||g==="none"||g==="-moz-alt-content"||s.display==="none")){this.counters.parse(new mv(this.context,s));var C=new wL(this.context,s),v=d.createElement("html2canvaspseudoelement");fC(s,v),C.content.forEach(function(T){if(T.type===0)v.appendChild(d.createTextNode(T.value));else if(T.type===22){var G=d.createElement("img");G.src=T.value,G.style.opacity="1",v.appendChild(G)}else if(T.type===18){if(T.name==="attr"){var k=T.values.filter($r);k.length&&v.appendChild(d.createTextNode(t.getAttribute(k[0].value)||""))}else if(T.name==="counter"){var W=T.values.filter(Ru),K=W[0],$=W[1];if(K&&$r(K)){var O=o.counters.getCounterValue(K.value),tt=$&&$r($)?QC.parse(o.context,$.value):3;v.appendChild(d.createTextNode(ag(O,tt,!1)))}}else if(T.name==="counters"){var at=T.values.filter(Ru),K=at[0],Lt=at[1],$=at[2];if(K&&$r(K)){var Tt=o.counters.getCounterValues(K.value),Ut=$&&$r($)?QC.parse(o.context,$.value):3,Ft=Lt&&Lt.type===0?Lt.value:"",vt=Tt.map(function(At){return ag(At,Ut,!1)}).join(Ft);v.appendChild(d.createTextNode(vt))}}}else if(T.type===20)switch(T.value){case"open-quote":v.appendChild(d.createTextNode(fv(C.quotes,o.quoteDepth++,!0)));break;case"close-quote":v.appendChild(d.createTextNode(fv(C.quotes,--o.quoteDepth,!1)));break;default:v.appendChild(d.createTextNode(T.value))}}),v.className=MC+" "+NC;var x=A===ng.BEFORE?" "+MC:" "+NC;return Vd(i)?i.className.baseValue+=x:i.className+=x,v}}},r.destroy=function(t){return t.parentNode?(t.parentNode.removeChild(t),!0):!1},r}();(function(r){r[r.BEFORE=0]="BEFORE",r[r.AFTER=1]="AFTER"})(ng||(ng={}));EE=function(r,t){var i=r.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute(N2,"true"),r.body.appendChild(i),i},TE=function(r){return new Promise(function(t){if(r.complete){t();return}if(!r.src){t();return}r.onload=t,r.onerror=t})},UE=function(r){return Promise.all([].slice.call(r.images,0).map(TE))},QE=function(r){return new Promise(function(t,i){var s=r.contentWindow;if(!s)return i("No window assigned for iframe");var A=s.document;s.onload=r.onload=function(){s.onload=r.onload=null;var o=setInterval(function(){A.body.childNodes.length>0&&A.readyState==="complete"&&(clearInterval(o),t(r))},50)}})},GE=["all","d","content"],fC=function(r,t){for(var i=r.length-1;i>=0;i--){var s=r.item(i);GE.indexOf(s)===-1&&t.style.setProperty(s,r.getPropertyValue(s))}return t},RE=function(r){var t="";return r&&(t+=""),t},HE=function(r,t,i){r&&r.defaultView&&(t!==r.defaultView.pageXOffset||i!==r.defaultView.pageYOffset)&&r.defaultView.scrollTo(t,i)},ZE=function(r){var t=r[0],i=r[1],s=r[2];t.scrollLeft=i,t.scrollTop=s},PE=":before",ME=":after",MC="___html2canvas___pseudoelement_before",NC="___html2canvas___pseudoelement_after",Vv=`{ content: "" !important; display: none !important; }`,NE=function(r){VE(r,"."+MC+PE+Vv+` - .`+NC+ME+Vv)},VE=function(r,t){var i=r.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,r.appendChild(s)}},V2=function(){function r(){}return r.getOrigin=function(t){var i=r._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},r.isSameOrigin=function(t){return r.getOrigin(t)===r._origin},r.setContext=function(t){r._link=t.document.createElement("a"),r._origin=r.getOrigin(t.location.href)},r._origin="about:blank",r}(),DE=function(){function r(t,i){this.context=t,this._options=i,this._cache={}}return r.prototype.addImage=function(t){var i=Promise.resolve();return this.has(t)||(CC(t)||zE(t))&&(this._cache[t]=this.loadImage(t)).catch(function(){}),i},r.prototype.match=function(t){return this._cache[t]},r.prototype.loadImage=function(t){return Co(this,void 0,void 0,function(){var i,s,A,o,g=this;return Js(this,function(d){switch(d.label){case 0:return i=V2.isSameOrigin(t),s=!mC(t)&&this._options.useCORS===!0&&Ts.SUPPORT_CORS_IMAGES&&!i,A=!mC(t)&&!i&&!CC(t)&&typeof this._options.proxy=="string"&&Ts.SUPPORT_CORS_XHR&&!s,!i&&this._options.allowTaint===!1&&!mC(t)&&!CC(t)&&!A&&!s?[2]:(o=t,A?[4,this.proxy(o)]:[3,2]);case 1:o=d.sent(),d.label=2;case 2:return this.context.logger.debug("Added image "+t.substring(0,256)),[4,new Promise(function(C,v){var x=new Image;x.onload=function(){return C(x)},x.onerror=v,(JE(o)||s)&&(x.crossOrigin="anonymous"),x.src=o,x.complete===!0&&setTimeout(function(){return C(x)},500),g._options.imageTimeout>0&&setTimeout(function(){return v("Timed out ("+g._options.imageTimeout+"ms) loading image")},g._options.imageTimeout)})];case 3:return[2,d.sent()]}})})},r.prototype.has=function(t){return typeof this._cache[t]<"u"},r.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},r.prototype.proxy=function(t){var i=this,s=this._options.proxy;if(!s)throw new Error("No proxy defined");var A=t.substring(0,256);return new Promise(function(o,g){var d=Ts.SUPPORT_RESPONSE_TYPE?"blob":"text",C=new XMLHttpRequest;C.onload=function(){if(C.status===200)if(d==="text")o(C.response);else{var T=new FileReader;T.addEventListener("load",function(){return o(T.result)},!1),T.addEventListener("error",function(G){return g(G)},!1),T.readAsDataURL(C.response)}else g("Failed to proxy resource "+A+" with status code "+C.status)},C.onerror=g;var v=s.indexOf("?")>-1?"&":"?";if(C.open("GET",""+s+v+"url="+encodeURIComponent(t)+"&responseType="+d),d!=="text"&&C instanceof XMLHttpRequest&&(C.responseType=d),i._options.imageTimeout){var x=i._options.imageTimeout;C.timeout=x,C.ontimeout=function(){return g("Timed out ("+x+"ms) proxying "+A)}}C.send()})},r}(),KE=/^data:image\/svg\+xml/i,WE=/^data:image\/.*;base64,/i,OE=/^data:image\/.*/i,zE=function(r){return Ts.SUPPORT_SVG_DRAWING||!XE(r)},mC=function(r){return OE.test(r)},JE=function(r){return WE.test(r)},CC=function(r){return r.substr(0,4)==="blob"},XE=function(r){return r.substr(-3).toLowerCase()==="svg"||KE.test(r)},yi=function(){function r(t,i){this.type=0,this.x=t,this.y=i}return r.prototype.add=function(t,i){return new r(this.x+t,this.y+i)},r}(),ku=function(r,t,i){return new yi(r.x+(t.x-r.x)*i,r.y+(t.y-r.y)*i)},Gd=function(){function r(t,i,s,A){this.type=1,this.start=t,this.startControl=i,this.endControl=s,this.end=A}return r.prototype.subdivide=function(t,i){var s=ku(this.start,this.startControl,t),A=ku(this.startControl,this.endControl,t),o=ku(this.endControl,this.end,t),g=ku(s,A,t),d=ku(A,o,t),C=ku(g,d,t);return i?new r(this.start,s,g,C):new r(C,d,o,this.end)},r.prototype.add=function(t,i){return new r(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},r.prototype.reverse=function(){return new r(this.end,this.endControl,this.startControl,this.start)},r}(),wa=function(r){return r.type===1},YE=function(){function r(t){var i=t.styles,s=t.bounds,A=jh(i.borderTopLeftRadius,s.width,s.height),o=A[0],g=A[1],d=jh(i.borderTopRightRadius,s.width,s.height),C=d[0],v=d[1],x=jh(i.borderBottomRightRadius,s.width,s.height),T=x[0],G=x[1],k=jh(i.borderBottomLeftRadius,s.width,s.height),W=k[0],K=k[1],$=[];$.push((o+C)/s.width),$.push((W+T)/s.width),$.push((g+K)/s.height),$.push((v+G)/s.height);var O=Math.max.apply(Math,$);O>1&&(o/=O,g/=O,C/=O,v/=O,T/=O,G/=O,W/=O,K/=O);var tt=s.width-C,at=s.height-G,Lt=s.width-T,Tt=s.height-K,Qt=i.borderTopWidth,Ft=i.borderRightWidth,vt=i.borderBottomWidth,Jt=i.borderLeftWidth,qt=ln(i.paddingTop,t.bounds.width),At=ln(i.paddingRight,t.bounds.width),lt=ln(i.paddingBottom,t.bounds.width),kt=ln(i.paddingLeft,t.bounds.width);this.topLeftBorderDoubleOuterBox=o>0||g>0?Cn(s.left+Jt/3,s.top+Qt/3,o-Jt/3,g-Qt/3,Wr.TOP_LEFT):new yi(s.left+Jt/3,s.top+Qt/3),this.topRightBorderDoubleOuterBox=o>0||g>0?Cn(s.left+tt,s.top+Qt/3,C-Ft/3,v-Qt/3,Wr.TOP_RIGHT):new yi(s.left+s.width-Ft/3,s.top+Qt/3),this.bottomRightBorderDoubleOuterBox=T>0||G>0?Cn(s.left+Lt,s.top+at,T-Ft/3,G-vt/3,Wr.BOTTOM_RIGHT):new yi(s.left+s.width-Ft/3,s.top+s.height-vt/3),this.bottomLeftBorderDoubleOuterBox=W>0||K>0?Cn(s.left+Jt/3,s.top+Tt,W-Jt/3,K-vt/3,Wr.BOTTOM_LEFT):new yi(s.left+Jt/3,s.top+s.height-vt/3),this.topLeftBorderDoubleInnerBox=o>0||g>0?Cn(s.left+Jt*2/3,s.top+Qt*2/3,o-Jt*2/3,g-Qt*2/3,Wr.TOP_LEFT):new yi(s.left+Jt*2/3,s.top+Qt*2/3),this.topRightBorderDoubleInnerBox=o>0||g>0?Cn(s.left+tt,s.top+Qt*2/3,C-Ft*2/3,v-Qt*2/3,Wr.TOP_RIGHT):new yi(s.left+s.width-Ft*2/3,s.top+Qt*2/3),this.bottomRightBorderDoubleInnerBox=T>0||G>0?Cn(s.left+Lt,s.top+at,T-Ft*2/3,G-vt*2/3,Wr.BOTTOM_RIGHT):new yi(s.left+s.width-Ft*2/3,s.top+s.height-vt*2/3),this.bottomLeftBorderDoubleInnerBox=W>0||K>0?Cn(s.left+Jt*2/3,s.top+Tt,W-Jt*2/3,K-vt*2/3,Wr.BOTTOM_LEFT):new yi(s.left+Jt*2/3,s.top+s.height-vt*2/3),this.topLeftBorderStroke=o>0||g>0?Cn(s.left+Jt/2,s.top+Qt/2,o-Jt/2,g-Qt/2,Wr.TOP_LEFT):new yi(s.left+Jt/2,s.top+Qt/2),this.topRightBorderStroke=o>0||g>0?Cn(s.left+tt,s.top+Qt/2,C-Ft/2,v-Qt/2,Wr.TOP_RIGHT):new yi(s.left+s.width-Ft/2,s.top+Qt/2),this.bottomRightBorderStroke=T>0||G>0?Cn(s.left+Lt,s.top+at,T-Ft/2,G-vt/2,Wr.BOTTOM_RIGHT):new yi(s.left+s.width-Ft/2,s.top+s.height-vt/2),this.bottomLeftBorderStroke=W>0||K>0?Cn(s.left+Jt/2,s.top+Tt,W-Jt/2,K-vt/2,Wr.BOTTOM_LEFT):new yi(s.left+Jt/2,s.top+s.height-vt/2),this.topLeftBorderBox=o>0||g>0?Cn(s.left,s.top,o,g,Wr.TOP_LEFT):new yi(s.left,s.top),this.topRightBorderBox=C>0||v>0?Cn(s.left+tt,s.top,C,v,Wr.TOP_RIGHT):new yi(s.left+s.width,s.top),this.bottomRightBorderBox=T>0||G>0?Cn(s.left+Lt,s.top+at,T,G,Wr.BOTTOM_RIGHT):new yi(s.left+s.width,s.top+s.height),this.bottomLeftBorderBox=W>0||K>0?Cn(s.left,s.top+Tt,W,K,Wr.BOTTOM_LEFT):new yi(s.left,s.top+s.height),this.topLeftPaddingBox=o>0||g>0?Cn(s.left+Jt,s.top+Qt,Math.max(0,o-Jt),Math.max(0,g-Qt),Wr.TOP_LEFT):new yi(s.left+Jt,s.top+Qt),this.topRightPaddingBox=C>0||v>0?Cn(s.left+Math.min(tt,s.width-Ft),s.top+Qt,tt>s.width+Ft?0:Math.max(0,C-Ft),Math.max(0,v-Qt),Wr.TOP_RIGHT):new yi(s.left+s.width-Ft,s.top+Qt),this.bottomRightPaddingBox=T>0||G>0?Cn(s.left+Math.min(Lt,s.width-Jt),s.top+Math.min(at,s.height-vt),Math.max(0,T-Ft),Math.max(0,G-vt),Wr.BOTTOM_RIGHT):new yi(s.left+s.width-Ft,s.top+s.height-vt),this.bottomLeftPaddingBox=W>0||K>0?Cn(s.left+Jt,s.top+Math.min(Tt,s.height-vt),Math.max(0,W-Jt),Math.max(0,K-vt),Wr.BOTTOM_LEFT):new yi(s.left+Jt,s.top+s.height-vt),this.topLeftContentBox=o>0||g>0?Cn(s.left+Jt+kt,s.top+Qt+qt,Math.max(0,o-(Jt+kt)),Math.max(0,g-(Qt+qt)),Wr.TOP_LEFT):new yi(s.left+Jt+kt,s.top+Qt+qt),this.topRightContentBox=C>0||v>0?Cn(s.left+Math.min(tt,s.width+Jt+kt),s.top+Qt+qt,tt>s.width+Jt+kt?0:C-Jt+kt,v-(Qt+qt),Wr.TOP_RIGHT):new yi(s.left+s.width-(Ft+At),s.top+Qt+qt),this.bottomRightContentBox=T>0||G>0?Cn(s.left+Math.min(Lt,s.width-(Jt+kt)),s.top+Math.min(at,s.height+Qt+qt),Math.max(0,T-(Ft+At)),G-(vt+lt),Wr.BOTTOM_RIGHT):new yi(s.left+s.width-(Ft+At),s.top+s.height-(vt+lt)),this.bottomLeftContentBox=W>0||K>0?Cn(s.left+Jt+kt,s.top+Tt,Math.max(0,W-(Jt+kt)),K-(vt+lt),Wr.BOTTOM_LEFT):new yi(s.left+Jt+kt,s.top+s.height-(vt+lt))}return r}();(function(r){r[r.TOP_LEFT=0]="TOP_LEFT",r[r.TOP_RIGHT=1]="TOP_RIGHT",r[r.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",r[r.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Wr||(Wr={}));Cn=function(r,t,i,s,A){var o=4*((Math.sqrt(2)-1)/3),g=i*o,d=s*o,C=r+i,v=t+s;switch(A){case Wr.TOP_LEFT:return new Gd(new yi(r,v),new yi(r,v-d),new yi(C-g,t),new yi(C,t));case Wr.TOP_RIGHT:return new Gd(new yi(r,t),new yi(r+g,t),new yi(C,v-d),new yi(C,v));case Wr.BOTTOM_RIGHT:return new Gd(new yi(C,t),new yi(C,t+d),new yi(r+g,v),new yi(r,v));case Wr.BOTTOM_LEFT:default:return new Gd(new yi(C,v),new yi(C-g,v),new yi(r,t+d),new yi(r,t))}},Yd=function(r){return[r.topLeftBorderBox,r.topRightBorderBox,r.bottomRightBorderBox,r.bottomLeftBorderBox]},jE=function(r){return[r.topLeftContentBox,r.topRightContentBox,r.bottomRightContentBox,r.bottomLeftContentBox]},jd=function(r){return[r.topLeftPaddingBox,r.topRightPaddingBox,r.bottomRightPaddingBox,r.bottomLeftPaddingBox]},qE=function(){function r(t,i,s){this.offsetX=t,this.offsetY=i,this.matrix=s,this.type=0,this.target=6}return r}(),Rd=function(){function r(t,i){this.path=t,this.target=i,this.type=1}return r}(),$E=function(){function r(t){this.opacity=t,this.type=2,this.target=6}return r}(),tT=function(r){return r.type===0},D2=function(r){return r.type===1},eT=function(r){return r.type===2},Dv=function(r,t){return r.length===t.length?r.some(function(i,s){return i===t[s]}):!1},iT=function(r,t,i,s,A){return r.map(function(o,g){switch(g){case 0:return o.add(t,i);case 1:return o.add(t+s,i);case 2:return o.add(t+s,i+A);case 3:return o.add(t,i+A)}return o})},K2=function(){function r(t){this.element=t,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return r}(),W2=function(){function r(t,i){if(this.container=t,this.parent=i,this.effects=[],this.curves=new YE(this.container),this.container.styles.opacity<1&&this.effects.push(new $E(this.container.styles.opacity)),this.container.styles.transform!==null){var s=this.container.bounds.left+this.container.styles.transformOrigin[0].number,A=this.container.bounds.top+this.container.styles.transformOrigin[1].number,o=this.container.styles.transform;this.effects.push(new qE(s,A,o))}if(this.container.styles.overflowX!==0){var g=Yd(this.curves),d=jd(this.curves);Dv(g,d)?this.effects.push(new Rd(g,6)):(this.effects.push(new Rd(g,2)),this.effects.push(new Rd(d,4)))}}return r.prototype.getEffects=function(t){for(var i=[2,3].indexOf(this.container.styles.position)===-1,s=this.parent,A=this.effects.slice(0);s;){var o=s.effects.filter(function(C){return!D2(C)});if(i||s.container.styles.position!==0||!s.parent){if(A.unshift.apply(A,o),i=[2,3].indexOf(s.container.styles.position)===-1,s.container.styles.overflowX!==0){var g=Yd(s.curves),d=jd(s.curves);Dv(g,d)||A.unshift(new Rd(d,6))}}else A.unshift.apply(A,o);s=s.parent}return A.filter(function(C){return as(C.target,t)})},r}(),VC=function(r,t,i,s){r.container.elements.forEach(function(A){var o=as(A.flags,4),g=as(A.flags,2),d=new W2(A,r);as(A.styles.display,2048)&&s.push(d);var C=as(A.flags,8)?[]:s;if(o||g){var v=o||A.styles.isPositioned()?i:t,x=new K2(d);if(A.styles.isPositioned()||A.styles.opacity<1||A.styles.isTransformed()){var T=A.styles.zIndex.order;if(T<0){var G=0;v.negativeZIndex.some(function(W,K){return T>W.element.container.styles.zIndex.order?(G=K,!1):G>0}),v.negativeZIndex.splice(G,0,x)}else if(T>0){var k=0;v.positiveZIndex.some(function(W,K){return T>=W.element.container.styles.zIndex.order?(k=K+1,!1):k>0}),v.positiveZIndex.splice(k,0,x)}else v.zeroOrAutoZIndexOrTransformedOrOpacity.push(x)}else A.styles.isFloating()?v.nonPositionedFloats.push(x):v.nonPositionedInlineLevel.push(x);VC(d,x,o?x:i,C)}else A.styles.isInlineLevel()?t.inlineLevel.push(d):t.nonInlineLevel.push(d),VC(d,t,i,C);as(A.flags,8)&&O2(A,C)})},O2=function(r,t){for(var i=r instanceof HC?r.start:1,s=r instanceof HC?r.reversed:!1,A=0;A"u"?r[0]:i},cT=function(r,t,i,s,A){var o=t[0],g=t[1],d=i[0],C=i[1];switch(r){case 2:return[new yi(Math.round(s.left),Math.round(s.top+g)),new yi(Math.round(s.left+s.width),Math.round(s.top+g)),new yi(Math.round(s.left+s.width),Math.round(C+s.top+g)),new yi(Math.round(s.left),Math.round(C+s.top+g))];case 3:return[new yi(Math.round(s.left+o),Math.round(s.top)),new yi(Math.round(s.left+o+d),Math.round(s.top)),new yi(Math.round(s.left+o+d),Math.round(s.height+s.top)),new yi(Math.round(s.left+o),Math.round(s.height+s.top))];case 1:return[new yi(Math.round(s.left+o),Math.round(s.top+g)),new yi(Math.round(s.left+o+d),Math.round(s.top+g)),new yi(Math.round(s.left+o+d),Math.round(s.top+g+C)),new yi(Math.round(s.left+o),Math.round(s.top+g+C))];default:return[new yi(Math.round(A.left),Math.round(A.top)),new yi(Math.round(A.left+A.width),Math.round(A.top)),new yi(Math.round(A.left+A.width),Math.round(A.height+A.top)),new yi(Math.round(A.left),Math.round(A.height+A.top))]}},uT="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",Wv="Hidden Text",hT=function(){function r(t){this._data={},this._document=t}return r.prototype.parseMetrics=function(t,i){var s=this._document.createElement("div"),A=this._document.createElement("img"),o=this._document.createElement("span"),g=this._document.body;s.style.visibility="hidden",s.style.fontFamily=t,s.style.fontSize=i,s.style.margin="0",s.style.padding="0",s.style.whiteSpace="nowrap",g.appendChild(s),A.src=uT,A.width=1,A.height=1,A.style.margin="0",A.style.padding="0",A.style.verticalAlign="baseline",o.style.fontFamily=t,o.style.fontSize=i,o.style.margin="0",o.style.padding="0",o.appendChild(this._document.createTextNode(Wv)),s.appendChild(o),s.appendChild(A);var d=A.offsetTop-o.offsetTop+2;s.removeChild(o),s.appendChild(this._document.createTextNode(Wv)),s.style.lineHeight="normal",A.style.verticalAlign="super";var C=A.offsetTop-s.offsetTop+2;return g.removeChild(s),{baseline:d,middle:C}},r.prototype.getMetrics=function(t,i){var s=t+" "+i;return typeof this._data[s]>"u"&&(this._data[s]=this.parseMetrics(t,i)),this._data[s]},r}(),J2=function(){function r(t,i){this.context=t,this.options=i}return r}(),gT=1e4,dT=function(r){$a(t,r);function t(i,s){var A=r.call(this,i,s)||this;return A._activeEffects=[],A.canvas=s.canvas?s.canvas:document.createElement("canvas"),A.ctx=A.canvas.getContext("2d"),s.canvas||(A.canvas.width=Math.floor(s.width*s.scale),A.canvas.height=Math.floor(s.height*s.scale),A.canvas.style.width=s.width+"px",A.canvas.style.height=s.height+"px"),A.fontMetrics=new hT(document),A.ctx.scale(A.options.scale,A.options.scale),A.ctx.translate(-s.x,-s.y),A.ctx.textBaseline="bottom",A._activeEffects=[],A.context.logger.debug("Canvas renderer initialized ("+s.width+"x"+s.height+") with scale "+s.scale),A}return t.prototype.applyEffects=function(i){for(var s=this;this._activeEffects.length;)this.popEffect();i.forEach(function(A){return s.applyEffect(A)})},t.prototype.applyEffect=function(i){this.ctx.save(),eT(i)&&(this.ctx.globalAlpha=i.opacity),tT(i)&&(this.ctx.translate(i.offsetX,i.offsetY),this.ctx.transform(i.matrix[0],i.matrix[1],i.matrix[2],i.matrix[3],i.matrix[4],i.matrix[5]),this.ctx.translate(-i.offsetX,-i.offsetY)),D2(i)&&(this.path(i.path),this.ctx.clip()),this._activeEffects.push(i)},t.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},t.prototype.renderStack=function(i){return Co(this,void 0,void 0,function(){var s;return Js(this,function(A){switch(A.label){case 0:return s=i.element.container.styles,s.isVisible()?[4,this.renderStackContent(i)]:[3,2];case 1:A.sent(),A.label=2;case 2:return[2]}})})},t.prototype.renderNode=function(i){return Co(this,void 0,void 0,function(){return Js(this,function(s){switch(s.label){case 0:if(as(i.container.flags,16))debugger;return i.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(i)]:[3,3];case 1:return s.sent(),[4,this.renderNodeContent(i)];case 2:s.sent(),s.label=3;case 3:return[2]}})})},t.prototype.renderTextWithLetterSpacing=function(i,s,A){var o=this;if(s===0)this.ctx.fillText(i.text,i.bounds.left,i.bounds.top+A);else{var g=zC(i.text);g.reduce(function(d,C){return o.ctx.fillText(C,d,i.bounds.top+A),d+o.ctx.measureText(C).width},i.bounds.left)}},t.prototype.createFontStyle=function(i){var s=i.fontVariant.filter(function(g){return g==="normal"||g==="small-caps"}).join(""),A=IT(i.fontFamily).join(", "),o=lg(i.fontSize)?""+i.fontSize.number+i.fontSize.unit:i.fontSize.number+"px";return[[i.fontStyle,s,i.fontWeight,o,A].join(" "),A,o]},t.prototype.renderTextNode=function(i,s){return Co(this,void 0,void 0,function(){var A,o,g,d,C,v,x,T,G=this;return Js(this,function(k){return A=this.createFontStyle(s),o=A[0],g=A[1],d=A[2],this.ctx.font=o,this.ctx.direction=s.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",C=this.fontMetrics.getMetrics(g,d),v=C.baseline,x=C.middle,T=s.paintOrder,i.textBounds.forEach(function(W){T.forEach(function(K){switch(K){case 0:G.ctx.fillStyle=ms(s.color),G.renderTextWithLetterSpacing(W,s.letterSpacing,v);var $=s.textShadow;$.length&&W.text.trim().length&&($.slice(0).reverse().forEach(function(O){G.ctx.shadowColor=ms(O.color),G.ctx.shadowOffsetX=O.offsetX.number*G.options.scale,G.ctx.shadowOffsetY=O.offsetY.number*G.options.scale,G.ctx.shadowBlur=O.blur.number,G.renderTextWithLetterSpacing(W,s.letterSpacing,v)}),G.ctx.shadowColor="",G.ctx.shadowOffsetX=0,G.ctx.shadowOffsetY=0,G.ctx.shadowBlur=0),s.textDecorationLine.length&&(G.ctx.fillStyle=ms(s.textDecorationColor||s.color),s.textDecorationLine.forEach(function(O){switch(O){case 1:G.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top+v),W.bounds.width,1);break;case 2:G.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top),W.bounds.width,1);break;case 3:G.ctx.fillRect(W.bounds.left,Math.ceil(W.bounds.top+x),W.bounds.width,1);break}}));break;case 1:s.webkitTextStrokeWidth&&W.text.trim().length&&(G.ctx.strokeStyle=ms(s.webkitTextStrokeColor),G.ctx.lineWidth=s.webkitTextStrokeWidth,G.ctx.lineJoin=window.chrome?"miter":"round",G.ctx.strokeText(W.text,W.bounds.left,W.bounds.top+v)),G.ctx.strokeStyle="",G.ctx.lineWidth=0,G.ctx.lineJoin="miter";break}})}),[2]})})},t.prototype.renderReplacedElement=function(i,s,A){if(A&&i.intrinsicWidth>0&&i.intrinsicHeight>0){var o=qd(i),g=jd(s);this.path(g),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(A,0,0,i.intrinsicWidth,i.intrinsicHeight,o.left,o.top,o.width,o.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(i){return Co(this,void 0,void 0,function(){var s,A,o,g,d,C,tt,tt,v,x,T,G,Lt,k,W,Tt,K,$,O,tt,at,Lt,Tt;return Js(this,function(Qt){switch(Qt.label){case 0:this.applyEffects(i.getEffects(4)),s=i.container,A=i.curves,o=s.styles,g=0,d=s.textNodes,Qt.label=1;case 1:return g0&&_t>0&&(vt=o.ctx.createPattern(Tt,"repeat"),o.renderRepeat(qt,vt,ie,ne))):ek(x)&&(Jt=IC(i,s,[null,null,null]),qt=Jt[0],At=Jt[1],lt=Jt[2],kt=Jt[3],_t=Jt[4],le=x.position.length===0?[KC]:x.position,ie=ln(le[0],kt),ne=ln(le[le.length-1],_t),te=Y4(x,ie,ne,kt,_t),wt=te[0],Ut=te[1],wt>0&&Ut>0&&(fe=o.ctx.createRadialGradient(At+ie,lt+ne,0,At+ie,lt+ne,wt),hv(x.stops,wt*2).forEach(function(Ae){return fe.addColorStop(Ae.stop,ms(Ae.color))}),o.path(qt),o.ctx.fillStyle=fe,wt!==Ut?(j=i.bounds.left+.5*i.bounds.width,bt=i.bounds.top+.5*i.bounds.height,It=Ut/wt,Ht=1/It,o.ctx.save(),o.ctx.translate(j,bt),o.ctx.transform(1,0,0,It,0,0),o.ctx.translate(-j,-bt),o.ctx.fillRect(At,Ht*(lt-bt)+bt,kt,_t*Ht),o.ctx.restore()):o.ctx.fill())),Ot.label=6;case 6:return s--,[2]}})},o=this,g=0,d=i.styles.backgroundImage.slice(0).reverse(),v.label=1;case 1:return g0?x.style!==2?[3,5]:[4,this.renderDashedDottedBorder(x.color,x.width,d,i.curves,2)]:[3,11]):[3,13];case 4:return G.sent(),[3,11];case 5:return x.style!==3?[3,7]:[4,this.renderDashedDottedBorder(x.color,x.width,d,i.curves,3)];case 6:return G.sent(),[3,11];case 7:return x.style!==4?[3,9]:[4,this.renderDoubleBorder(x.color,x.width,d,i.curves)];case 8:return G.sent(),[3,11];case 9:return[4,this.renderSolidBorder(x.color,d,i.curves)];case 10:G.sent(),G.label=11;case 11:d++,G.label=12;case 12:return C++,[3,3];case 13:return[2]}})})},t.prototype.renderDashedDottedBorder=function(i,s,A,o,g){return Co(this,void 0,void 0,function(){var d,C,v,x,T,G,k,W,K,$,O,tt,at,Lt,Tt,Qt,Tt,Qt;return Js(this,function(Ft){return this.ctx.save(),d=oT(o,A),C=Kv(o,A),g===2&&(this.path(C),this.ctx.clip()),wa(C[0])?(v=C[0].start.x,x=C[0].start.y):(v=C[0].x,x=C[0].y),wa(C[1])?(T=C[1].end.x,G=C[1].end.y):(T=C[1].x,G=C[1].y),A===0||A===2?k=Math.abs(v-T):k=Math.abs(x-G),this.ctx.beginPath(),g===3?this.formatPath(d):this.formatPath(C.slice(0,2)),W=s<3?s*3:s*2,K=s<3?s*2:s,g===3&&(W=s,K=s),$=!0,k<=W*2?$=!1:k<=W*2+K?(O=k/(2*W+K),W*=O,K*=O):(tt=Math.floor((k+K)/(W+K)),at=(k-tt*W)/(tt-1),Lt=(k-(tt+1)*W)/tt,K=Lt<=0||Math.abs(K-at)eQ});function Ac(r){return Ac=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ac(r)}function i0(r,t){return i0=Object.setPrototypeOf||function(i,s){return i.__proto__=s,i},i0(r,t)}function ST(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function up(r,t,i){return ST()?up=Reflect.construct:up=function(s,A,o){var g=[null];g.push.apply(g,A);var d=Function.bind.apply(s,g),C=new d;return o&&i0(C,o.prototype),C},up.apply(null,arguments)}function eA(r){return FT(r)||kT(r)||LT(r)||ET()}function FT(r){if(Array.isArray(r))return r0(r)}function kT(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function LT(r,t){if(r){if(typeof r=="string")return r0(r,t);var i=Object.prototype.toString.call(r).slice(8,-1);if(i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set")return Array.from(r);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return r0(r,t)}}function r0(r,t){(t==null||t>r.length)&&(t=r.length);for(var i=0,s=new Array(t);i1?i-1:0),A=1;A0&&arguments[0]!==void 0?arguments[0]:$T(),t=function(Dt){return nw(Dt)};if(t.version="2.4.7",t.removed=[],!r||!r.document||r.document.nodeType!==9)return t.isSupported=!1,t;var i=r.document,s=r.document,A=r.DocumentFragment,o=r.HTMLTemplateElement,g=r.Node,d=r.Element,C=r.NodeFilter,v=r.NamedNodeMap,x=v===void 0?r.NamedNodeMap||r.MozNamedAttrMap:v,T=r.HTMLFormElement,G=r.DOMParser,k=r.trustedTypes,W=d.prototype,K=lp(W,"cloneNode"),$=lp(W,"nextSibling"),O=lp(W,"childNodes"),tt=lp(W,"parentNode");if(typeof o=="function"){var at=s.createElement("template");at.content&&at.content.ownerDocument&&(s=at.content.ownerDocument)}var Lt=tQ(k,i),Tt=Lt?Lt.createHTML(""):"",Qt=s,Ft=Qt.implementation,vt=Qt.createNodeIterator,Jt=Qt.createDocumentFragment,qt=Qt.getElementsByTagName,At=i.importNode,lt={};try{lt=Pc(s).documentMode?s.documentMode:{}}catch{}var kt={};t.isSupported=typeof tt=="function"&&Ft&&Ft.createHTMLDocument!==void 0&<!==9;var _t=KT,le=WT,ie=OT,ne=zT,te=JT,wt=YT,Ut=jT,fe=XT,j=null,bt=yr({},[].concat(eA($2),eA(qC),eA($C),eA(t0),eA(tw))),It=null,Ht=yr({},[].concat(eA(ew),eA(e0),eA(iw),eA(cp))),Ot=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,he=null,de=!0,He=!0,Re=!1,je=!0,Me=!1,gi=!1,xt=!1,Rt=!1,Li=!1,Ue=!1,Ee=!1,Ne=!0,Je=!1,ze="user-content-",ui=!0,hi=!1,Ei={},Pi=null,Ie=yr({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Oi=null,mi=yr({},["audio","video","img","source","image","track"]),Vi=null,We=yr({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Se="http://www.w3.org/1998/Math/MathML",$e="http://www.w3.org/2000/svg",di="http://www.w3.org/1999/xhtml",Zi=di,qi=!1,vi=null,tr=yr({},[Se,$e,di],YC),Lr,ft=["application/xhtml+xml","text/html"],Y="text/html",q,rt=null,ht=s.createElement("form"),Zt=function(Dt){return Dt instanceof RegExp||Dt instanceof Function},zt=function(Dt){rt&&rt===Dt||((!Dt||Ac(Dt)!=="object")&&(Dt={}),Dt=Pc(Dt),Lr=ft.indexOf(Dt.PARSER_MEDIA_TYPE)===-1?Lr=Y:Lr=Dt.PARSER_MEDIA_TYPE,q=Lr==="application/xhtml+xml"?YC:hp,j="ALLOWED_TAGS"in Dt?yr({},Dt.ALLOWED_TAGS,q):bt,It="ALLOWED_ATTR"in Dt?yr({},Dt.ALLOWED_ATTR,q):Ht,vi="ALLOWED_NAMESPACES"in Dt?yr({},Dt.ALLOWED_NAMESPACES,YC):tr,Vi="ADD_URI_SAFE_ATTR"in Dt?yr(Pc(We),Dt.ADD_URI_SAFE_ATTR,q):We,Oi="ADD_DATA_URI_TAGS"in Dt?yr(Pc(mi),Dt.ADD_DATA_URI_TAGS,q):mi,Pi="FORBID_CONTENTS"in Dt?yr({},Dt.FORBID_CONTENTS,q):Ie,Ae="FORBID_TAGS"in Dt?yr({},Dt.FORBID_TAGS,q):{},he="FORBID_ATTR"in Dt?yr({},Dt.FORBID_ATTR,q):{},Ei="USE_PROFILES"in Dt?Dt.USE_PROFILES:!1,de=Dt.ALLOW_ARIA_ATTR!==!1,He=Dt.ALLOW_DATA_ATTR!==!1,Re=Dt.ALLOW_UNKNOWN_PROTOCOLS||!1,je=Dt.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=Dt.SAFE_FOR_TEMPLATES||!1,gi=Dt.WHOLE_DOCUMENT||!1,Li=Dt.RETURN_DOM||!1,Ue=Dt.RETURN_DOM_FRAGMENT||!1,Ee=Dt.RETURN_TRUSTED_TYPE||!1,Rt=Dt.FORCE_BODY||!1,Ne=Dt.SANITIZE_DOM!==!1,Je=Dt.SANITIZE_NAMED_PROPS||!1,ui=Dt.KEEP_CONTENT!==!1,hi=Dt.IN_PLACE||!1,fe=Dt.ALLOWED_URI_REGEXP||fe,Zi=Dt.NAMESPACE||di,Ot=Dt.CUSTOM_ELEMENT_HANDLING||{},Dt.CUSTOM_ELEMENT_HANDLING&&Zt(Dt.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ot.tagNameCheck=Dt.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Dt.CUSTOM_ELEMENT_HANDLING&&Zt(Dt.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ot.attributeNameCheck=Dt.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Dt.CUSTOM_ELEMENT_HANDLING&&typeof Dt.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Ot.allowCustomizedBuiltInElements=Dt.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Me&&(He=!1),Ue&&(Li=!0),Ei&&(j=yr({},eA(tw)),It=[],Ei.html===!0&&(yr(j,$2),yr(It,ew)),Ei.svg===!0&&(yr(j,qC),yr(It,e0),yr(It,cp)),Ei.svgFilters===!0&&(yr(j,$C),yr(It,e0),yr(It,cp)),Ei.mathMl===!0&&(yr(j,t0),yr(It,iw),yr(It,cp))),Dt.ADD_TAGS&&(j===bt&&(j=Pc(j)),yr(j,Dt.ADD_TAGS,q)),Dt.ADD_ATTR&&(It===Ht&&(It=Pc(It)),yr(It,Dt.ADD_ATTR,q)),Dt.ADD_URI_SAFE_ATTR&&yr(Vi,Dt.ADD_URI_SAFE_ATTR,q),Dt.FORBID_CONTENTS&&(Pi===Ie&&(Pi=Pc(Pi)),yr(Pi,Dt.FORBID_CONTENTS,q)),ui&&(j["#text"]=!0),gi&&yr(j,["html","head","body"]),j.table&&(yr(j,["tbody"]),delete Ae.tbody),bo&&bo(Dt),rt=Dt)},Xt=yr({},["mi","mo","mn","ms","mtext"]),Mt=yr({},["foreignobject","desc","title","annotation-xml"]),re=yr({},["title","style","font","a","script"]),ce=yr({},qC);yr(ce,$C),yr(ce,VT);var pe=yr({},t0);yr(pe,DT);var me=function(Dt){var Ke=tt(Dt);(!Ke||!Ke.tagName)&&(Ke={namespaceURI:Zi,tagName:"template"});var Te=hp(Dt.tagName),or=hp(Ke.tagName);return vi[Dt.namespaceURI]?Dt.namespaceURI===$e?Ke.namespaceURI===di?Te==="svg":Ke.namespaceURI===Se?Te==="svg"&&(or==="annotation-xml"||Xt[or]):!!ce[Te]:Dt.namespaceURI===Se?Ke.namespaceURI===di?Te==="math":Ke.namespaceURI===$e?Te==="math"&&Mt[or]:!!pe[Te]:Dt.namespaceURI===di?Ke.namespaceURI===$e&&!Mt[or]||Ke.namespaceURI===Se&&!Xt[or]?!1:!pe[Te]&&(re[Te]||!ce[Te]):!!(Lr==="application/xhtml+xml"&&vi[Dt.namespaceURI]):!1},Xe=function(Dt){cg(t.removed,{element:Dt});try{Dt.parentNode.removeChild(Dt)}catch{try{Dt.outerHTML=Tt}catch{Dt.remove()}}},oi=function(Dt,Ke){try{cg(t.removed,{attribute:Ke.getAttributeNode(Dt),from:Ke})}catch{cg(t.removed,{attribute:null,from:Ke})}if(Ke.removeAttribute(Dt),Dt==="is"&&!It[Dt])if(Li||Ue)try{Xe(Ke)}catch{}else try{Ke.setAttribute(Dt,"")}catch{}},ii=function(Dt){var Ke,Te;if(Rt)Dt=""+Dt;else{var or=ZT(Dt,/^[\r\n\t ]+/);Te=or&&or[0]}Lr==="application/xhtml+xml"&&Zi===di&&(Dt=''+Dt+"");var Er=Lt?Lt.createHTML(Dt):Dt;if(Zi===di)try{Ke=new G().parseFromString(Er,Lr)}catch{}if(!Ke||!Ke.documentElement){Ke=Ft.createDocument(Zi,"template",null);try{Ke.documentElement.innerHTML=qi?Tt:Er}catch{}}var Ji=Ke.body||Ke.documentElement;return Dt&&Te&&Ji.insertBefore(s.createTextNode(Te),Ji.childNodes[0]||null),Zi===di?qt.call(Ke,gi?"html":"body")[0]:gi?Ke.documentElement:Ji},Ni=function(Dt){return vt.call(Dt.ownerDocument||Dt,Dt,C.SHOW_ELEMENT|C.SHOW_COMMENT|C.SHOW_TEXT,null,!1)},Qi=function(Dt){return Dt instanceof T&&(typeof Dt.nodeName!="string"||typeof Dt.textContent!="string"||typeof Dt.removeChild!="function"||!(Dt.attributes instanceof x)||typeof Dt.removeAttribute!="function"||typeof Dt.setAttribute!="function"||typeof Dt.namespaceURI!="string"||typeof Dt.insertBefore!="function"||typeof Dt.hasChildNodes!="function")},rr=function(Dt){return Ac(g)==="object"?Dt instanceof g:Dt&&Ac(Dt)==="object"&&typeof Dt.nodeType=="number"&&typeof Dt.nodeName=="string"},zi=function(Dt,Ke,Te){kt[Dt]&&HT(kt[Dt],function(or){or.call(t,Ke,Te,rt)})},Cr=function(Dt){var Ke;if(zi("beforeSanitizeElements",Dt,null),Qi(Dt)||yo(/[\u0080-\uFFFF]/,Dt.nodeName))return Xe(Dt),!0;var Te=q(Dt.nodeName);if(zi("uponSanitizeElement",Dt,{tagName:Te,allowedTags:j}),Dt.hasChildNodes()&&!rr(Dt.firstElementChild)&&(!rr(Dt.content)||!rr(Dt.content.firstElementChild))&&yo(/<[/\w]/g,Dt.innerHTML)&&yo(/<[/\w]/g,Dt.textContent)||Te==="select"&&yo(/