Files
torebki-fabiola.pl/wp-content/plugins/mapster-wp-maps/admin/js/dist/compiled/mapbox-chart-mwp.js
2026-03-05 13:07:40 +01:00

29 lines
1.4 MiB
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mapboxgl=e()}(this,(function(){"use strict";var t,e,i;function r(r,n){if(t)if(e){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s);i=n(s);"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=n;else t=n}r(0,(function(t){var e="undefined"!=typeof self?self:{},i=r;function r(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=i,this.p2y=r}r.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},r.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},r.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},r.prototype.solveCurveX=function(t,e){var i,r,n,o,s;for(void 0===e&&(e=1e-6),n=t,s=0;s<8;s++){if(o=this.sampleCurveX(n)-t,Math.abs(o)<e)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=o/a}if((n=t)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-t)<e)return n;t>o?i=n:r=n,n=.5*(r-i)+i}return n},r.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var n=o;function o(t,e){this.x=t,this.y=e}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(t){return t instanceof o?t:Array.isArray(t)?new o(t[0],t[1]):t};const s=Math.PI/180,a=180/Math.PI;function l(t){return t*s}function c(t){return t*a}const u=[[0,0],[1,0],[1,1],[0,1]];function h(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function p(t,e,r,n){const o=new i(t,e,r,n);return function(t){return o.solve(t)}}const d=p(.25,.1,.25,1);function f(t,e,i){return Math.min(i,Math.max(e,t))}function m(t,e,i){return(i=f((i-t)/(e-t),0,1))*i*(3-2*i)}function _(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function g(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let o=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(o=t),n[s]=e,0==--r&&i(o,n)}))}))}function y(t){const e=[];for(const i in t)e.push(t[i]);return e}function v(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let x=1;function b(){return x++}function w(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function T(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function M(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function E(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function C(t,e){return-1!==t.indexOf(e,t.length-e.length)}function S(t,e,i){const r={};for(const n in t)r[n]=e.call(i||this,t[n],n,t);return r}function k(t,e,i){const r={};for(const n in t)e.call(i||this,t[n],n,t)&&(r[n]=t[n]);return r}function A(t){return Array.isArray(t)?t.map(A):"object"==typeof t&&t?S(t,A):t}const I={};function P(t){I[t]||("undefined"!=typeof console&&console.warn(t),I[t]=!0)}function L(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function z(t){let e=0;for(let i,r,n=0,o=t.length,s=o-1;n<o;s=n++)i=t[n],r=t[s],e+=(r.x-i.x)*(i.y+r.y);return e}function D(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function R(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const o=r||n;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let O=null;function F(t){if(null==O){const e=t.navigator?t.navigator.userAgent:null;O=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return O}function B(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function j(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const N=e.performance;function V(t){const e=t?t.url.toString():void 0;return N.getEntriesByName(e)}var U="2.9.1";let $,G,q,Z;const H={now:()=>void 0!==q?q:e.performance.now(),setNow(t){q=t},restoreNow(){q=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:r,height:n}=t;Z||(Z=e.document.createElement("canvas"));const o=Z.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(r>Z.width||n>Z.height)&&(Z.width=r,Z.height=n),o.clearRect(-i,-i,r+2*i,n+2*i),o.drawImage(t,0,0,r,n),o.getImageData(-i,-i,r+2*i,n+2*i)},resolveURL:t=>($||($=e.document.createElement("a")),$.href=t,$.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==G&&(G=e.matchMedia("(prefers-reduced-motion: reduce)")),G.matches)}};let W;const X={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==W){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{W=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){W=t}}return W},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},Q={supported:!1,testSupport:function(t){!K&&J&&(tt?et(t):Y=t)}};let Y,J,K=!1,tt=!1;function et(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,J),t.isContextLost())return;Q.supported=!0}catch(t){}t.deleteTexture(e),K=!0}e.document&&(J=e.document.createElement("img"),J.onload=function(){Y&&et(Y),Y=null,tt=!0},J.onerror=function(){K=!0,Y=null},J.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const it="01",rt="NO_ACCESS_TOKEN";function nt(t){return 0===t.indexOf("mapbox:")}function ot(t){return X.API_URL_REGEX.test(t)}const st=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function at(t){const e=t.match(st);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function lt(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function ct(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class ut{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=ct(X.ACCESS_TOKEN);let r="";return r=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):X.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${r}`:`mapbox.eventData:${r}`}fetchEventData(){const t=B("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const n=e.localStorage.getItem(r);n&&(this.anonId=n)}catch(t){P("Unable to read from LocalStorage")}}saveEventData(){const t=B("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(t){P("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,r){if(!X.EVENTS_URL)return;const n=at(X.EVENTS_URL);n.params.push(`access_token=${r||X.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:U,skuId:it,userId:this.anonId},s=e?v(o,e):o,a={url:lt(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Lt(a,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const ht=new class extends ut{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){X.EVENTS_URL&&X.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>nt(t)||ot(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=ct(X.ACCESS_TOKEN),i=e?e.u:X.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;M(this.anonId)||(this.anonId=w(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;r?this.postEvent(n,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),t):this.processRequests()}},pt=ht.postTurnstileEvent.bind(ht),dt=new class extends ut{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,X.EVENTS_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(rt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),M(this.anonId)||(this.anonId=w()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},ft=dt.postMapLoadEvent.bind(dt),mt=new class extends ut{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!X.API_URL||!X.SESSION_PATH)return;const n=at(X.API_URL+X.SESSION_PATH);n.params.push(`sku=${e||""}`),n.params.push(`access_token=${r||X.ACCESS_TOKEN||""}`);const o={url:lt(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=zt(o,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,X.SESSION_PATH&&X.API_URL&&(i||X.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(rt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},_t=mt.getSessionAPI.bind(mt),gt=new Set;let yt,vt=500,xt=50,bt={};function wt(t){const e=Mt(t);let i,r;e&&e.forEach((t=>{const e=t.split("=");"language"===e[0]?i=e[1]:"worldview"===e[0]&&(r=e[1])}));let n="mapbox-tiles";return i&&(n+=`-${i}`),r&&(n+=`-${r}`),n}function Tt(t){e.caches&&!bt[t]&&(bt[t]=e.caches.open(t))}function Mt(t){const e=t.indexOf("?");return e>0?t.slice(e+1).split("&"):[]}function Et(t){const e=t.indexOf("?");if(e<0)return t;const i=Mt(t).filter((t=>{const e=t.split("=");return"language"===e[0]||"worldview"===e[0]}));return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let Ct=1/0;const St={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(St);class kt extends Error{constructor(t,e,i){401===e&&ot(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const At=D()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href,It=function(t,i){if(!(/^file:/.test(r=t.url)||/^file:/.test(At())&&!/^\w+:/.test(r))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const r=new e.AbortController,n=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:At(),signal:r.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&ot(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const c=(r,o,l)=>{if(s)return;if(r&&"SecurityError"!==r.message&&P(r),o&&l)return u(o);const c=Date.now();e.fetch(n).then((e=>{if(e.ok){const t=a?e.clone():null;return u(e,t,c)}return i(new kt(e.statusText,e.status,t.url))})).catch((t=>{20!==t.code&&i(new Error(t.message))}))},u=(r,a,l)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(a&&l&&function(t,i,r){const n=wt(t.url);if(Tt(n),!bt[n])return;const o={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((t,e)=>o.headers.set(e,t)));const s=R(i.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&o.headers.set("Expires",new Date(r+1e3*s["max-age"]).toUTCString());const a=o.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(t,e){if(void 0===yt)try{new Response(new ReadableStream),yt=!0}catch(t){yt=!1}yt?e(t.body):t.blob().then(e)}(i,(i=>{const r=new e.Response(i,o);Tt(n),bt[n]&&bt[n].then((e=>e.put(Et(t.url),r))).catch((t=>P(t.message)))})))}(n,a,l),o=!0,i(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((t=>{s||i(new Error(t.message))}))};return a?function(t,e){const i=wt(t.url);if(Tt(i),!bt[i])return e(null);const r=Et(t.url);bt[i].then((t=>{t.match(r).then((i=>{const n=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=R(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(i);t.delete(r),n&&t.put(r,i.clone()),e(null,i,n)})).catch(e)})).catch(e)}(n,c):c(null,null),{cancel:()=>{s=!0,o||r.abort()}}}(t,i);if(D()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var r;return function(t,i){const r=new e.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(t){return i(t)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new kt(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,i)},Pt=function(t,e){return It(v(t,{type:"arrayBuffer"}),e)},Lt=function(t,e){return It(v(t,{method:"POST"}),e)},zt=function(t,e){return It(v(t,{method:"GET"}),e)};function Dt(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const Rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ot,Ft;Ot=[],Ft=0;const Bt=function(t,i){if(Q.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Ft>=X.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return Ot.push(e),e}Ft++;let r=!1;const n=()=>{if(!r)for(r=!0,Ft--;Ot.length&&Ft<X.MAX_PARALLEL_IMAGE_REQUESTS;){const t=Ot.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=Bt(e,i).cancel)}},o=Pt(t,((t,r,o,s)=>{n(),t?i(t):r&&(e.createImageBitmap?function(t,i){const r=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(r).then((t=>{i(null,t)})).catch((t=>{i(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((t,e)=>i(t,e,o,s))):function(t,i){const r=new e.Image,n=e.URL;r.onload=()=>{i(null,r),n.revokeObjectURL(r.src),r.onload=null,e.requestAnimationFrame((()=>{r.src=Rt}))},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new e.Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?n.createObjectURL(o):Rt}(r,((t,e)=>i(t,e,o,s))))}));return{cancel:()=>{o.cancel(),n()}}};function jt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Nt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class Vt{constructor(t,e={}){v(this,e),this.type=t}}class Ut extends Vt{constructor(t,e={}){super("error",v({error:t},e))}}class $t{on(t,e){return this._listeners=this._listeners||{},jt(t,e,this._listeners),this}off(t,e){return Nt(t,e,this._listeners),Nt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},jt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Vt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)Nt(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(v(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof Ut&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var Gt=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"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":true,"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":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"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_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"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":true,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"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":true,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"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":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"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_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"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":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"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"}}}');function qt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function Zt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ht(t){if(Array.isArray(t))return t.map(Ht);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Ht(t[i]);return e}return Zt(t)}class Wt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var Xt=Wt;class Qt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Qt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var Yt=Qt;const Jt={kind:"null"},Kt={kind:"number"},te={kind:"string"},ee={kind:"boolean"},ie={kind:"color"},re={kind:"object"},ne={kind:"value"},oe={kind:"collator"},se={kind:"formatted"},ae={kind:"resolvedImage"};function le(t,e){return{kind:"array",itemType:t,N:e}}function ce(t){if("array"===t.kind){const e=ce(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const ue=[Jt,Kt,te,ee,ie,se,re,le(ne),ae];function he(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!he(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of ue)if(!he(t,e))return null}return`Expected ${ce(t)} but found ${ce(e)} instead.`}function pe(t,e){return e.some((e=>e.kind===t.kind))}function de(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function fe(t){var e={exports:{}};return t(e,e.exports),e.exports}var me=fe((function(t,e){var i={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function r(t){return(t=Math.round(t))<0?0:t>255?255:t}function n(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function s(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*s(g,_,d+1/3)),r(255*s(g,_,d)),r(255*s(g,_,d-1/3)),p];default:return null}}return null}}catch(t){}}));class _e{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof _e)return t;if("string"!=typeof t)return;const e=me.parseCSSColor(t);return e?new _e(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}toArray01(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[t/r,e/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:r}=this;return[t,e,i,r]}}_e.black=new _e(0,0,0,1),_e.white=new _e(1,1,1,1),_e.transparent=new _e(0,0,0,0),_e.red=new _e(1,0,0,1),_e.blue=new _e(0,0,1,1);var ge=_e;class ye{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ve{constructor(t,e,i,r,n){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n}}class xe{constructor(t){this.sections=t}static fromString(t){return new xe([new ve(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof xe?t:xe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class be{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new be({name:t,available:!1}):null}serialize(){return["image",this.name]}}function we(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Te(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ge)return!0;if(t instanceof ye)return!0;if(t instanceof xe)return!0;if(t instanceof be)return!0;if(Array.isArray(t)){for(const e of t)if(!Te(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Te(t[e]))return!1;return!0}return!1}function Me(t){if(null===t)return Jt;if("string"==typeof t)return te;if("boolean"==typeof t)return ee;if("number"==typeof t)return Kt;if(t instanceof ge)return ie;if(t instanceof ye)return oe;if(t instanceof xe)return se;if(t instanceof be)return ae;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Me(e);if(i){if(i===t)continue;i=ne;break}i=t}return le(i||ne,e)}return re}function Ee(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ge||t instanceof xe||t instanceof be?t.toString():JSON.stringify(t)}class Ce{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Te(t[1]))return e.error("invalid value");const i=t[1];let r=Me(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Ce(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ge?["rgba"].concat(this.value.toArray()):this.value instanceof xe?this.value.serialize():this.value}}var Se=Ce,ke=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Ae={string:te,number:Kt,boolean:ee,object:re};class Ie{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,o;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in Ae)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=Ae[i],r++}else n=ne;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],r++}i=le(n,o)}else i=Ae[n];const o=[];for(;r<t.length;r++){const i=e.parse(t[r],r,ne);if(!i)return null;o.push(i)}return new Ie(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!he(this.type,Me(i)))return i;if(e===this.args.length-1)throw new ke(`Expected value to be of type ${ce(this.type)}, but found ${ce(Me(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}var Pe=Ie;class Le{constructor(t){this.type=se,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const o=t[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,Kt),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,le(te)),!i))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,ie),!s))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=s}else{const o=e.parse(t[i],1,ne);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Le(r)}evaluate(t){return new xe(this.sections.map((e=>{const i=e.content.evaluate(t);return Me(i)===ae?new ve("",i,null,null,null):new ve(Ee(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class ze{constructor(t){this.type=ae,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,te);return i?new ze(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=be.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const De={"to-boolean":ee,"to-color":ie,"to-number":Kt,"to-string":te};class Re{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=De[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,ne);if(!r)return null;n.push(r)}return new Re(r,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof ge)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:we(e[0],e[1],e[2],e[3]),!i))return new ge(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ke(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new ke(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?xe.fromString(Ee(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?be.fromString(Ee(this.args[0].evaluate(t))):Ee(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Le([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ze(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Oe=Re;const Fe=["Unknown","Point","LineString","Polygon"];var Be=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Fe[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ge.parse(t)),e}};class je{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=je.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,o]of s){a=new pi(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,o=a.parse(i,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(r)&&r.length!==s.length)a.error(`Expected ${r.length} arguments, but found ${s.length} instead.`);else{for(let t=0;t<s.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=s[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new je(i,n,o,s)}}if(1===s.length)e.errors.push(...a.errors);else{const i=(s.length?s:o).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(ce).join(", ")})`:`(${ce(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(ce(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){je.definitions=e;for(const i in e)t[i]=je}}var Ne=je;class Ve{constructor(t,e,i){this.type=oe,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,ee);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,ee);if(!n)return null;let o=null;return i.locale&&(o=e.parse(i.locale,1,te),!o)?null:new Ve(r,n,o)}evaluate(t){return new ye(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const Ue=8192;function $e(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Ge(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function qe(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*Ue),Math.round(r*n*Ue)]}function Ze(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function He(t,e){let i=!1;for(let s=0,a=e.length;s<a;s++){const a=e[s];for(let e=0,s=a.length;e<s-1;e++){if(Ze(t,a[e],a[e+1]))return!1;(n=a[e])[1]>(r=t)[1]!=(o=a[e+1])[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function We(t,e){for(let i=0;i<e.length;i++)if(He(t,e[i]))return!0;return!1}function Xe(t,e,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(t[0]-i[0])*o-n*(t[1]-i[1]),a=(e[0]-i[0])*o-n*(e[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Qe(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(a=[(s=c[i+1])[0]-(o=c[i])[0],s[1]-o[1]])[0]*(l=[(n=e)[0]-(r=t)[0],n[1]-r[1]])[1]-a[1]*l[0]&&Xe(r,n,o,s)&&Xe(o,s,r,n))return!0;var r,n,o,s,a,l;return!1}function Ye(t,e){for(let i=0;i<t.length;++i)if(!He(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(Qe(t[i],t[i+1],e))return!1;return!0}function Je(t,e){for(let i=0;i<e.length;i++)if(Ye(t,e[i]))return!0;return!1}function Ke(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=[];for(let r=0;r<t[n].length;r++){const s=qe(t[n][r],i);$e(e,s),o.push(s)}r.push(o)}return r}function ti(t,e,i){const r=[];for(let n=0;n<t.length;n++){const o=Ke(t[n],e,i);r.push(o)}return r}function ei(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}$e(e,t)}function ii(t,e,i,r){const n=Math.pow(2,r.z)*Ue,o=[r.x*Ue,r.y*Ue],s=[];if(!t)return s;for(const r of t)for(const t of r){const r=[t.x+o[0],t.y+o[1]];ei(r,e,i,n),s.push(r)}return s}function ri(t,e,i,r){const n=Math.pow(2,r.z)*Ue,o=[r.x*Ue,r.y*Ue],s=[];if(!t)return s;for(const i of t){const t=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];$e(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const r of t)ei(r,e,i,n)}var a;return s}class ni{constructor(t,e){this.type=ee,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Te(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new ni(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new ni(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new ni(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(!n)return!1;if("Polygon"===e.type){const o=Ke(e.coordinates,r,n),s=ii(t.geometry(),i,r,n);if(!Ge(i,r))return!1;for(const t of s)if(!He(t,o))return!1}if("MultiPolygon"===e.type){const o=ti(e.coordinates,r,n),s=ii(t.geometry(),i,r,n);if(!Ge(i,r))return!1;for(const t of s)if(!We(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(!n)return!1;if("Polygon"===e.type){const o=Ke(e.coordinates,r,n),s=ri(t.geometry(),i,r,n);if(!Ge(i,r))return!1;for(const t of s)if(!Ye(t,o))return!1}if("MultiPolygon"===e.type){const o=ti(e.coordinates,r,n),s=ri(t.geometry(),i,r,n);if(!Ge(i,r))return!1;for(const t of s)if(!Je(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var oi=ni;function si(t){if(t instanceof Ne){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof oi)return!1;let e=!0;return t.eachChild((t=>{e&&!si(t)&&(e=!1)})),e}function ai(t){if(t instanceof Ne&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!ai(t)&&(e=!1)})),e}function li(t,e){if(t instanceof Ne&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!li(t,e)&&(i=!1)})),i}class ci{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ci(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var ui=ci;class hi{constructor(t,e=[],i,r=new Yt,n=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new Pe(e,[t]):"coerce"===i?new Oe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Se)&&"resolvedImage"!==r.type.kind&&di(r)){const e=new Be;try{r=new Se(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new hi(this.registry,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Xt(i,t))}checkSubtype(t,e){const i=he(t,e);return i&&this.error(i),i}}var pi=hi;function di(t){if(t instanceof ui)return di(t.boundExpression);if(t instanceof Ne&&"error"===t.name)return!1;if(t instanceof Ve)return!1;if(t instanceof oi)return!1;const e=t instanceof Oe||t instanceof Pe;let i=!0;return t.eachChild((t=>{i=e?i&&di(t):i&&t instanceof Se})),!!i&&si(t)&&li(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function fi(t,e){const i=t.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;o=a+1}else{if(!(r>e))throw new ke("Input is not a number.");s=a-1}return 0}class mi{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,Kt);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const o=1===i?-1/0:t[i],s=t[i+1],a=i,l=i+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new mi(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[fi(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var _i=mi;function gi(t,e,i){return t*(1-i)+e*i}var yi=Object.freeze({__proto__:null,number:gi,color:function(t,e,i){return new ge(gi(t.r,e.r,i),gi(t.g,e.g,i),gi(t.b,e.b,i),gi(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>gi(t,e[r],i)))}});const vi=.95047,xi=1.08883,bi=4/29,wi=6/29,Ti=3*wi*wi,Mi=Math.PI/180,Ei=180/Math.PI;function Ci(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ti+bi}function Si(t){return t>wi?t*t*t:Ti*(t-bi)}function ki(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ai(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ii(t){const e=Ai(t.r),i=Ai(t.g),r=Ai(t.b),n=Ci((.4124564*e+.3575761*i+.1804375*r)/vi),o=Ci((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Ci((.0193339*e+.119192*i+.9503041*r)/xi)),alpha:t.a}}function Pi(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Si(e),i=vi*Si(i),r=xi*Si(r),new ge(ki(3.2404542*i-1.5371385*e-.4985314*r),ki(-.969266*i+1.8760108*e+.041556*r),ki(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Li(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const zi={forward:Ii,reverse:Pi,interpolate:function(t,e,i){return{l:gi(t.l,e.l,i),a:gi(t.a,e.a,i),b:gi(t.b,e.b,i),alpha:gi(t.alpha,e.alpha,i)}}},Di={forward:function(t){const{l:e,a:i,b:r}=Ii(t),n=Math.atan2(r,i)*Ei;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Mi,i=t.c;return Pi({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Li(t.h,e.h,i),c:gi(t.c,e.c,i),l:gi(t.l,e.l,i),alpha:gi(t.alpha,e.alpha,i)}}};var Ri=Object.freeze({__proto__:null,lab:zi,hcl:Di});class Oi{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,n){let o=0;if("exponential"===t.name)o=Fi(e,t.base,r,n);else if("linear"===t.name)o=Fi(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;o=new i(s[0],s[1],s[2],s[3]).solve(Fi(e,1,r,n))}return o}static parse(t,e){let[i,r,n,...o]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,Kt),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=ie:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<o.length;t+=2){const i=o[t],r=o[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Oi(a,i,r,n,s):e.error(`Type ${ce(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const o=fi(e,r),s=Oi.interpolationFactor(this.interpolation,r,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?yi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Di.reverse(Di.interpolate(Di.forward(a),Di.forward(l),s)):zi.reverse(zi.interpolate(zi.forward(a),zi.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function Fi(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}var Bi=Oi;class ji{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}const o=r&&n.some((t=>he(r,t.type)));return new ji(o?ne:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(t),i&&i instanceof be&&!i.available&&(e||(e=i),i=null,r===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Ni=ji;class Vi{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=e.parse(t[r+1],r+1);if(!o)return null;i.push([n,o])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Vi(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,i]of this.bindings)t.push(e,i.serialize());return t.push(this.result.serialize()),t}}var Ui=Vi;class $i{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Kt),r=e.parse(t[2],2,le(e.expectedType||ne));return i&&r?new $i(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new ke(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new ke(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ke(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Gi=$i;class qi{constructor(t,e){this.type=ee,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);return i&&r?pe(i.type,[ee,te,Kt,Jt,ne])?new qi(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ce(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!de(e,["boolean","string","number","null"]))throw new ke(`Expected first argument to be of type boolean, string, number or null, but found ${ce(Me(e))} instead.`);if(!de(i,["string","array"]))throw new ke(`Expected second argument to be of type array or string, but found ${ce(Me(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Zi=qi;class Hi{constructor(t,e,i){this.type=Kt,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);if(!i||!r)return null;if(!pe(i.type,[ee,te,Kt,Jt,ne]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ce(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Kt);return n?new Hi(i,r,n):null}return new Hi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!de(e,["boolean","string","number","null"]))throw new ke(`Expected first argument to be of type boolean, string, number or null, but found ${ce(Me(e))} instead.`);if(!de(i,["string","array"]))throw new ke(`Expected second argument to be of type array or string, but found ${ce(Me(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Wi=Hi;class Xi{constructor(t,e,i,r,n,o){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},o=[];for(let s=2;s<t.length-1;s+=2){let a=t[s];const l=t[s+1];Array.isArray(a)||(a=[a]);const c=e.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Me(t)))return null}else i=Me(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=o.length}const u=e.parse(l,s,r);if(!u)return null;r=r||u.type,o.push(u)}const s=e.parse(t[1],1,ne);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Xi(i,r,s,n,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(Me(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const n=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?n(r[0]):r.map(n)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var Qi=Xi;class Yi{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const o=e.parse(t[n],n,ee);if(!o)return null;const s=e.parse(t[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=e.parse(t[t.length-1],t.length-1,i);return n?new Yi(i,r,n):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Ji=Yi;class Ki{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,Kt);if(!i||!r)return null;if(!pe(i.type,[le(ne),te,ne]))return e.error(`Expected first argument to be of type array or string, but found ${ce(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Kt);return n?new Ki(i.type,i,r,n):null}return new Ki(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!de(e,["string","array"]))throw new ke(`Expected first argument to be of type array or string, but found ${ce(Me(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var tr=Ki;function er(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function ir(t,e,i,r){return 0===r.compare(e,i)}function rr(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=ee,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,ne);if(!o)return null;if(!er(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${ce(o.type)}'.`);let s=e.parse(t[2],2,ne);if(!s)return null;if(!er(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${ce(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${ce(o.type)}' and '${ce(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Pe(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Pe(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,oe),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=Me(o),i=Me(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ke(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Me(o),i=Me(s);if("string"!==t.kind||"string"!==i.kind)return e(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):e(n,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const nr=rr("==",(function(t,e,i){return e===i}),ir),or=rr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!ir(0,e,i,r)})),sr=rr("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),ar=rr(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),lr=rr("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),cr=rr(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class ur{constructor(t,e,i,r,n){this.type=te,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Kt);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,te),!n))return null;let o=null;if(r.currency&&(o=e.parse(r.currency,1,te),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,Kt),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,Kt),!a)?null:new ur(i,n,o,s,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class hr{constructor(t){this.type=Kt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${ce(i.type)} instead.`):new hr(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ke(`Expected value to be of type string or array, but found ${ce(Me(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const pr={"==":nr,"!=":or,">":ar,"<":sr,">=":cr,"<=":lr,array:Pe,at:Gi,boolean:Pe,case:Ji,coalesce:Ni,collator:Ve,format:Le,image:ze,in:Zi,"index-of":Wi,interpolate:Bi,"interpolate-hcl":Bi,"interpolate-lab":Bi,length:hr,let:Ui,literal:Se,match:Qi,number:Pe,"number-format":ur,object:Pe,slice:tr,step:_i,string:Pe,"to-boolean":Oe,"to-color":Oe,"to-number":Oe,"to-string":Oe,var:ui,within:oi};function dr(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const o=n?n.evaluate(t):1,s=we(e,i,r,o);if(s)throw new ke(s);return new ge(e/255*o,i/255*o,r/255*o,o)}function fr(t,e){return t in e}function mr(t,e){const i=e[t];return void 0===i?null:i}function _r(t){return{type:t}}Ne.register(pr,{error:[{kind:"error"},[te],(t,[e])=>{throw new ke(e.evaluate(t))}],typeof:[te,[ne],(t,[e])=>ce(Me(e.evaluate(t)))],"to-rgba":[le(Kt,4),[ie],(t,[e])=>e.evaluate(t).toArray()],rgb:[ie,[Kt,Kt,Kt],dr],rgba:[ie,[Kt,Kt,Kt,Kt],dr],has:{type:ee,overloads:[[[te],(t,[e])=>fr(e.evaluate(t),t.properties())],[[te,re],(t,[e,i])=>fr(e.evaluate(t),i.evaluate(t))]]},get:{type:ne,overloads:[[[te],(t,[e])=>mr(e.evaluate(t),t.properties())],[[te,re],(t,[e,i])=>mr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[ne,[te],(t,[e])=>mr(e.evaluate(t),t.featureState||{})],properties:[re,[],t=>t.properties()],"geometry-type":[te,[],t=>t.geometryType()],id:[ne,[],t=>t.id()],zoom:[Kt,[],t=>t.globals.zoom],pitch:[Kt,[],t=>t.globals.pitch||0],"distance-from-center":[Kt,[],t=>t.distanceFromCenter()],"heatmap-density":[Kt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Kt,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Kt,[],t=>t.globals.skyRadialProgress||0],accumulated:[ne,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Kt,_r(Kt),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Kt,_r(Kt),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Kt,overloads:[[[Kt,Kt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Kt],(t,[e])=>-e.evaluate(t)]]},"/":[Kt,[Kt,Kt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Kt,[Kt,Kt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Kt,[],()=>Math.LN2],pi:[Kt,[],()=>Math.PI],e:[Kt,[],()=>Math.E],"^":[Kt,[Kt,Kt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Kt,[Kt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Kt,[Kt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Kt,[Kt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Kt,[Kt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Kt,[Kt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Kt,[Kt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Kt,[Kt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Kt,[Kt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Kt,[Kt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Kt,[Kt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Kt,_r(Kt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Kt,_r(Kt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Kt,[Kt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Kt,[Kt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Kt,[Kt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Kt,[Kt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ee,[te,ne],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ee,[ne],(t,[e])=>t.id()===e.value],"filter-type-==":[ee,[te],(t,[e])=>t.geometryType()===e.value],"filter-<":[ee,[te,ne],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[ee,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[ee,[te,ne],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[ee,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ee,[te,ne],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[ee,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ee,[te,ne],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[ee,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ee,[ne],(t,[e])=>e.value in t.properties()],"filter-has-id":[ee,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ee,[le(te)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ee,[le(ne)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ee,[te,le(ne)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ee,[te,le(ne)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ee,overloads:[[[ee,ee],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[_r(ee),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ee,overloads:[[[ee,ee],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[_r(ee),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ee,[ee],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ee,[te],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[te,[te],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[te,[te],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[te,_r(ne),(t,e)=>e.map((e=>Ee(e.evaluate(t)))).join("")],"resolved-locale":[te,[oe],(t,[e])=>e.evaluate(t).resolvedLocale()]});var gr=pr;function yr(t){return{result:"success",value:t}}function vr(t){return{result:"error",value:t}}function xr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function br(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function wr(t){return!!t.expression&&t.expression.interpolated}function Tr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Mr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Er(t){return t}function Cr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),o=t.type||(wr(e)?"exponential":"interval");if(i&&((t=qt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],ge.parse(t[1])]))),t.default=ge.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Ri[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Ir;else if("interval"===o)s=Ar;else if("categorical"===o){s=kr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Pr}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Cr(i[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Bi.interpolationFactor.bind(void 0,o),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Ir({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Bi.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Sr(t.default,e.default):s(t,e,n,a,l)}}}function Sr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function kr(t,e,i,r,n){return Sr(typeof i===n?r[i]:void 0,t.default,e.default)}function Ar(t,e,i){if("number"!==Tr(i))return Sr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=fi(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function Ir(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Tr(i))return Sr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const o=fi(t.stops.map((t=>t[0])),i),s=function(t,e,i,r){const n=r-i,o=t-i;return 0===n?0:1===e?o/n:(Math.pow(e,o)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=yi[e.type]||Er;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Ri[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function Pr(t,e,i){return"color"===e.type?i=ge.parse(i):"formatted"===e.type?i=xe.fromString(i.toString()):"resolvedImage"===e.type?i=be.fromString(i.toString()):Tr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Sr(i,t.default,e.default)}class Lr{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Be,this._defaultValue=e?function(t){return"color"===t.type&&(Mr(t.default)||Array.isArray(t.default))?new ge(0,0,0,0):"color"===t.type?ge.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,o,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,o,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ke(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function zr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in gr}function Dr(t,e){const i=new pi(gr,[],e?function(t){const e={color:ie,string:te,number:Kt,enum:te,boolean:ee,formatted:se,resolvedImage:ae};return"array"===t.type?le(e[t.value]||ne,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?yr(new Lr(r,e)):vr(i.errors)}class Rr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!ai(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}}class Or{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!ai(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,o)}evaluate(t,e,i,r,n,o){return this._styleExpression.evaluate(t,e,i,r,n,o)}interpolationFactor(t,e,i){return this.interpolationType?Bi.interpolationFactor(this.interpolationType,t,e,i):0}}function Fr(t,e){if("error"===(t=Dr(t,e)).result)return t;const i=t.value.expression,r=si(i);if(!r&&!xr(e))return vr([new Xt("","data expressions not supported")]);const n=li(i,["zoom","pitch","distance-from-center"]);if(!n&&!br(e))return vr([new Xt("","zoom expressions not supported")]);const o=jr(i);return o||n?o instanceof Xt?vr([o]):o instanceof Bi&&!wr(e)?vr([new Xt("",'"interpolate" expressions cannot be used with this property')]):yr(o?new Or(r?"camera":"composite",t.value,o.labels,o instanceof Bi?o.interpolation:void 0):new Rr(r?"constant":"source",t.value)):vr([new Xt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Br{constructor(t,e){this._parameters=t,this._specification=e,qt(this,Cr(this._parameters,this._specification))}static deserialize(t){return new Br(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function jr(t){let e=null;if(t instanceof Ui)e=jr(t.result);else if(t instanceof Ni){for(const i of t.args)if(e=jr(i),e)break}else(t instanceof _i||t instanceof Bi)&&t.input instanceof Ne&&"zoom"===t.input.name&&(e=t);return e instanceof Xt||t.eachChild((t=>{const i=jr(t);i instanceof Xt?e=i:!e&&i?e=new Xt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Xt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class Nr{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Vr(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,s=t.styleSpec;let a=[];const l=Tr(i);if("object"!==l)return[new Nr(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let u;n[l]?u=n[l]:r[l]?u=bn:n["*"]?u=n["*"]:r["*"]&&(u=bn),u?a=a.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:o,styleSpec:s,object:i,objectKey:t},i)):a.push(new Nr(e,i[t],`unknown property "${t}"`))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new Nr(e,i,`missing required property "${t}"`));return a}function Ur(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,o=t.key,s=t.arrayElementValidator||bn;if("array"!==Tr(e))return[new Nr(o,e,`array expected, ${Tr(e)} found`)];if(i.length&&e.length!==i.length)return[new Nr(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new Nr(o,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(a.function=i.function),"object"===Tr(i.value)&&(a=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(s({array:e,arrayIndex:t,value:e[t],valueSpec:a,style:r,styleSpec:n,key:`${o}[${t}]`}));return l}function $r(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Tr(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new Nr(e,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===Tr(r.minimum)&&(n=r.minimum[t.arrayIndex]),i<n)return[new Nr(e,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===Tr(r.maximum)&&(n=r.maximum[t.arrayIndex]),i>n)return[new Nr(e,i,`${i} is greater than the maximum value ${n}`)]}return[]}function Gr(t){const e=t.valueSpec,i=Zt(t.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Tr(t.value.stops)&&"array"===Tr(t.value.stops[0])&&"object"===Tr(t.value.stops[0][0]),u=Vr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new Nr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ur({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Tr(r)&&0===r.length&&e.push(new Nr(t.key,r,"array must have at least one stop")),e},default:function(t){return bn({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&u.push(new Nr(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||u.push(new Nr(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!wr(t.valueSpec)&&u.push(new Nr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!xr(t.valueSpec)?u.push(new Nr(t.key,t.value,"property functions not supported")):a&&!br(t.valueSpec)&&u.push(new Nr(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||u.push(new Nr(t.key,t.value,'"property" property is required')),u;function h(t){let i=[];const r=t.value,a=t.key;if("array"!==Tr(r))return[new Nr(a,r,`array expected, ${Tr(r)} found`)];if(2!==r.length)return[new Nr(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Tr(r[0]))return[new Nr(a,r,`object expected, ${Tr(r[0])} found`)];if(void 0===r[0].zoom)return[new Nr(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Nr(a,r,"object stop key must have value")];const e=Zt(r[0].zoom);if("number"!=typeof e)return[new Nr(a,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>e)return[new Nr(a,r[0].zoom,"stop zoom values must appear in ascending order")];e!==o&&(o=e,n=void 0,s={}),i=i.concat(Vr({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:$r,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return zr(Ht(r[1]))?i.concat([new Nr(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(bn({key:`${a}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,o){const a=Tr(t.value),l=Zt(t.value),c=null!==t.value?t.value:o;if(r){if(a!==r)return[new Nr(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new Nr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return xr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Nr(t.key,c,r)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&l<n?[new Nr(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new Nr(t.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Nr(t.key,c,`integer expected, found ${String(l)}`)]}}function qr(t){const e=("property"===t.expressionContext?Fr:Dr)(Ht(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new Nr(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new Nr(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!ai(i))return[new Nr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Zr(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!li(i,["zoom","feature-state"]))return[new Nr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!si(i))return[new Nr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Zr(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const r=[];return t instanceof Ne&&i.has(t.name)?[new Nr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{r.push(...Zr(t,e))})),r)}function Hr(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Zt(i))&&n.push(new Nr(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Zt(i))&&n.push(new Nr(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Wr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Wr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Xr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Wr(t)||(t=rn(t));const i=t;let r=!0;try{r=function(t){if(!Jr(t))return t;let e=Ht(t);return Yr(e),e=Qr(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const n=Gt[`filter_${e}`],o=Dr(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(r!==i){const t=Dr(i,n);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,r,n,o)=>t.value.evaluate(e,i,{},r,void 0,void 0,n,o),l=!si(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:en(r),needFeature:!!l}}function Qr(t){if(!Array.isArray(t))return t;const e=function(t){if(Kr.has(t[0]))for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return t}(t);return!0===e?e:e.map((t=>Qr(t)))}function Yr(t){let e=!1;const i=[];if("case"===t[0]){for(let r=1;r<t.length-1;r+=2)e=e||Jr(t[r]),i.push(t[r+1]);i.push(t[t.length-1])}else if("match"===t[0]){e=e||Jr(t[1]);for(let e=2;e<t.length-1;e+=2)i.push(t[e+1]);i.push(t[t.length-1])}else if("step"===t[0]){e=e||Jr(t[1]);for(let e=1;e<t.length-1;e+=2)i.push(t[e+1])}e&&(t.length=0,t.push("any",...i));for(let e=1;e<t.length;e++)Yr(t[e])}function Jr(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return!1}const Kr=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function tn(t,e){return t<e?-1:t>e?1:0}function en(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(en(t[e]))return!0;return!1}function rn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?nn(t[1],t[2],"=="):"!="===e?an(nn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?nn(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(rn))):"all"===e?["all"].concat(t.slice(1).map(rn)):"none"===e?["all"].concat(t.slice(1).map(rn).map(an)):"in"===e?on(t[1],t.slice(2)):"!in"===e?an(on(t[1],t.slice(2))):"has"===e?sn(t[1]):"!has"===e?an(sn(t[1])):"within"!==e||t;var i}function nn(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function on(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(tn)]]:["filter-in-small",t,["literal",e]]}}function sn(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function an(t){return["!",t]}function ln(t){return Wr(Ht(t.value))?qr(qt({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):cn(t)}function cn(t){const e=t.value,i=t.key;if("array"!==Tr(e))return[new Nr(i,e,`array expected, ${Tr(e)} found`)];const r=t.styleSpec;let n,o=[];if(e.length<1)return[new Nr(i,e,"filter array must have at least 1 element")];switch(o=o.concat(Hr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Zt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Zt(e[1])&&o.push(new Nr(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new Nr(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Tr(e[1]),"string"!==n&&o.push(new Nr(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let s=2;s<e.length;s++)n=Tr(e[s]),"$type"===Zt(e[1])?o=o.concat(Hr({key:`${i}[${s}]`,value:e[s],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new Nr(`${i}[${s}]`,e[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)o=o.concat(cn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Tr(e[1]),2!==e.length?o.push(new Nr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new Nr(`${i}[1]`,e[1],`string expected, ${n} found`));break;case"within":n=Tr(e[1]),2!==e.length?o.push(new Nr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new Nr(`${i}[1]`,e[1],`object expected, ${n} found`))}return o}function un(t,e){const i=t.key,r=t.style,n=t.styleSpec,o=t.value,s=t.objectKey,a=n[`${e}_${t.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===e&&l&&a[l[1]]&&a[l[1]].transition)return bn({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=t.valueSpec||a[s];if(!c)return[new Nr(i,o,`unknown property "${s}"`)];let u;if("string"===Tr(o)&&xr(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new Nr(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const h=[];return"symbol"===t.layerType&&("text-field"===s&&r&&!r.glyphs&&h.push(new Nr(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&Mr(Ht(o))&&"identity"===Zt(o.type)&&h.push(new Nr(i,o,'"text-font" does not support identity functions'))),h.concat(bn({key:t.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:s}))}function hn(t){return un(t,"paint")}function pn(t){return un(t,"layout")}function dn(t){let e=[];const i=t.value,r=t.key,n=t.style,o=t.styleSpec;i.type||i.ref||e.push(new Nr(r,i,'either "type" or "ref" is required'));let s=Zt(i.type);const a=Zt(i.ref);if(i.id){const o=Zt(i.id);for(let s=0;s<t.arrayIndex;s++){const t=n.layers[s];Zt(t.id)===o&&e.push(new Nr(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new Nr(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{Zt(e.id)===a&&(t=e)})),t?t.ref?e.push(new Nr(r,i.ref,"ref cannot reference another ref layer")):s=Zt(t.type):"string"==typeof a&&e.push(new Nr(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const t=n.sources&&n.sources[i.source],o=t&&Zt(t.type);t?"vector"===o&&"raster"===s?e.push(new Nr(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?e.push(new Nr(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new Nr(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&t.lineMetrics||e.push(new Nr(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Nr(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Nr(r,i.source,`source "${i.source}" not found`))}else e.push(new Nr(r,i,'missing required property "source"'));return e=e.concat(Vr({key:r,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bn({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>ln(qt({layerType:s},t)),layout:t=>Vr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>pn(qt({layerType:s},t))}}),paint:t=>Vr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>hn(qt({layerType:s},t))}})}})),e}function fn(t){const e=t.value,i=t.key,r=Tr(e);return"string"!==r?[new Nr(i,e,`string expected, ${r} found`)]:[]}const mn={promoteId:function({key:t,value:e}){if("string"===Tr(e))return fn({key:t,value:e});{const i=[];for(const r in e)i.push(...fn({key:`${t}.${r}`,value:e[r]}));return i}}};function _n(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style;if(!e.type)return[new Nr(i,e,'"type" is required')];const o=Zt(e.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Vr({key:i,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:mn}),s;case"geojson":if(s=Vr({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:mn}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;s.push(...qr({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),s.push(...qr({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return Vr({key:i,value:e,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Vr({key:i,value:e,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new Nr(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Hr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function gn(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let o=[];const s=Tr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Nr("light",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?bn({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new Nr(t,e[t],`unknown property "${t}"`)])}return o}function yn(t){const e=t.value,i=t.key,r=t.style,n=t.styleSpec,o=n.terrain;let s=[];const a=Tr(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Nr("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const i=t.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?bn({key:t,value:e[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?bn({key:t,value:e[t],valueSpec:o[t],style:r,styleSpec:n}):[new Nr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],n=t&&Zt(t.type);t?"raster-dem"!==n&&s.push(new Nr(i,e.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):s.push(new Nr(i,e.source,`source "${e.source}" not found`))}else s.push(new Nr(i,e,'terrain is missing required property "source"'));return s}function vn(t){const e=t.value,i=t.style,r=t.styleSpec,n=r.fog;let o=[];const s=Tr(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new Nr("fog",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?bn({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):n[t]?bn({key:t,value:e[t],valueSpec:n[t],style:i,styleSpec:r}):[new Nr(t,e[t],`unknown property "${t}"`)])}return o}const xn={"*":()=>[],array:Ur,boolean:function(t){const e=t.value,i=t.key,r=Tr(e);return"boolean"!==r?[new Nr(i,e,`boolean expected, ${r} found`)]:[]},number:$r,color:function(t){const e=t.key,i=t.value,r=Tr(i);return"string"!==r?[new Nr(e,i,`color expected, ${r} found`)]:null===me.parseCSSColor(i)?[new Nr(e,i,`color expected, "${i}" found`)]:[]},enum:Hr,filter:ln,function:Gr,layer:dn,object:Vr,source:_n,light:gn,terrain:yn,fog:vn,string:fn,formatted:function(t){return 0===fn(t).length?[]:qr(t)},resolvedImage:function(t){return 0===fn(t).length?[]:qr(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style;let o=[];const s=Tr(e);if("object"===s)for(const t in e)o=o.concat(bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}));else"string"!==s&&(o=o.concat([new Nr("projection",e,`object or string expected, ${s} found`)]));return o}};function bn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Mr(Zt(e))?Gr(t):i.expression&&zr(Ht(e))?qr(t):i.type&&xn[i.type]?xn[i.type](t):Vr(qt({},t,{valueSpec:i.type?r[i.type]:i}))}function wn(t){const e=t.value,i=t.key,r=fn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Nr(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Nr(i,e,'"glyphs" url must include a "{range}" token'))),r}function Tn(t,e=Gt){return Cn(bn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const Mn=t=>Cn(hn(t)),En=t=>Cn(pn(t));function Cn(t){return t.slice().sort(((t,e)=>t.line&&e.line?t.line-e.line:0))}function Sn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new Ut(new Error(r.message))),i=!0;return i}var kn=An;function An(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var s=n[3+o],a=n[3+o+1];r.push(s===a?null:n.subarray(s,a))}var l=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var u=i/e*t;this.min=-u,this.max=t+u}An.prototype.insert=function(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},An.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},An.prototype._insertCell=function(t,e,i,r,n,o){this.cells[n].push(o)},An.prototype.query=function(t,e,i,r,n){var o=this.min,s=this.max;if(t<=o&&e<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,i,r,this._queryCell,a,{},n),a},An.prototype._queryCell=function(t,e,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===s[p]){var d=4*p;(a?a(u[d+0],u[d+1],u[d+2],u[d+3]):t<=u[d+2]&&e<=u[d+3]&&i>=u[d+0]&&r>=u[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},An.prototype._forEachCell=function(t,e,i,r,n,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,t,e,i,r,f,o,s,a))return}},An.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},An.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},An.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(e+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=e,s=0;s<t.length;s++){var a=t[s];n[3+s]=o,n.set(a,o),o+=a.length}return n[3+t.length]=o,n.set(this.keys,o),n[3+t.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const In={};function Pn(t,e,i={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),In[e]={klass:t,omit:i.omit||[]}}Pn(Object,"Object"),kn.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},kn.deserialize=function(t){return new kn(t.buffer)},Object.defineProperty(kn,"name",{value:"Grid"}),Pn(kn,"Grid"),Pn(ge,"Color"),Pn(Error,"Error"),Pn(kt,"AJAXError"),Pn(be,"ResolvedImage"),Pn(Br,"StylePropertyFunction"),Pn(Lr,"StyleExpression",{omit:["_evaluator"]}),Pn(Or,"ZoomDependentExpression"),Pn(Rr,"ZoomConstantExpression"),Pn(Ne,"CompoundExpression",{omit:["_evaluate"]});for(const t in gr)In[gr[t]._classRegistryKey]||Pn(gr[t],`Expression${t}`);function Ln(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function zn(t){return e.ImageBitmap&&t instanceof e.ImageBitmap}function Dn(t,i){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Ln(t)||zn(t))return i&&i.push(t),t;if(ArrayBuffer.isView(t)){const e=t;return i&&i.push(e.buffer),e}if(t instanceof e.ImageData)return i&&i.push(t.data.buffer),t;if(Array.isArray(t)){const e=[];for(const r of t)e.push(Dn(r,i));return e}if("object"==typeof t){const e=t.constructor,r=e._classRegistryKey;if(!r)throw new Error(`can't serialize object of unregistered class ${r}`);const n=e.serialize?e.serialize(t,i):{};if(!e.serialize){for(const e in t)t.hasOwnProperty(e)&&(In[r].omit.indexOf(e)>=0||(n[e]=Dn(t[e],i)));t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof t)}function Rn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Ln(t)||zn(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Rn);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=In[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(r[e]=Rn(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class On{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const Fn=t=>t>=1536&&t<=1791,Bn=t=>t>=1872&&t<=1919,jn=t=>t>=2208&&t<=2303,Nn=t=>t>=11904&&t<=12031,Vn=t=>t>=12032&&t<=12255,Un=t=>t>=12272&&t<=12287,$n=t=>t>=12288&&t<=12351,Gn=t=>t>=12352&&t<=12447,qn=t=>t>=12448&&t<=12543,Zn=t=>t>=12544&&t<=12591,Hn=t=>t>=12704&&t<=12735,Wn=t=>t>=12736&&t<=12783,Xn=t=>t>=12784&&t<=12799,Qn=t=>t>=12800&&t<=13055,Yn=t=>t>=13056&&t<=13311,Jn=t=>t>=13312&&t<=19903,Kn=t=>t>=19968&&t<=40959,to=t=>t>=40960&&t<=42127,eo=t=>t>=42128&&t<=42191,io=t=>t>=44032&&t<=55215,ro=t=>t>=63744&&t<=64255,no=t=>t>=64336&&t<=65023,oo=t=>t>=65040&&t<=65055,so=t=>t>=65072&&t<=65103,ao=t=>t>=65104&&t<=65135,lo=t=>t>=65136&&t<=65279,co=t=>t>=65280&&t<=65519;function uo(t){for(const e of t)if(fo(e.charCodeAt(0)))return!0;return!1}function ho(t){for(const e of t)if(!po(e.charCodeAt(0)))return!1;return!0}function po(t){return!(Fn(t)||Bn(t)||jn(t)||no(t)||lo(t))}function fo(t){return!(746!==t&&747!==t&&(t<4352||!(Hn(t)||Zn(t)||so(t)&&!(t>=65097&&t<=65103)||ro(t)||Yn(t)||Nn(t)||Wn(t)||!(!$n(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Jn(t)||Kn(t)||Qn(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||io(t)||Gn(t)||Un(t)||(t=>t>=12688&&t<=12703)(t)||Vn(t)||Xn(t)||qn(t)&&12540!==t||!(!co(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!ao(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||oo(t)||(t=>t>=19904&&t<=19967)(t)||to(t)||eo(t))))}function mo(t){return!(fo(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||$n(t)||qn(t)||(t=>t>=57344&&t<=63743)(t)||so(t)||ao(t)||co(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function _o(t){return t>=1424&&t<=2303||no(t)||lo(t)}function go(t,e){return!(!e&&_o(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function yo(t){for(const e of t)if(_o(e.charCodeAt(0)))return!0;return!1}const vo="deferred",xo="loading",bo="loaded";let wo=null,To="unavailable",Mo=null;const Eo=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(To="error"),wo&&wo(t)};function Co(){So.fire(new Vt("pluginStateChange",{pluginStatus:To,pluginURL:Mo}))}const So=new $t,ko=function(){return To},Ao=function(){if(To!==vo||!Mo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=xo,Co(),Mo&&Pt({url:Mo},(t=>{t?Eo(t):(To=bo,Co())}))},Io={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>To===bo||null!=Io.applyArabicShaping,isLoading:()=>To===xo,setState(t){To=t.pluginStatus,Mo=t.pluginURL},isParsed:()=>null!=Io.applyArabicShaping&&null!=Io.processBidirectionalText&&null!=Io.processStyledBidirectionalText,getPluginURL:()=>Mo};class Po{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new On,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!go(i.charCodeAt(0),e))return!1;return!0}(t,Io.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class Lo{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Mr(t))return new Br(t,e);if(zr(t)){const i=Fr(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=ge.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class zo{constructor(t){this.property=t,this.value=new Lo(t,void 0)}transitioned(t,e){return new Ro(this.property,this.value,e,v({},t.transition,this.transition),t.now)}untransitioned(){return new Ro(this.property,this.value,null,{},0)}}class Do{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return A(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new zo(this._values[t].property)),this._values[t].value=new Lo(this._values[t].property,null===e?void 0:A(e))}getTransition(t){return A(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new zo(this._values[t].property)),this._values[t].transition=A(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new Oo(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new Oo(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ro{constructor(t,e,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=t,this.value=e,this.begin=n+o,this.end=this.begin+s,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(t,e,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,i),n,h(s))}}return n}}class Oo{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new jo(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Fo{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return A(this._values[t].value)}setValue(t,e){this._values[t]=new Lo(this._values[t].property,null===e?void 0:A(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new jo(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}}class Bo{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class jo{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class No{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=yi[this.specification.type];return r?r(t,e,i):t}}class Vo{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new Bo(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Bo(this,{kind:"constant",value:void 0},t.parameters);const r=yi[this.specification.type];return r?new Bo(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,n,o){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,o)}}class Uo extends Vo{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new Bo(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),o="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,e);return new Bo(this,{kind:"constant",value:s},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Bo(this,{kind:"constant",value:i},e)}return new Bo(this,t.expression,e)}evaluate(t,e,i,r,n,o){if("source"===t.kind){const s=t.evaluate(e,i,r,n,o);return this._calculate(s,s,s,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class $o{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new Po(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Po(Math.floor(e.zoom),e)),t.expression.evaluate(new Po(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Go{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class qo{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new Po(0,{});for(const i in t){const r=t[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new Lo(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new zo(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(e)}}}function Zo(t,e){return 256*(t=f(Math.floor(t),0,255))+f(Math.floor(e),0,255)}Pn(Vo,"DataDrivenProperty"),Pn(No,"DataConstantProperty"),Pn(Uo,"CrossFadedDataDrivenProperty"),Pn($o,"CrossFadedProperty"),Pn(Go,"ColorRampProperty");const Ho={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Wo{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Qo(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=Ho[t.type].BYTES_PER_ELEMENT,o=i=Yo(i,Math.max(e,n)),s=t.components||1;return r=Math.max(r,n),i+=n*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Yo(i,Math.max(r,e)),alignment:e}}function Yo(t,e){return Math.ceil(t/e)*e}class Jo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Jo.prototype.bytesPerElement=4,Pn(Jo,"StructArrayLayout2i4");class Ko extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}Ko.prototype.bytesPerElement=6,Pn(Ko,"StructArrayLayout3i6");class ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,t}}ts.prototype.bytesPerElement=8,Pn(ts,"StructArrayLayout4i8");class es extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o,s)}emplace(t,e,i,r,n,o,s,a){const l=6*t,c=12*t,u=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,t}}es.prototype.bytesPerElement=12,Pn(es,"StructArrayLayout2i4ub1f12");class is extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,t}}is.prototype.bytesPerElement=16,Pn(is,"StructArrayLayout4f16");class rs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,i,r,n,o,s,a,l,c)}emplace(t,e,i,r,n,o,s,a,l,c,u){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=n,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,t}}rs.prototype.bytesPerElement=20,Pn(rs,"StructArrayLayout10ui20");class ns extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,o,s,a)}emplace(t,e,i,r,n,o,s,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}ns.prototype.bytesPerElement=16,Pn(ns,"StructArrayLayout8ui16");class os extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,t}}os.prototype.bytesPerElement=12,Pn(os,"StructArrayLayout6i12");class ss extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,n,o,s,a,l,c,u,h)}emplace(t,e,i,r,n,o,s,a,l,c,u,h,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,t}}ss.prototype.bytesPerElement=24,Pn(ss,"StructArrayLayout4i4ui4i24");class as extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n,o)}emplace(t,e,i,r,n,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,t}}as.prototype.bytesPerElement=20,Pn(as,"StructArrayLayout3i3f20");class ls extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ls.prototype.bytesPerElement=4,Pn(ls,"StructArrayLayout1ul4");class cs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,n,o,s,a,l,c,u,h,p)}emplace(t,e,i,r,n,o,s,a,l,c,u,h,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}cs.prototype.bytesPerElement=40,Pn(cs,"StructArrayLayout5i4f1i1ul2ui40");class us extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o,s)}emplace(t,e,i,r,n,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}us.prototype.bytesPerElement=16,Pn(us,"StructArrayLayout3i2i2i16");class hs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n)}emplace(t,e,i,r,n,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,t}}hs.prototype.bytesPerElement=16,Pn(hs,"StructArrayLayout2f1f2i16");class ps extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,t}}ps.prototype.bytesPerElement=12,Pn(ps,"StructArrayLayout2ub2f12");class ds extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}ds.prototype.bytesPerElement=12,Pn(ds,"StructArrayLayout3f12");class fs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}fs.prototype.bytesPerElement=6,Pn(fs,"StructArrayLayout3ui6");class ms extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x)}emplace(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,M=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[M+48]=_,this.uint8[M+49]=g,this.uint8[M+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[M+58]=b,t}}ms.prototype.bytesPerElement=60,Pn(ms,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class _s extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,M,E,C,S,k,A){const I=this.length;return this.resize(I+1),this.emplace(I,t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,M,E,C,S,k,A)}emplace(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,M,E,C,S,k,A,I){const P=38*t,L=19*t;return this.int16[P+0]=e,this.int16[P+1]=i,this.int16[P+2]=r,this.float32[L+2]=n,this.float32[L+3]=o,this.int16[P+8]=s,this.int16[P+9]=a,this.int16[P+10]=l,this.int16[P+11]=c,this.int16[P+12]=u,this.int16[P+13]=h,this.uint16[P+14]=p,this.uint16[P+15]=d,this.uint16[P+16]=f,this.uint16[P+17]=m,this.uint16[P+18]=_,this.uint16[P+19]=g,this.uint16[P+20]=y,this.uint16[P+21]=v,this.uint16[P+22]=x,this.uint16[P+23]=b,this.uint16[P+24]=w,this.uint16[P+25]=T,this.uint16[P+26]=M,this.uint16[P+27]=E,this.uint16[P+28]=C,this.uint32[L+15]=S,this.float32[L+16]=k,this.float32[L+17]=A,this.float32[L+18]=I,t}}_s.prototype.bytesPerElement=76,Pn(_s,"StructArrayLayout3i2f6i15ui1ul3f76");class gs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}gs.prototype.bytesPerElement=4,Pn(gs,"StructArrayLayout1f4");class ys extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,o,s)}emplace(t,e,i,r,n,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}ys.prototype.bytesPerElement=28,Pn(ys,"StructArrayLayout7f28");class vs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n)}emplace(t,e,i,r,n,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,t}}vs.prototype.bytesPerElement=20,Pn(vs,"StructArrayLayout5f20");class xs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,t}}xs.prototype.bytesPerElement=12,Pn(xs,"StructArrayLayout1ul3ui12");class bs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}bs.prototype.bytesPerElement=4,Pn(bs,"StructArrayLayout2ui4");class ws extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ws.prototype.bytesPerElement=2,Pn(ws,"StructArrayLayout1ui2");class Ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Ts.prototype.bytesPerElement=8,Pn(Ts,"StructArrayLayout2f8");class Ms extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Ms.prototype.size=12;class Es extends os{get(t){return new Ms(this,t)}}Pn(Es,"FillExtrusionExtArray");class Cs extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Cs.prototype.size=40;class Ss extends cs{get(t){return new Cs(this,t)}}Pn(Ss,"CollisionBoxArray");class ks extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}ks.prototype.size=60;class As extends ms{get(t){return new ks(this,t)}}Pn(As,"PlacedSymbolArray");class Is extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Is.prototype.size=76;class Ps extends _s{get(t){return new Is(this,t)}}Pn(Ps,"SymbolInstanceArray");class Ls extends gs{getoffsetX(t){return this.float32[1*t+0]}}Pn(Ls,"GlyphOffsetArray");class zs extends Ko{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Pn(zs,"SymbolLineVertexArray");class Ds extends Wo{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Ds.prototype.size=12;class Rs extends xs{get(t){return new Ds(this,t)}}Pn(Rs,"FeatureIndexArray");class Os extends Wo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Os.prototype.size=4;class Fs extends bs{get(t){return new Os(this,t)}}Pn(Fs,"FillExtrusionCentroidArray");class Bs extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Bs.prototype.size=12;class js extends os{get(t){return new Bs(this,t)}}Pn(js,"CircleGlobeExtArray");const Ns=Qo([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Vs=Qo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Us=fe((function(t){t.exports=function(t,e){var i,r,n,o,s,a,l,c;for(r=t.length-(i=3&t.length),n=e,s=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}})),$s=fe((function(t){t.exports=function(t,e){for(var i,r=t.length,n=e^r,o=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&t.charCodeAt(o+2))<<16;case 2:n^=(255&t.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),Gs=Us,qs=$s;Gs.murmur3=Us,Gs.murmur2=qs;class Zs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Hs(t)),this.positions.push(e,i,r)}getPositions(t){const e=Hs(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Ws(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Zs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Hs(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Gs(String(t))}function Ws(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(t[o]<n);do{s--}while(t[s]>n);if(o>=s)break;Xs(t,o,s),Xs(e,3*o,3*s),Xs(e,3*o+1,3*s+1),Xs(e,3*o+2,3*s+2)}s-i<r-s?(Ws(t,e,i,s),i=s+1):(Ws(t,e,s+1,r),r=s)}}function Xs(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Pn(Zs,"FeaturePositionMap");class Qs{constructor(t,e){this.gl=t.gl,this.location=e}}class Ys extends Qs{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Js extends Qs{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Ks extends Qs{constructor(t,e){super(t,e),this.current=ge.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const ta=new Float32Array(16),ea=new Float32Array(9),ia=new Float32Array(4);function ra(t){return[Zo(255*t.r,255*t.g),Zo(255*t.b,255*t.a)]}class na{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Ks(t,e):new Ys(t,e)}}class oa{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Js(t,e):new Ys(t,e)}}class sa{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Po(0),e,{},n,r,o);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,i,r,n){const o=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(t,e,o)}_setPaintValue(t,e,i){if("color"===this.type){const r=ra(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class aa{constructor(t,e,i,r,n,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,r,n,o){const s=this.expression.evaluate(new Po(this.zoom),e,{},n,r,o),a=this.expression.evaluate(new Po(this.zoom+1),e,{},n,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,s,a)}updatePaintArray(t,e,i,r,n){const o=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),s=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(t,e,o,s)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=ra(i),o=ra(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=f(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Ys(t,e)}}class la{constructor(t,e,i,r,n,o,s){this.expression=t,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=s,this.paintVertexAttributes=("array"===i?Vs:Ns).members;for(let t=0;t<e.length;++t);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n,o){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:o,max:s}=i,a=r[n],l=r[o],c=r[s];if(a&&l&&c)for(let i=t;i<e;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(t,e,i,r){t.emplace(e,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ca{constructor(t,e,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const o=t.paint.get(n);if(!(o instanceof Bo&&xr(o.property.specification)))continue;const s=pa(n,t.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(n)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const i=ma(n,l,"source");this.binders[n]=h?new la(a,s,l,c,e,i,t.id):new sa(a,s,l,i),r.push(`/a_${n}`)}else{const t=ma(n,l,"composite");this.binders[n]=new aa(a,s,l,c,e,t),r.push(`/z_${n}`)}else this.binders[n]=h?new oa(a.value,s):new na(a.value,s,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof sa||e instanceof aa?e.maxValue:0}populatePaintArrays(t,e,i,r,n,o){for(const s in this.binders){const a=this.binders[s];(a instanceof sa||a instanceof aa||a instanceof la)&&a.populatePaintArray(t,e,i,r,n,o)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof oa&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n,o){let s=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof sa||c instanceof aa||c instanceof la)&&!0===c.expression.isStateDependent){const u=r.paint.get(i);c.expression=u.value,c.updatePaintArray(e.start,e.end,l,t[a],n,o),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof na||i instanceof oa)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof sa||i instanceof aa||i instanceof la)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof na||i instanceof oa||i instanceof aa)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof na||n instanceof oa||n instanceof aa)for(const o of n.uniformNames)if(e[o]){const s=n.getBinding(t,e[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:o}of e)this.binders[n].setUniform(o,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof la){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof sa||i instanceof aa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof sa||i instanceof aa||i instanceof la)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof sa||e instanceof aa||e instanceof la)&&e.destroy()}}}class ua{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new ca(r,e,i);this.needsUpload=!1,this._featureMap=new Zs,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,o,s);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r,n){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(t,this._featureMap,e,o,r,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const ha={"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"],"line-dasharray":["dash_to","dash_from"]};function pa(t,e){return ha[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const da={"line-pattern":{source:rs,composite:rs},"fill-pattern":{source:rs,composite:rs},"fill-extrusion-pattern":{source:rs,composite:rs},"line-dasharray":{source:ns,composite:ns}},fa={color:{source:Ts,composite:is},number:{source:gs,composite:Ts}};function ma(t,e,i){const r=da[t];return r&&r[i]||fa[e][i]}Pn(na,"ConstantBinder"),Pn(oa,"CrossFadedConstantBinder"),Pn(sa,"SourceExpressionBinder"),Pn(la,"CrossFadedCompositeBinder"),Pn(aa,"CompositeExpressionBinder"),Pn(ca,"ProgramConfiguration",{omit:["_buffers"]}),Pn(ua,"ProgramConfigurationSet");const _a="-transition";class ga extends $t{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Fo(e.layout)),e.paint)){this._transitionablePaint=new Do(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new jo(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(En,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return C(t,_a)?this._transitionablePaint.getTransition(t.slice(0,-_a.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Mn,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(C(t,_a))return this._transitionablePaint.setTransition(t.slice(0,-_a.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,o,s)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),k(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Sn(this,t.call(Tn,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:Gt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Bo&&xr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Xr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ya=Qo([{name:"a_pos",components:2,type:"Int16"}],4),va=Qo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xa{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let n=this.segments[this.segments.length-1];return t>xa.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${xa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!n||n.vertexLength+t>xa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new xa([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}xa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Pn(xa,"SegmentVector");var ba=8192;class wa{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Ma?new Ma(t.lng,t.lat):Ma.convert(t),this}setSouthWest(t){return this._sw=t instanceof Ma?new Ma(t.lng,t.lat):Ma.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof Ma)r=t,n=t;else{if(!(t instanceof wa))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(wa.convert(t)):this.extend(Ma.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Ma(r.lng,r.lat),this._ne=new Ma(n.lng,n.lat)),this}getCenter(){return new Ma((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 Ma(this.getWest(),this.getNorth())}getSouthEast(){return new Ma(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Ma.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof wa?t:new wa(t)}}const Ta=6371008.8;class Ma{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ma(_(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Ta*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new wa(new Ma(this.lng-i,this.lat-e),new Ma(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Ma)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Ma(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Ma(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Ea=2*Math.PI*Ta;function Ca(t){return Ea*Math.cos(t*Math.PI/180)}function Sa(t){return(180+t)/360}function ka(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Aa(t,e){return t/Ca(e)}function Ia(t){return 360*t-180}function Pa(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function La(t,e){return t*Ca(Pa(e))}const za=85.051129;class Da{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Ma.convert(t);return new Da(Sa(i.lng),ka(i.lat),Aa(e,i.lat))}toLngLat(){return new Ma(Ia(this.x),Pa(this.y))}toAltitude(){return La(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ea*(t=Pa(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ra(t,e,i,r,o,s,a,l,c){const u=(e+r)/2,h=(i+o)/2,p=new n(u,h);l(p),function(t,e,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-e)*s-(i-t)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Ra(t,e,i,u,h,s,p,l,c),Ra(t,u,h,r,o,p,a,l,c)):t.push(a)}function Oa(t,e,i){let r=t[0],n=r.x,o=r.y;e(r);const s=[r];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:u}=l;e(l),Ra(s,n,o,c,u,r,l,e,i),n=c,o=u,r=l}return s}function Fa(t,e,i,r,n){if(n(e,i)){const o=e.add(i).mult(.5);r(o),Fa(t,e,o,r,n),Fa(t,o,i,r,n)}else t.push(i)}function Ba(t,e,i){let r=t[0];e(r);const n=[r];for(let o=1;o<t.length;o++){const s=t[o];e(s),Fa(n,r,s,e,i),r=s}return n}const ja=Math.pow(2,14)-1,Na=-ja-1;function Va(t,e){const i=Math.round(t.x*e),r=Math.round(t.y*e);return t.x=f(i,Na,ja),t.y=f(r,Na,ja),(i<t.x||i>t.x+1||r<t.y||r>t.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Ua(t,e,i){const r=t.loadGeometry(),n=t.extent,o=ba/n;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1<<e.z,{scale:s,x:a,y:l,projection:c}=i,u=t=>{const i=Ia((e.x+t.x/n)/o),r=Pa((e.y+t.y/n)/o),u=c.project(i,r);t.x=(u.x*s-a)*n,t.y=(u.y*s-l)*n};for(let e=0;e<r.length;e++)if(1!==t.type)r[e]=Oa(r[e],u,1);else{const t=[];for(const i of r[e])i.x<0||i.x>=n||i.y<0||i.y>=n||(u(i),t.push(i));r[e]=t}}for(const t of r)for(const e of t)Va(e,o);return r}function $a(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ua(t):[]}}function Ga(t,e,i,r,n){t.emplaceBack(2*e+(r+1)/2,2*i+(n+1)/2)}function qa(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class Za{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Jo,this.indexArray=new fs,this.segments=new xa,this.programConfigurations=new ua(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:e,id:n,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=$a(e,t);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ua(e,i,r),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new js,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=t[o].feature;this.addFeature(r,n,o,e.availableImages,i,a),e.featureIndex.insert(l,n,o,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ya.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,va.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,r,n,o){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=ba||r<0||r>=ba)continue;if(o){const t=o.projectTilePoint(i,r,n),e=o.upVector(n,i,r),s=this.globeExtVertexArray;qa(s,t,e),qa(s,t,e),qa(s,t,e),qa(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;Ga(this.layoutVertexArray,i,r,-1,-1),Ga(this.layoutVertexArray,i,r,1,-1),Ga(this.layoutVertexArray,i,r,1,1),Ga(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r,n)}}function Ha(t,e){for(let i=0;i<t.length;i++)if(il(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(il(t,e[i]))return!0;return!!Ya(t,e)}function Wa(t,e,i){return!!il(t,e)||!!Ka(e,t,i)}function Xa(t,e){if(1===t.length)return el(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(il(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(el(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ya(t,e[i]))return!0;return!1}function Qa(t,e,i){if(t.length>1){if(Ya(t,e))return!0;for(let r=0;r<e.length;r++)if(Ka(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Ka(t[r],e,i))return!0;return!1}function Ya(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(Ja(r,n,e[t],e[t+1]))return!0}return!1}function Ja(t,e,i,r){return L(t,i,r)!==L(e,i,r)&&L(t,e,i)!==L(t,e,r)}function Ka(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(tl(t,e[i-1],e[i])<r)return!0;return!1}function tl(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function el(t,e){let i,r,n,o=!1;for(let s=0;s<t.length;s++){i=t[s];for(let t=0,s=i.length-1;t<i.length;s=t++)r=i[t],n=i[s],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function il(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const o=t[r],s=t[n];o.y>e.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function rl(t,e,i,r,o){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&o>=n.y)return!0;const s=[new n(e,i),new n(e,o),new n(r,o),new n(r,i)];if(t.length>2)for(const e of s)if(il(t,e))return!0;for(let e=0;e<t.length-1;e++)if(nl(t[e],t[e+1],s))return!0;return!1}function nl(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const o=L(t,e,i[0]);return o!==L(t,e,i[1])||o!==L(t,e,i[2])||o!==L(t,e,i[3])}function ol(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function sl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function al(t,e,i,r,o){if(!e[0]&&!e[1])return t;const s=n.convert(e)._mult(o);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(s));return a}function ll(t,e,i,r){const o=n.convert(t)._mult(r);return"viewport"===e&&o._rotate(-i),o}Pn(Za,"CircleBucket",{omit:["layers"]});const cl=new qo({"circle-sort-key":new Vo(Gt.layout_circle["circle-sort-key"])});var ul={paint:new qo({"circle-radius":new Vo(Gt.paint_circle["circle-radius"]),"circle-color":new Vo(Gt.paint_circle["circle-color"]),"circle-blur":new Vo(Gt.paint_circle["circle-blur"]),"circle-opacity":new Vo(Gt.paint_circle["circle-opacity"]),"circle-translate":new No(Gt.paint_circle["circle-translate"]),"circle-translate-anchor":new No(Gt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new No(Gt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new No(Gt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Vo(Gt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Vo(Gt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Vo(Gt.paint_circle["circle-stroke-opacity"])}),layout:cl},hl=1e-6,pl="undefined"!=typeof Float32Array?Float32Array:Array;function dl(){var t=new pl(9);return pl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function fl(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ml(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=i[0],x=i[1],b=i[2],w=i[3];return t[0]=v*r+x*a+b*h+w*m,t[1]=v*n+x*l+b*p+w*_,t[2]=v*o+x*c+b*d+w*g,t[3]=v*s+x*u+b*f+w*y,t[4]=(v=i[4])*r+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,t[5]=v*n+x*l+b*p+w*_,t[6]=v*o+x*c+b*d+w*g,t[7]=v*s+x*u+b*f+w*y,t[8]=(v=i[8])*r+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,t[9]=v*n+x*l+b*p+w*_,t[10]=v*o+x*c+b*d+w*g,t[11]=v*s+x*u+b*f+w*y,t[12]=(v=i[12])*r+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,t[13]=v*n+x*l+b*p+w*_,t[14]=v*o+x*c+b*d+w*g,t[15]=v*s+x*u+b*f+w*y,t}function _l(t,e,i){var r,n,o,s,a,l,c,u,h,p,d,f,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=p,t[10]=d,t[11]=f,t[12]=r*m+a*_+h*g+e[12],t[13]=n*m+l*_+p*g+e[13],t[14]=o*m+c*_+d*g+e[14],t[15]=s*m+u*_+f*g+e[15]),t}function gl(t,e,i){var r=i[0],n=i[1],o=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function yl(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+c*r,t[5]=s*n+u*r,t[6]=a*n+h*r,t[7]=l*n+p*r,t[8]=c*n-o*r,t[9]=u*n-s*r,t[10]=h*n-a*r,t[11]=p*n-l*r,t}function vl(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n-c*r,t[1]=s*n-u*r,t[2]=a*n-h*r,t[3]=l*n-p*r,t[8]=o*r+c*n,t[9]=s*r+u*n,t[10]=a*r+h*n,t[11]=l*r+p*n,t}function xl(t,e,i){var r,n,o,s=i[0],a=i[1],l=i[2],c=Math.hypot(s,a,l);return c<hl?null:(s*=c=1/c,a*=c,l*=c,r=Math.sin(e),n=Math.cos(e),t[0]=s*s*(o=1-n)+n,t[1]=a*s*o+l*r,t[2]=l*s*o-a*r,t[3]=0,t[4]=s*a*o-l*r,t[5]=a*a*o+n,t[6]=l*a*o+s*r,t[7]=0,t[8]=s*l*o+a*r,t[9]=a*l*o-s*r,t[10]=l*l*o+n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var bl=ml;function wl(){var t=new pl(3);return pl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Tl(t){var e=new pl(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ml(t){return Math.hypot(t[0],t[1],t[2])}function El(t,e,i){var r=new pl(3);return r[0]=t,r[1]=e,r[2]=i,r}function Cl(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function Sl(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function kl(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function Al(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function Il(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function Pl(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Ll(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function zl(t,e){var i=e[0],r=e[1],n=e[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function Dl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rl(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=n*l-o*a,t[1]=o*s-r*l,t[2]=r*a-n*s,t}function Ol(t,e,i){var r=e[0],n=e[1],o=e[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,t[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,t}function Fl(t,e,i){var r=i[0],n=i[1],o=i[2],s=e[0],a=e[1],l=e[2],c=n*l-o*a,u=o*s-r*l,h=r*a-n*s,p=n*h-o*u,d=o*c-r*h,f=r*u-n*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,t[0]=s+(c*=m)+(p*=2),t[1]=a+u+d,t[2]=l+h+f,t}var Bl,jl=Sl,Nl=kl,Vl=Ml;function Ul(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function $l(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,t[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,t[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,t[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,t}function Gl(){var t=new pl(4);return pl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ql(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Zl(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+s*a,t[1]=n*l+o*a,t[2]=o*l-n*a,t[3]=s*l-r*a,t}function Hl(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l-o*a,t[1]=n*l+s*a,t[2]=o*l+r*a,t[3]=s*l-n*a,t}wl(),Bl=new pl(4),pl!=Float32Array&&(Bl[0]=0,Bl[1]=0,Bl[2]=0,Bl[3]=0),wl(),El(1,0,0),El(0,1,0),Gl(),Gl(),dl();class Wl{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const r=Dl(e,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(t,e,i){if(function(t,e){var i=t[0],r=t[1],n=t[2],o=e[0],s=e[1],a=e[2];return Math.abs(i-o)<=hl*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=hl*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=hl*Math.max(1,Math.abs(n),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,s=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=r*r+n*n+o*o,u=2*(s*r+a*n+l*o),h=u*u-4*c*(s*s+a*a+l*l-e*e);if(h<0){const t=Math.max(-u/2,0),c=s+r*t,h=a+n*t,p=l+o*t,d=Math.hypot(c,h,p);return i[0]=c*e/d,i[1]=h*e/d,i[2]=p*e/d,!1}{const t=(-u-Math.sqrt(h))/(2*c);if(t<0){const t=Math.hypot(s,a,l);return i[0]=s*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=s+r*t,i[1]=a+n*t,i[2]=l+o*t,!0}}}class Xl{constructor(t,e,i,r,n){this.TL=t,this.TR=e,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(t,e,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Ol(r,r,t),l=Ol(n,n,t),c=Ol(o,o,t),u=Ol(s,s,t);return new Xl(a,l,c,u,e/i)}}class Ql{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,r){const n=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=$l([],i,t),s=1/o[3]/e*n;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(o,o,[s,s,r?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=zl([],Rl([],jl([],o[t[0]],o[t[1]]),jl([],o[t[2]],o[t[1]]))),i=-Dl(e,o[t[1]]);return e.concat(i)}));return new Ql(o,s)}}class Yl{constructor(t,e){this.min=t,this.max=e,this.center=Pl([],Cl([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],i=Tl(this.min),r=Tl(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],r[t]=e[t]?this.center[t]:this.max[t];return r[2]=this.max[2],new Yl(i,r)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return[[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){const e=this.getCorners();let i=!0;for(let r=0;r<t.planes.length;r++){const n=t.planes[r];let o=0;for(let t=0;t<e.length;t++)o+=Dl(n,e[t])+n[3]>=0;if(0===o)return 0;o!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<t.points.length;n++){const o=t.points[n][e]-this.min[e];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[e]-this.min[e])return 0}return 1}}function Jl(t,e,i,r,n,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(a),p=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const t=i.projection.upVector(c,h.x,h.y);d.x+=t[0]*u*p,d.y+=t[1]*u*p,d.z+=t[2]*u*p}const f=o?h:Kl(d.x,d.y,d.z,r),m=o?t.tilespaceRays.map((t=>ic(t,p))):t.queryGeometry.screenGeometry,_=$l([],[d.x,d.y,d.z,1],r);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const t=Pa((e.y/ba+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(t,1)/Aa(1,t)}if(Wa(m,f,l))return!0}return!1}function Kl(t,e,i,r){const o=$l([],[t,e,i,1],r);return new n(o[0]/o[3],o[1]/o[3])}const tc=El(0,0,0),ec=El(0,0,1);function ic(t,e){const i=wl();return tc[2]=e,t.intersectsPlane(tc,ec,i),new n(i[0],i[1])}class rc extends Za{}function nc(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function oc(t,e,i){const{width:r,height:n}=e;r===t.width&&n===t.height||(sc(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,r),height:Math.min(t.height,n)},i),t.width=r,t.height=n,t.data=e.data)}function sc(t,e,i,r,n,o){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*o,u=((r.y+l)*e.width+r.x)*o;for(let t=0;t<n.width*o;t++)a[u+t]=s[c+t]}return e}Pn(rc,"HeatmapBucket",{omit:["layers"]});class ac{constructor(t,e){nc(this,t,1,e)}resize(t){oc(this,new ac(t),1)}clone(){return new ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){sc(t,e,i,r,n,1)}}class lc{constructor(t,e){nc(this,t,4,e)}resize(t){oc(this,new lc(t),4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new lc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){sc(t,e,i,r,n,4)}}Pn(ac,"AlphaImage"),Pn(lc,"RGBAImage");var cc={paint:new qo({"heatmap-radius":new Vo(Gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Vo(Gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new No(Gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Go(Gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new No(Gt.paint_heatmap["heatmap-opacity"])})};function uc(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new lc({width:i,height:r}),o=(i,r,o)=>{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];o(n,s,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)o(0,e,t/(i-1));return n}var hc={paint:new qo({"hillshade-illumination-direction":new No(Gt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new No(Gt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new No(Gt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new No(Gt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new No(Gt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new No(Gt.paint_hillshade["hillshade-accent-color"])})};const pc=Qo([{name:"a_pos",components:2,type:"Int16"}],4),{members:dc}=pc;var fc=_c,mc=_c;function _c(t,e,i){i=i||2;var r,n,o,s,a,l,c,u=e&&e.length,h=u?e[0]*i:t.length,p=gc(t,0,h,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(t,e,i,r){var n,o,s,a=[];for(n=0,o=e.length;n<o;n++)(s=gc(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1))===s.next&&(s.steiner=!0),a.push(kc(s));for(a.sort(Mc),n=0;n<a.length;n++)i=yc(i=Ec(a[n],i),i.next);return i}(t,e,p,i)),t.length>80*i){r=o=t[0],n=s=t[1];for(var f=i;f<h;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?1/c:0}return vc(p,d,i,r,n,c),d}function gc(t,e,i,r,n){var o,s;if(n===Vc(t,e,i,r)>0)for(o=e;o<i;o+=r)s=Bc(o,t[o],t[o+1],s);else for(o=i-r;o>=e;o-=r)s=Bc(o,t[o],t[o+1],s);return s&&Lc(s,s.next)&&(jc(s),s=s.next),s}function yc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Lc(r,r.next)&&0!==Pc(r.prev,r,r.next))r=r.next;else{if(jc(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function vc(t,e,i,r,n,o,s){if(t){!s&&o&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=Sc(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,o,s,a,l,c=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,r=i,a=0,e=0;e<c&&(a++,r=r.nextZ);e++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1)}(n)}(t,r,n,o);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,o?bc(t,r,n,o):xc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),jc(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?vc(t=wc(yc(t),e,i),e,i,r,n,o,2):2===s&&Tc(t,e,i,r,n,o):vc(yc(t),e,i,r,n,o,1);break}}}function xc(t){var e=t.prev,i=t,r=t.next;if(Pc(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(Ac(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Pc(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function bc(t,e,i,r){var n=t.prev,o=t,s=t.next;if(Pc(n,o,s)>=0)return!1;for(var a=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,l=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,c=Sc(n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,e,i,r),u=Sc(a,l,e,i,r),h=t.prevZ,p=t.nextZ;h&&h.z>=c&&p&&p.z<=u;){if(h!==t.prev&&h!==t.next&&Ac(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==t.prev&&p!==t.next&&Ac(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==t.prev&&h!==t.next&&Ac(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==t.prev&&p!==t.next&&Ac(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function wc(t,e,i){var r=t;do{var n=r.prev,o=r.next.next;!Lc(n,o)&&zc(n,r,r.next,o)&&Oc(n,o)&&Oc(o,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(o.i/i),jc(r),jc(r.next),r=t=o),r=r.next}while(r!==t);return yc(r)}function Tc(t,e,i,r,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Ic(s,a)){var l=Fc(s,a);return s=yc(s,s.next),l=yc(l,l.next),vc(s,e,i,r,n,o),void vc(l,e,i,r,n,o)}a=a.next}s=s.next}while(s!==t)}function Mc(t,e){return t.x-e.x}function Ec(t,e){var i=function(t,e){var i,r=e,n=t.x,o=t.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===s)return i;var l,c=i,u=i.x,h=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=u&&n!==r.x&&Ac(o<h?n:s,o,u,h,o<h?s:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),Oc(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&Cc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Fc(i,t),n=yc(i,i.next);return yc(r,r.next),e===i?n:e}function Cc(t,e){return Pc(t.prev,t,e.prev)<0&&Pc(e.next,t,t.next)<0}function Sc(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function kc(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Ac(t,e,i,r,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(r-a)-(i-s)*(e-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function Ic(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&zc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Oc(t,e)&&Oc(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Pc(t.prev,t,e.prev)||Pc(t,e.prev,e))||Lc(t,e)&&Pc(t.prev,t,t.next)>0&&Pc(e.prev,e,e.next)>0)}function Pc(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Lc(t,e){return t.x===e.x&&t.y===e.y}function zc(t,e,i,r){var n=Rc(Pc(t,e,i)),o=Rc(Pc(t,e,r)),s=Rc(Pc(i,r,t)),a=Rc(Pc(i,r,e));return n!==o&&s!==a||!(0!==n||!Dc(t,i,e))||!(0!==o||!Dc(t,r,e))||!(0!==s||!Dc(i,t,r))||!(0!==a||!Dc(i,e,r))}function Dc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Rc(t){return t>0?1:t<0?-1:0}function Oc(t,e){return Pc(t.prev,t,t.next)<0?Pc(t,e,t.next)>=0&&Pc(t,t.prev,e)>=0:Pc(t,e,t.prev)<0||Pc(t,t.next,e)<0}function Fc(t,e){var i=new Nc(t.i,t.x,t.y),r=new Nc(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Bc(t,e,i,r){var n=new Nc(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function jc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Nc(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vc(t,e,i,r){for(var n=0,o=e,s=i-r;o<i;o+=r)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}function Uc(t,e,i,r,n){$c(t,e,i||0,r||t.length-1,n||qc)}function $c(t,e,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);$c(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(r,Math.floor(e+(o-s)*l/o+c)),n)}var u=t[e],h=i,p=r;for(Gc(t,i,e),n(t[r],u)>0&&Gc(t,i,r);h<p;){for(Gc(t,h,p),h++,p--;n(t[h],u)<0;)h++;for(;n(t[p],u)>0;)p--}0===n(t[i],u)?Gc(t,i,p):Gc(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function Gc(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function qc(t,e){return t<e?-1:t>e?1:0}function Zc(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,o;for(let e=0;e<i;e++){const i=z(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[e]]):n.push(t[e]))}if(n&&r.push(n),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Uc(r[t],e,1,r[t].length-1,Hc),r[t]=r[t].slice(0,e));return r}function Hc(t,e){return e.area-t.area}function Wc(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const o=e.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function Xc(t,e,i,r,n){const o=n.patternDependencies;for(const s of e){const e=s.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),a=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[s.id]={min:t,mid:a,max:l}}}return i}_c.deviation=function(t,e,i,r){var n=e&&e.length,o=Math.abs(Vc(t,0,n?e[0]*i:t.length,i));if(n)for(var s=0,a=e.length;s<a;s++)o-=Math.abs(Vc(t,e[s]*i,s<a-1?e[s+1]*i:t.length,i));var l=0;for(s=0;s<r.length;s+=3){var c=r[s]*i,u=r[s+1]*i,h=r[s+2]*i;l+=Math.abs((t[c]-t[h])*(t[u+1]-t[c+1])-(t[c]-t[u])*(t[h+1]-t[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},_c.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,n=0;n<t.length;n++){for(var o=0;o<t[n].length;o++)for(var s=0;s<e;s++)i.vertices.push(t[n][o][s]);n>0&&i.holes.push(r+=t[n-1].length)}return i},fc.default=mc;class Qc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Jo,this.indexArray=new fs,this.indexArray2=new bs,this.programConfigurations=new ua(t.layers,t.zoom),this.segments=new xa,this.segments2=new xa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,r){this.hasPattern=Wc("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=$a(s,t);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),u,i))continue;const h=n?n.evaluate(u,{},i,e.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:Ua(s,i,r),patterns:{},sortKey:h};o.push(p)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const t=Xc("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,{},e.availableImages);e.featureIndex.insert(t[o].feature,n,o,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,dc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,n,o=[]){for(const t of Zc(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),n.push(e[0].x),n.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),n.push(e[t].x),n.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const s=fc(n,o);for(let t=0;t<s.length;t+=3)this.indexArray.emplaceBack(r+s[t],r+s[t+1],r+s[t+2]);i.vertexLength+=e,i.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,o,r)}}Pn(Qc,"FillBucket",{omit:["layers","patternFeatures"]});const Yc=new qo({"fill-sort-key":new Vo(Gt.layout_fill["fill-sort-key"])});var Jc={paint:new qo({"fill-antialias":new No(Gt.paint_fill["fill-antialias"]),"fill-opacity":new Vo(Gt.paint_fill["fill-opacity"]),"fill-color":new Vo(Gt.paint_fill["fill-color"]),"fill-outline-color":new Vo(Gt.paint_fill["fill-outline-color"]),"fill-translate":new No(Gt.paint_fill["fill-translate"]),"fill-translate-anchor":new No(Gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Uo(Gt.paint_fill["fill-pattern"])}),layout:Yc};const Kc=Qo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),tu=Qo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),eu=Qo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:iu}=Kc;var ru=nu;function nu(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(ou,this,e)}function ou(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function su(t){for(var e,i,r=0,n=0,o=t.length,s=o-1;n<o;s=n++)r+=((i=t[s]).x-(e=t[n]).x)*(e.y+i.y);return r}nu.types=["Unknown","Point","LineString","Polygon"],nu.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,o=0,s=0,a=0,l=[];t.pos<i;){if(o<=0){var c=t.readVarint();r=7&c,o=c>>3}if(o--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new n(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},nu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var u=t.readVarint();i=7&u,r=u>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=t.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},nu.prototype.toGeoJSON=function(t,e,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=nu.types[this.type];function u(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(r=0;r<l.length;r++)h[r]=l[r][0];u(l=h);break;case 2:for(r=0;r<l.length;r++)u(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,n=[],o=0;o<e;o++){var s=su(t[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(i&&n.push(i),i=[t[o]]):i.push(t[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)u(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var au=lu;function lu(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(cu,this,e),this.length=this._features.length}function cu(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function uu(t,e,i){if(3===t){var r=new au(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}lu.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ru(this._pbf,e,this.extent,this._keys,this._values)};var hu={VectorTile:function(t,e){this.layers=t.readFields(uu,{},e)},VectorTileFeature:ru,VectorTileLayer:au};function pu(t,e,i,r){const o=[],s=0===r?(t,e,i,r,o,s)=>{t.push(new n(s,i+(s-e)/(r-e)*(o-i)))}:(t,e,i,r,o,s)=>{t.push(new n(e+(s-i)/(o-i)*(r-e),s))};for(const n of t){const t=[];for(const o of n){if(o.length<=2)continue;const n=[];for(let t=0;t<o.length-1;t++){const a=o[t].x,l=o[t].y,c=o[t+1].x,u=o[t+1].y,h=0===r?a:l,p=0===r?c:u;h<e?p>e&&s(n,a,l,c,u,e):h>i?p<i&&s(n,a,l,c,u,i):n.push(o[t]),p<e&&h>=e&&s(n,a,l,c,u,e),p>i&&h<=i&&s(n,a,l,c,u,i)}let a=o[o.length-1];const l=0===r?a.x:a.y;l>=e&&l<=i&&n.push(a),n.length&&(a=n[n.length-1],n[0].x===a.x&&n[0].y===a.y||n.push(n[0]),t.push(n))}t.length&&o.push(t)}return o}const du=hu.VectorTileFeature.types,fu=Math.pow(2,13);function mu(t,e,i,r,n,o,s,a){t.emplaceBack((e<<1)+s,(i<<1)+o,(Math.floor(r*fu)<<1)+n,Math.round(a))}function _u(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class gu{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(t.x,t.y),this.max=new n(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,r=this.max;t.x<i.x?i.x=t.x:t.x>r.x&&(r.x=t.x),t.y<i.y?i.y=t.y:t.y>r.y&&(r.y=t.y),((0===t.x||t.x===ba)&&t.x===e.x)!=((0===t.y||t.y===ba)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,gi(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>ba!=t.x>ba&&this.addBorderIntersection(1,gi(e.y,t.y,(ba-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,gi(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>ba!=t.y>ba&&this.addBorderIntersection(3,gi(e.x,t.x,(ba-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];e<i[0]&&(i[0]=e),e>i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class yu{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ts,this.centroidVertexArray=new Fs,this.indexArray=new fs,this.programConfigurations=new ua(t.layers,t.zoom),this.segments=new xa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,r){this.features=[],this.hasPattern=Wc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<<t.z)*2));return 80150034*e/(e*e+1)/ba/(1<<t.z)}(i);for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=$a(n,t);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Ua(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(Xc("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,r),e.featureIndex.insert(n,c.geometry,s,a,this.index,u)}this.sortBorders()}addFeatures(t,e,i,r,n){for(const t of this.features){const{geometry:o}=t;this.addFeature(t,o,t.index,e,i,r,n)}this.sortBorders()}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,iu),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,eu.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,tu.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r,o,s,a){const l=[new n(0,0),new n(ba,ba)],c=a.projection,u="globe"===c.name,h=this.enableTerrain&&!u?new gu:null;u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Es);const p=Zc(e,500);for(let t=p.length-1;t>=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=ba))||d.every((t=>t.y<=0))||d.every((t=>t.y>=ba)))&&p.splice(t,1)}var d;let f;if(u)f=bu(p,l,r);else{f=[];for(const t of p)f.push({polygon:t,bounds:l})}for(const e of f){const i=e.polygon;let n=0,o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let t=0;t<i.length;t++){const s=i[t];if(0===s.length)continue;n+=s.length;let a=0;h&&h.startRing(s[0]);for(let t=0;t<s.length;t++){const i=s[t];if(t>=1){const n=s[t-1];if(!vu(i,n,e.bounds)){h&&h.append(i,n),o.vertexLength+4>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(n)._perp(),e=t.x/(Math.abs(t.x)+Math.abs(t.y)),s=t.y>0?1:0,l=n.dist(i);a+l>32768&&(a=0),mu(this.layoutVertexArray,i.x,i.y,e,s,0,0,a),mu(this.layoutVertexArray,i.x,i.y,e,s,0,1,a),a+=l,mu(this.layoutVertexArray,n.x,n.y,e,s,0,0,a),mu(this.layoutVertexArray,n.x,n.y,e,s,0,1,a);const p=o.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),o.vertexLength+=4,o.primitiveLength+=2,u){const t=this.layoutVertexExtArray,e=c.projectTilePoint(i.x,i.y,r),o=c.projectTilePoint(n.x,n.y,r),s=c.upVector(r,i.x,i.y),a=c.upVector(r,n.x,n.y);_u(t,e,s),_u(t,e,s),_u(t,o,a),_u(t,o,a)}}}}}if(o.vertexLength+n>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==du[t.type])continue;const s=[],a=[],l=o.vertexLength;for(let t=0;t<i.length;t++){const e=i[t];if(0!==e.length){e!==i[0]&&a.push(s.length/2);for(let t=0;t<e.length;t++){const i=e[t];mu(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),s.push(i.x),s.push(i.y),h&&h.currentPolyCount.top++,u&&_u(this.layoutVertexExtArray,c.projectTilePoint(i.x,i.y,r),c.upVector(r,i.x,i.y))}}}const p=fc(s,a);for(let t=0;t<p.length;t+=3)this.indexArray.emplaceBack(l+p[t],l+p[t+2],l+p[t+1]);o.primitiveLength+=p.length/3,o.vertexLength+=n}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const t=h.borders,e=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,o,s,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,n;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(o++,r,n)}}}function vu(t,e,i){return t.x===e.x&&(t.x<i[0].x||t.x>i[1].x)||t.y===e.y&&(t.y<i[0].y||t.y>i[1].y)}function xu(){const t=Math.PI/32,e=Math.tan(t),i=Ta;return i*Math.sqrt(1+2*e*e)-i}function bu(t,e,i){const r=1<<i.z,o=Ia(i.x/r),s=Ia((i.x+1)/r),a=Pa(i.y/r),l=Pa((i.y+1)/r);return function(t,e,i,r,o=0,s){const a=[];if(!t.length||!i||!r)return a;const l=(t,e)=>{for(const i of t)a.push({polygon:i,bounds:e})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(r)),h=c-u,p=[];for(let t=0;t<Math.abs(h);t++)p.push(h>0?0:1);for(let t=0;t<Math.min(c,u);t++)p.push(0),p.push(1);let d=t;if(d=pu(d,e[0].y-o,e[1].y+o,1),d=pu(d,e[0].x-o,e[1].x+o,0),!d.length)return a;const f=[];for(p.length?f.push({polygons:d,bounds:e,depth:0}):l(d,e);f.length;){const t=f.pop(),e=t.depth,i=p[e],r=t.bounds[0],a=t.bounds[1],c=0===i?r.x:r.y,u=0===i?a.x:a.y,h=s?s(i,c,u):.5*(c+u),d=pu(t.polygons,c-o,h+o,i),m=pu(t.polygons,h-o,u+o,i);if(d.length){const t=[r,new n(0===i?h:a.x,1===i?h:a.y)];p.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):l(d,t)}if(m.length){const t=[new n(0===i?h:r.x,1===i?h:r.y),a];p.length>e+1?f.push({polygons:m,bounds:t,depth:e+1}):l(m,t)}}return a}(t,e,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((t,e,n)=>{if(0===t)return.5*(e+n);{const t=Pa((i.y+e/ba)/r);return(ka(.5*(Pa((i.y+n/ba)/r)+t))*r-i.y)*ba}}))}Pn(yu,"FillExtrusionBucket",{omit:["layers","features"]}),Pn(gu,"PartMetadata");var wu={paint:new qo({"fill-extrusion-opacity":new No(Gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Vo(Gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new No(Gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new No(Gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Uo(Gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Vo(Gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Vo(Gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new No(Gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Tu(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Mu{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=Su(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var r=Tu(256*t,256*(e=Math.pow(2,i)-e-1),i),n=Tu(256*(t+1),256*(e+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(t,e,i){let r,n="";for(let o=t;o>0;o--)r=1<<o-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Eu{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Su(t,e.z,e.z,e.x,e.y)}}class Cu{constructor(t,e,i,r,n){this.overscaledZ=t,this.wrap=e,this.canonical=new Mu(i,+r,+n),this.key=0===e&&t===i?this.canonical.key:Su(e,t,i,r,n)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new Cu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Cu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Su(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Su(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Cu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Cu(e,this.wrap,e,i,r),new Cu(e,this.wrap,e,i+1,r),new Cu(e,this.wrap,e,i,r+1),new Cu(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Cu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Cu(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Eu(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Su(t,e,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return t&&i<22&&(s+=o*o*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*s+i)+(e-i)}function ku(t,e){return t.x*e.x+t.y*e.y}function Au(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const o=e[i],s=t[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),u=ku(a,a),h=ku(a,l),p=ku(l,l),d=ku(c,a),f=ku(c,l),m=u*p-h*h,_=(p*d-h*f)/m,g=(u*f-h*d)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}function Iu(t){const e=new n(t[0],t[1]);return e.z=t[2],e}function Pu(t,e,i,r,n,o,s,a){const l=s*n.getElevationAt(t,e,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/7-450):s*function(t,e,i){const r=Math.floor(e[0]/8),n=Math.floor(e[1]/8),o=10*(e[0]-8*r),s=10*(e[1]-8*n),a=t.getElevationAt(r,n,!0,!0),l=t.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=t.tileCoordToPixel(r,n),p=2*c+1,d=2*u+1,f=function(t,e,i,r,n){return[t.getElevationAtPixel(e,i,!0),t.getElevationAtPixel(e+n,i,!0),t.getElevationAtPixel(e,i+n,!0),t.getElevationAtPixel(e+r,i+n,!0)]}(t,h.x-c,h.y-u,p,d),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/p),v=Math.min(.25,.5*l*g/d);return a+Math.max(y*o,v*s)}(n,o,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(u+r,l+i+2):l+r}}Pn(Mu,"CanonicalTileID"),Pn(Cu,"OverscaledTileID",{omit:["projMatrix"]});const Lu=Qo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:zu}=Lu,Du=Qo([{name:"a_packed",components:4,type:"Float32"}]),{members:Ru}=Du,Ou=hu.VectorTileFeature.types,Fu=Math.cos(Math.PI/180*37.5);class Bu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new es,this.layoutVertexArray2=new is,this.indexArray=new fs,this.programConfigurations=new ua(t.layers,t.zoom),this.segments=new xa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){this.hasPattern=Wc("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=$a(e,t);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,i))continue;const u=n?n.evaluate(c,{},i):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ua(e,i,r),patterns:{},sortKey:u};o.push(h)}n&&o.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:a}=e,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const t=Xc("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,o,i,s.positions,e.availableImages);a.insert(t[o].feature,n,o,c,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)e=!0;else{const e=n.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a,l,c,u,h;if("constant"===n.kind){const t=n.value;if(!t)continue;s=t.other||t.to,a=t.to,l=t.from}else s=n.evaluate({zoom:i-1},t),a=n.evaluate({zoom:i},t),l=n.evaluate({zoom:i+1},t);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:i-1},t),u=o.evaluate({zoom:i},t),h=o.evaluate({zoom:i+1},t)),e.addDash(s,c),e.addDash(a,u),e.addDash(l,h);const p=e.getKey(s,c),d=e.getKey(a,u),f=e.getKey(l,h);t.patterns[r.id]={min:p,mid:d,max:f}}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ru)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,zu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap").evaluate(t,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,o,r)}addLine(t,e,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===Ou[e.type];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l<a-1&&t[l].equals(t[l+1]);)l++;if(a<(s?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,u=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let h,p,d,f,m;this.e1=this.e2=-1,s&&(h=t[a-2],m=t[l].sub(h)._unit()._perp());for(let e=l;e<a;e++){if(d=e===a-1?s?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;m&&(f=m),h&&(p=h),h=t[e],m=d?d.sub(h)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<Fu&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&e>l){const t=h.dist(p);if(t>2*c){const e=h.sub(h.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,u),p=e}}const T=p&&d;let M=T?i:s?"butt":r;if(T&&"round"===M&&(v<o?M="miter":v<=2&&(M="fakeround")),"miter"===M&&v>n&&(M="bevel"),"bevel"===M&&(v>2&&(M="flipbevel"),v<n&&(M="miter")),p&&this.updateDistance(p,h),"miter"===M)_._mult(v),this.addCurrentVertex(h,_,0,0,u);else if("flipbevel"===M){if(v>100)_=m.mult(-1);else{const t=v*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===M||"fakeround"===M){const t=-Math.sqrt(v*v-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(h,f,e,i,u),"fakeround"===M){const t=Math.round(180*x/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(h,r.x,r.y,!1,w,0,u)}}d&&this.addCurrentVertex(h,m,-e,-i,u)}else if("butt"===M)this.addCurrentVertex(h,_,0,0,u);else if("square"===M){const t=p?1:-1;p||this.addCurrentVertex(h,_,t,t,u),this.addCurrentVertex(h,_,0,0,u),p&&this.addCurrentVertex(h,_,t,t,u)}else"round"===M&&(p&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),d&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&e<a-1){const t=h.dist(d);if(t>2*c){const e=h.add(d.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,i,r,n,o=!1){const s=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,o,!1,i,n),this.addHalfVertex(t,s,a,o,!0,-r,n)}addHalfVertex({x:t,y:e},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Pn(Bu,"LineBucket",{omit:["layers","patternFeatures"]});const ju=new qo({"line-cap":new Vo(Gt.layout_line["line-cap"]),"line-join":new Vo(Gt.layout_line["line-join"]),"line-miter-limit":new No(Gt.layout_line["line-miter-limit"]),"line-round-limit":new No(Gt.layout_line["line-round-limit"]),"line-sort-key":new Vo(Gt.layout_line["line-sort-key"])});var Nu={paint:new qo({"line-opacity":new Vo(Gt.paint_line["line-opacity"]),"line-color":new Vo(Gt.paint_line["line-color"]),"line-translate":new No(Gt.paint_line["line-translate"]),"line-translate-anchor":new No(Gt.paint_line["line-translate-anchor"]),"line-width":new Vo(Gt.paint_line["line-width"]),"line-gap-width":new Vo(Gt.paint_line["line-gap-width"]),"line-offset":new Vo(Gt.paint_line["line-offset"]),"line-blur":new Vo(Gt.paint_line["line-blur"]),"line-dasharray":new Uo(Gt.paint_line["line-dasharray"]),"line-pattern":new Uo(Gt.paint_line["line-pattern"]),"line-gradient":new Go(Gt.paint_line["line-gradient"]),"line-trim-offset":new No(Gt.paint_line["line-trim-offset"])}),layout:ju};const Vu=new class extends Vo{possiblyEvaluate(t,e){return e=new Po(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=v({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Nu.paint.properties["line-width"].specification);function Uu(t,e){return e>0?e+2*t:t}Vu.useIntegerZoom=!0;const $u=Qo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Gu=Qo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),qu=Qo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Qo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Zu=Qo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Hu=Qo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Qo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Wu=Qo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Xu=Qo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Qo([{name:"triangle",components:3,type:"Uint16"}]),Qo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"},{type:"Uint8",name:"flipState"}]),Qo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Qo([{type:"Float32",name:"offsetX"}]),Qo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Qu=24;const Yu=128;function Ju(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Po(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let o=n;for(;o<e.length&&e[o]<t+1;)o++;o=Math.min(e.length-1,o);const s=e[n],a=e[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new Po(s)),maxSize:i.evaluate(new Po(a)),interpolationType:r}}}function Ku(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/Yu:"composite"===t.kind?gi(r/Yu,n/Yu,i):e}function th(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=t,a=n?f(Bi.interpolationFactor(n,e,o,s),0,1):0;"camera"===t.kind?r=gi(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var eh=Object.freeze({__proto__:null,getSizeData:Ju,evaluateSizeForFeature:Ku,evaluateSizeForZoom:th,SIZE_PACK_FACTOR:Yu});function ih(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Io.applyArabicShaping&&(t=Io.applyArabicShaping(t)),t}(t.text,e,i)})),t}const rh={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function nh(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||""===t||" ̄"===t||"︑"===t||"︒"===t}function oh(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var sh=function(t,e,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,u=-7,h=i?n-1:0,p=i?-1:1,d=t[e+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+t[e+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+t[e+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},ah=function(t,e,i,r,n,o){var s,a,l,c=8*o-n-1,u=(1<<c)-1,h=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*l-1)*Math.pow(2,n),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;t[i+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;t[i+d]=255&s,d+=f,s/=256,c-=8);t[i+d-f]|=128*m},lh=ch;function ch(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}ch.Varint=0,ch.Fixed64=1,ch.Bytes=2,ch.Fixed32=5;var uh=4294967296,hh=1/uh,ph="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function dh(t){return t.type===ch.Bytes?t.readVarint()+t.pos:t.pos+1}function fh(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function mh(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function _h(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function gh(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function yh(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function vh(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function xh(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function bh(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function wh(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Th(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function Mh(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Eh(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Ch(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Sh(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function kh(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ah,e)}function Ah(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Ih,{});e.glyphs.push({id:t,bitmap:new ac({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Ih(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Ph(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,o=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:o,fill:e/(n*o)||0}}ch.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,t(n,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Eh(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Sh(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Eh(this.buf,this.pos)+Eh(this.buf,this.pos+4)*uh;return this.pos+=8,t},readSFixed64:function(){var t=Eh(this.buf,this.pos)+Sh(this.buf,this.pos+4)*uh;return this.pos+=8,t},readFloat:function(){var t=sh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=sh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return fh(t,r,e);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return fh(t,r,e);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return fh(t,r,e);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return fh(t,r,e);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return fh(t,r,e);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return fh(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ph?function(t,e,i){return ph.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var o,s,a,l=t[n],c=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=t[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=t[n+2],128==(192&(o=t[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=t[n+2],a=t[n+3],128==(192&(o=t[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=u}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==ch.Bytes)return t.push(this.readVarint(e));var i=dh(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==ch.Bytes)return t.push(this.readSVarint());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==ch.Bytes)return t.push(this.readBoolean());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==ch.Bytes)return t.push(this.readFloat());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==ch.Bytes)return t.push(this.readDouble());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==ch.Bytes)return t.push(this.readFixed32());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==ch.Bytes)return t.push(this.readSFixed32());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==ch.Bytes)return t.push(this.readFixed64());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==ch.Bytes)return t.push(this.readSFixed64());var e=dh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===ch.Varint)for(;this.buf[this.pos++]>127;);else if(e===ch.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ch.Fixed32)this.pos+=4;else{if(e!==ch.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Ch(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Ch(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Ch(this.buf,-1&t,this.pos),Ch(this.buf,Math.floor(t*hh),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Ch(this.buf,-1&t,this.pos),Ch(this.buf,Math.floor(t*hh),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&mh(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),ah(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ah(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&mh(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,ch.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,_h,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,gh,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,xh,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,yh,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,vh,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,bh,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,wh,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Th,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mh,e)},writeBytesField:function(t,e){this.writeTag(t,ch.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ch.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ch.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ch.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ch.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ch.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ch.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ch.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ch.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ch.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class Lh{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class zh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:o,h:s}=Ph(n),a=new lc({width:o||1,height:s||1});for(const e in t){const r=t[e],n=i[e].paddedRect;lc.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,o=n.x+1,s=n.y+1,l=i.data.width,c=i.data.height;lc.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),lc.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),lc.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),lc.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),lc.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),e[r]=new Lh(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}Pn(Lh,"ImagePosition"),Pn(zh,"ImageAtlas");const Dh={horizontal:1,vertical:2,horizontalOnly:3};class Rh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Rh;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Rh;return e.imageName=t,e}}class Oh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Oh;for(let r=0;r<t.sections.length;r++){const n=t.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,e)}return i}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(t){this.text=function(t,e){let i="";for(let r=0;r<t.length;r++){const n=t.charCodeAt(r+1)||null,o=t.charCodeAt(r-1)||null;i+=!e&&(n&&mo(n)&&!rh[t[r+1]]||o&&mo(o)&&!rh[t[r-1]])||!rh[t[r]]?t[r]:rh[t[r]]}return i}(this.text,t)}trim(){let t=0;for(let e=0;e<this.text.length&&Bh[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let i=this.text.length-1;i>=0&&i>=t&&Bh[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Oh;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Rh.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(i)}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void P("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(Rh.forImage(e)),this.sectionIndex.push(this.sections.length-1)):P("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Fh(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m){const _=Oh.fromFeature(t,n);let g;h===Dh.vertical&&_.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:v}=Io;if(y&&1===_.sections.length){g=[];const t=y(_.toString(),qh(_,c,o,e,r,d,f));for(const e of t){const t=new Oh;t.text=e,t.sections=_.sections;for(let i=0;i<e.length;i++)t.sectionIndex.push(0);g.push(t)}}else if(v){g=[];const t=v(_.text,_.sectionIndex,qh(_,c,o,e,r,d,f));for(const e of t){const t=new Oh;t.text=e[0],t.sectionIndex=e[1],t.sections=_.sections,g.push(t)}}else g=function(t,e){const i=[],r=t.text;let n=0;for(const r of e)i.push(t.substring(n,r)),n=r;return n<r.length&&i.push(t.substring(n,r.length)),i}(_,qh(_,c,o,e,r,d,f));const x=[],b={positionedLines:x,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(t,e,i,r,n,o,s,a,l,c,u,h){let p=0,d=0,f=0;const m="right"===a?1:"left"===a?0:.5;let _=!1;for(const t of n){const i=t.getSections();for(const t of i){if(t.imageName)continue;const i=e[t.fontStack];if(i&&(_=void 0!==i.ascender&&void 0!==i.descender,!_))break}if(!_)break}let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*Qu,v={positionedGlyphs:[],lineOffset:0};t.positionedLines[g]=v;const x=v.positionedGlyphs;let b=0;if(!s.length()){d+=o,++g;continue}let w=0,T=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o);let g=a.scale,v=null,M=null,E=null,C=Qu,S=0;const k=!(l===Dh.horizontal||!u&&!fo(m)||u&&(Bh[m]||(y=m,Fn(y)||Bn(y)||jn(y)||no(y)||lo(y))));if(a.imageName){const e=r[a.imageName];if(!e)continue;E=a.imageName,t.iconsInText=t.iconsInText||!0,M=e.paddedRect;const i=e.displaySize;g=g*Qu/h,v={width:i[0],height:i[1],left:1,top:-3,advance:k?i[1]:i[0],localGlyph:!1},S=_?-v.height*g:n*Qu-17-i[1]*g,C=v.advance;const o=(k?i[0]:i[1])*g-Qu*n;o>0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(M=t[m]);const r=e[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,C=8203!==m?Qu:0,_){const t=void 0!==r.ascender?Math.abs(r.ascender):0,e=void 0!==r.descender?Math.abs(r.descender):0,i=(t+e)*g;w<i&&(w=i,T=(t-e)/2*g),S=-t*g}else S=(n-g)*Qu-17}k?(t.verticalizable=!0,x.push({glyph:m,imageName:E,x:p,y:d+S,vertical:k,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:M}),p+=C*g+c):(x.push({glyph:m,imageName:E,x:p,y:d+S,vertical:k,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:M}),p+=v.advance*g+c)}0!==x.length&&(f=Math.max(p-c,f),_?Hh(x,m,b,T,o*n/2):Hh(x,m,b,0,o/2)),p=0;const M=o*n+b;v.lineOffset=Math.max(b,a),d+=M,++g}var y;const v=d,{horizontalAlign:x,verticalAlign:b}=Zh(s);(function(t,e,i,r,n,o){const s=(e-i)*n,a=-o*r;for(const e of t)for(const t of e.positionedGlyphs)t.x+=s,t.y+=a})(t.positionedLines,m,x,b,f,v),t.top+=-b*v,t.bottom=t.top+v,t.left+=-x*f,t.right=t.left+f,t.hasBaseline=_}(b,e,i,r,g,s,a,l,h,c,p,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(x)&&b}const Bh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},jh={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 Nh(t,e,i,r,n,o){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*Qu/o+n:0}{const r=i[e.fontStack],o=r&&r.glyphs[t];return o?o.metrics.advance*e.scale+n:0}}function Vh(t,e,i,r){const n=Math.pow(t-e,2);return r?t<e?n/2:2*n:n+Math.abs(i)*i}function Uh(t,e,i){let r=0;return 10===t&&(r-=1e4),i&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function $h(t,e,i,r,n,o){let s=null,a=Vh(e,i,n,o);for(const t of r){const r=Vh(e-t.x,i,n,o)+t.badness;r<=a&&(s=t,a=r)}return{index:t,x:e,priorBreak:s,badness:a}}function Gh(t){return t?Gh(t.priorBreak).concat(t.index):[]}function qh(t,e,i,r,n,o,s){if("point"!==o)return[];if(!t)return[];const a=[],l=function(t,e,i,r,n,o){let s=0;for(let i=0;i<t.length();i++){const a=t.getSection(i);s+=Nh(t.getCharCode(i),a,r,n,e,o)}return s/Math.max(1,Math.ceil(s/i))}(t,e,i,r,n,s),c=t.text.indexOf("")>=0;let u=0;for(let i=0;i<t.length();i++){const o=t.getSection(i),p=t.getCharCode(i);if(Bh[p]||(u+=Nh(p,o,r,n,e,s)),i<t.length()-1){const e=!((h=p)<11904||!(Hn(h)||Zn(h)||so(h)||ro(h)||Yn(h)||Nn(h)||Wn(h)||$n(h)||Jn(h)||Kn(h)||Qn(h)||co(h)||Gn(h)||Un(h)||Vn(h)||Xn(h)||qn(h)||oo(h)||eo(h)||to(h)));(jh[p]||e||o.imageName)&&a.push($h(i+1,u,l,a,Uh(p,t.getCharCode(i+1),e&&c),!1))}}var h;return Gh($h(t.length(),u,l,a,0,!0))}function Zh(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Hh(t,e,i,r,n){if(!(e||i||r||n))return;const o=t.length-1,s=t[o],a=(s.x+s.metrics.advance*s.scale)*e;for(let e=0;e<=o;e++)t[e].x-=a,t[e].y+=i+r+n}function Wh(t,e,i){const{horizontalAlign:r,verticalAlign:n}=Zh(i),o=e[0]-t.displaySize[0]*r,s=e[1]-t.displaySize[1]*n;return{image:t,top:s,bottom:s+t.displaySize[1],left:o,right:o+t.displaySize[0]}}function Xh(t,e,i,r,n,o){const s=t.image;let a;if(s.content){const t=s.content,e=s.pixelRatio||1;a=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e]}const l=e.left*o,c=e.right*o;let u,h,p,d;"width"===i||"both"===i?(d=n[0]+l-r[3],h=n[0]+c+r[1]):(d=n[0]+(l+c-s.displaySize[0])/2,h=d+s.displaySize[0]);const f=e.top*o,m=e.bottom*o;return"height"===i||"both"===i?(u=n[1]+f-r[0],p=n[1]+m+r[2]):(u=n[1]+(f+m-s.displaySize[1])/2,p=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:p,left:d,collisionPadding:a}}class Qh extends n{constructor(t,e,i,r,n){super(t,e),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new Qh(this.x,this.y,this.z,this.angle,this.segment)}}function Yh(t,e,i,r,n){if(void 0===e.segment)return!0;let o=e,s=e.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=t[s].dist(o),o=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const e=t[s],i=t[s+1];if(!i)return!1;let o=t[s-1].angleTo(e)-e.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=e.dist(i)}return!0}function Jh(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Kh(t,e,i){return t?.6*e*i:0}function tp(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function ep(t,e,i,r,n,o){const s=Kh(i,n,o),a=tp(i,r)*o;let l=0;const c=Jh(t)/2;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1],o=r.dist(n);if(l+o>c){const u=(c-l)/o,h=gi(r.x,n.x,u),p=gi(r.y,n.y,u),d=new Qh(h,p,0,n.angleTo(r),i);return!s||Yh(t,d,a,s,e)?d:void 0}l+=o}}function ip(t,e,i,r,n,o,s,a,l){const c=Kh(r,o,s),u=tp(r,n),h=u*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),rp(t,p?e/2*a%e:(u/2+2*o)*s*a%e,e,c,i,h,p,!1,l)}function rp(t,e,i,r,n,o,s,a,l){const c=o/2,u=Jh(t);let h=0,p=e-i,d=[];for(let e=0;e<t.length-1;e++){const s=t[e],a=t[e+1],f=s.dist(a),m=a.angleTo(s);for(;p+i<h+f;){p+=i;const _=(p-h)/f,g=gi(s.x,a.x,_),y=gi(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&p-c>=0&&p+c<=u){const i=new Qh(g,y,0,m,e);i._round(),r&&!Yh(t,i,o,r,n)||d.push(i)}}h+=f}return a||d.length||s||(d=rp(t,h/2,i,r,n,o,s,!0,l)),d}function np(t,e,i,r,o){const s=[];for(let a=0;a<t.length;a++){const l=t[a];let c;for(let t=0;t<l.length-1;t++){let a=l[t],u=l[t+1];a.x<e&&u.x<e||(a.x<e?a=new n(e,a.y+(e-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x<e&&(u=new n(e,a.y+(e-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y<i&&u.y<i||(a.y<i?a=new n(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y<i&&(u=new n(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),a.x>=r&&u.x>=r||(a.x>=r?a=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}Pn(Qh,"Anchor");const op=1e20;function sp(t,e,i,r,n,o,s,a,l){for(let c=e;c<e+r;c++)ap(t,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)ap(t,c*o+e,1,r,s,a,l)}function ap(t,e,i,r,n,o,s){o[0]=0,s[0]=-op,s[1]=op,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=o[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=op}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;t[e+a*i]=n[r]+c*c}}const lp={none:0,ideographs:1,all:2};class cp{constructor(t,e,i){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});g(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const o=Math.floor(e/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:t,id:e,glyph:n});let s=r.requests[o];s||(s=r.requests[o]=[],cp.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){r.ascender=e.ascender,r.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e.glyphs[+t]);r.ranges[o]=!0}for(const i of s)i(t,e);delete r.requests[o]}))),s.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:n}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==lp.none&&(this.localGlyphMode===lp.all?!!this.localFontFamily:!!this.localFontFamily&&(Kn(t)||io(t)||Gn(t)||qn(t)||$n(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=t.tinySDF;if(!n){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),n=t.tinySDF=new cp.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new ac({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function up(t,e,i,r){const o=[],s=t.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=t.right-t.left,h=t.bottom-t.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(t,e)=>t+e[1]-e[0],m=p.reduce(f,0),_=d.reduce(f,0),g=l-m,y=c-_;let v=0,x=m,b=0,w=_,T=0,M=g,E=0,C=y;if(s.content&&r){const t=s.content;v=hp(p,0,t[0]),b=hp(d,0,t[1]),x=hp(p,t[0],t[2]),w=hp(d,t[1],t[3]),T=t[0]-v,E=t[1]-b,M=t[2]-t[0]-x,C=t[3]-t[1]-w}const S=(r,o,l,c)=>{const p=dp(r.stretch-v,x,u,t.left),d=fp(r.fixed-T,M,r.stretch,m),f=dp(o.stretch-b,w,h,t.top),g=fp(o.fixed-E,C,o.stretch,_),y=dp(l.stretch-v,x,u,t.left),S=fp(l.fixed-T,M,l.stretch,m),k=dp(c.stretch-b,w,h,t.top),A=fp(c.fixed-E,C,c.stretch,_),I=new n(p,f),P=new n(y,f),L=new n(y,k),z=new n(p,k),D=new n(d/a,g/a),R=new n(S/a,A/a),O=e*Math.PI/180;if(O){const t=Math.sin(O),e=Math.cos(O),i=[e,-t,t,e];I._matMult(i),P._matMult(i),z._matMult(i),L._matMult(i)}const F=r.stretch+r.fixed,B=o.stretch+o.fixed;return{tl:I,tr:P,bl:z,br:L,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+B,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:R,minFontScaleX:M/a/u,minFontScaleY:C/a/h,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const t=pp(p,g,m),e=pp(d,y,_);for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)o.push(S(r,e[t],n,e[t+1]))}}else o.push(S({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function hp(t,e,i){let r=0;for(const n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function pp(t,e,i){const r=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+1,stretch:i}),r}function dp(t,e,i,r){return t/e*i+r}function fp(t,e,i,r){return t-e*i/r}function mp(t,e,i,r){const n=e+t.positionedLines[r].lineOffset;return 0===r?i+n/2:i+(n+(e+t.positionedLines[r-1].lineOffset))/2}cp.loadGlyphRange=function(t,e,i,r,n){const o=256*e,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),St.Glyphs);Pt(a,((t,e)=>{if(t)n(t);else if(e){const t={},i=function(t){return new lh(t).readFields(kh,{})}(e);for(const e of i.glyphs)t[e.id]=e;n(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},cp.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(op,0,h),_.fill(0,0,h);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)g[r]=0,_[r]=op;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}sp(g,0,0,c,u,c,this.f,this.v,this.z),sp(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<h;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};class _p{constructor(t=[],e=gp){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1),o=e[r];const s=r+1;if(s<this.length&&i(e[s],o)<0&&(r=s,o=e[s]),i(o,n)>=0)break;e[t]=o,t=r}e[t]=n}}function gp(t,e){return t<e?-1:t>e?1:0}function yp(t,e=1,i=!1){let r=1/0,o=1/0,s=-1/0,a=-1/0;const l=t[0];for(let t=0;t<l.length;t++){const e=l[t];(!t||e.x<r)&&(r=e.x),(!t||e.y<o)&&(o=e.y),(!t||e.x>s)&&(s=e.x),(!t||e.y>a)&&(a=e.y)}const c=Math.min(s-r,a-o);let u=c/2;const h=new _p([],vp);if(0===c)return new n(r,o);for(let e=r;e<s;e+=c)for(let i=o;i<a;i+=c)h.push(new xp(e+u,i+u,u,t));let p=function(t){let e=0,i=0,r=0;const n=t[0];for(let t=0,o=n.length,s=o-1;t<o;s=t++){const o=n[t],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,e+=3*l}return new xp(i/e,r/e,0,t)}(t),d=h.length;for(;h.length;){const r=h.pop();(r.d>p.d||!p.d)&&(p=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-p.d<=e||(u=r.h/2,h.push(new xp(r.p.x-u,r.p.y-u,u,t)),h.push(new xp(r.p.x+u,r.p.y-u,u,t)),h.push(new xp(r.p.x-u,r.p.y+u,u,t)),h.push(new xp(r.p.x+u,r.p.y+u,u,t)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(t,e){return e.max-t.max}function xp(t,e,i,r){this.p=new n(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;n<e.length;n++){const o=e[n];for(let e=0,n=o.length,s=n-1;e<n;s=e++){const n=o[e],a=o[s];n.y>t.y!=a.y>t.y&&t.x<(a.x-n.x)*(t.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,tl(t,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const bp=Number.POSITIVE_INFINITY,wp=Math.sqrt(2);function Tp(t,e){return e[1]!==bp?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/wp;switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Mp(t,e,i,r,n,o,s,a,l,c){t.createArrays(),t.tilePixelRatio=ba/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Po(e),a),h["text-size"].possiblyEvaluate(new Po(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Po(e),a),h["icon-size"].possiblyEvaluate(new Po(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Po(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Po(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Po(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=p.layoutTextSize.evaluate(o,{},a),_=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),g=o.text;let y,v=[0,0];if(g){const r=g.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Qu,c=u.get("text-line-height").evaluate(o,{},a)*Qu,p=ho(r)?s:0,f=u.get("text-anchor").evaluate(o,{},a),y=u.get("text-variable-anchor");if(!y){const t=u.get("text-radial-offset").evaluate(o,{},a);v=t?Tp(f,[t*Qu,bp]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Qu))}let x=d?"center":u.get("text-justify").evaluate(o,{},a);const b=u.get("symbol-placement"),w="point"===b,T="point"===b?u.get("text-max-width").evaluate(o,{},a)*Qu:0,M=o=>{t.allowVerticalPlacement&&uo(r)&&(_.vertical=Fh(g,e,i,n,l,T,c,f,o,p,v,Dh.vertical,!0,b,m,h))};if(!d&&y){const t="auto"===x?y.map((t=>Ep(t))):[x];let r=!1;for(let o=0;o<t.length;o++){const s=t[o];if(!_.horizontal[s])if(r)_.horizontal[s]=_.horizontal[0];else{const t=Fh(g,e,i,n,l,T,c,"center",s,p,v,Dh.horizontal,!1,b,m,h);t&&(_.horizontal[s]=t,r=1===t.positionedLines.length)}}M("left")}else{if("auto"===x&&(x=Ep(f)),w||u.get("text-writing-mode").indexOf("horizontal")>=0||!uo(r)){const t=Fh(g,e,i,n,l,T,c,f,x,p,v,Dh.horizontal,!1,b,m,h);t&&(_.horizontal[x]=t)}M("point"===b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const e=r[o.icon.name];e&&(y=Wh(n[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&P("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const b=Ap(_.horizontal)||_.vertical;t.iconsInText||(t.iconsInText=!!b&&b.iconsInText),(b||y)&&Cp(t,o,_,y,r,p,m,0,v,x,s,a,c)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Ep(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Cp(t,e,i,r,n,o,s,a,c,u,h,p,d){let f=o.textMaxSize.evaluate(e,{},p);void 0===f&&(f=s);const m=t.layers[0].layout,_=m.get("icon-offset").evaluate(e,{},p),g=Ap(i.horizontal)||i.vertical,y="globe"===d.name,v=s/24,x=t.tilePixelRatio*f/24,b=(A=t.overscaling,t.zoom>18&&A>2&&(A>>=1),Math.max(ba/(512*A),1)*m.get("symbol-spacing")),w=m.get("text-padding")*t.tilePixelRatio,T=m.get("icon-padding")*t.tilePixelRatio,M=l(m.get("text-max-angle")),E="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),S=m.get("symbol-placement"),k=b/2;var A;const I=m.get("icon-text-fit");let L;r&&"none"!==I&&(t.allowVerticalPlacement&&i.vertical&&(L=Xh(r,i.vertical,I,m.get("icon-text-fit-padding"),_,v)),g&&(r=Xh(r,g,I,m.get("icon-text-fit-padding"),_,v)));const z=(s,a,l)=>{if(a.x<0||a.x>=ba||a.y<0||a.y>=ba)return;let f=null;if(y){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,l);f={anchor:new Qh(t,e,i,0,void 0),up:d.upVector(l,a.x,a.y)}}!function(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,M){const E=t.addToLineVertexArray(e,r);let C,S,k,A,I,L,z,D=0,R=0,O=0,F=0,B=-1,j=-1;const N={};let V=Gs("");const U=i?i.anchor:e;let $=0,G=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[$,G]=l.layout.get("text-offset").evaluate(x,{},M).map((t=>t*Qu)):($=l.layout.get("text-radial-offset").evaluate(x,{},M)*Qu,G=bp),t.allowVerticalPlacement&&n.vertical){const t=n.vertical;if(f)L=Pp(t),a&&(z=Pp(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},M)+90;k=Ip(c,U,e,u,h,p,t,d,i,m),a&&(A=Ip(c,U,e,u,h,p,a,g,i))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},M),n="none"!==l.layout.get("icon-text-fit"),s=up(o,r,w,n),d=a?up(a,r,w,n):void 0;S=Ip(c,U,e,u,h,p,o,g,r),D=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Yu*l.layout.get("icon-size").evaluate(x,{},M)],m[0]>Sp&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Yu*b.compositeIconSizes[0].evaluate(x,{},M),Yu*b.compositeIconSizes[1].evaluate(x,{},M)],(m[0]>Sp||m[1]>Sp)&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,!1,i,e,E.lineStartIndex,E.lineLength,-1,T,M),B=t.icon.placedSymbolArray.length-1,d&&(R=4*d.length,t.addSymbols(t.icon,d,m,v,y,x,Dh.vertical,i,e,E.lineStartIndex,E.lineLength,-1,T,M),j=t.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];C||(V=Gs(o.text),f?I=Pp(o):C=Ip(c,U,e,u,h,p,o,d,l.layout.get("text-rotate").evaluate(x,{},M),m));const a=1===o.positionedLines.length;if(O+=kp(t,i,e,o,s,l,f,x,m,E,n.vertical?Dh.horizontal:Dh.horizontalOnly,a?Object.keys(n.horizontal):[r],N,B,b,T,M),a)break}n.vertical&&(F+=kp(t,i,e,n.vertical,s,l,f,x,m,E,Dh.vertical,["vertical"],N,j,b,T,M));let q=-1;const Z=(t,e)=>t?Math.max(t,e):e;q=Z(I,q),q=Z(L,q),q=Z(z,q);const H=q>-1?1:0;t.glyphOffsetArray.length>=Bd.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(U.x,U.y,U.z,e.x,e.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,B,j,V,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,void 0!==k?k:t.collisionBoxArray.length,void 0!==k?k+1:t.collisionBoxArray.length,void 0!==S?S:t.collisionBoxArray.length,void 0!==S?S+1:t.collisionBoxArray.length,A||t.collisionBoxArray.length,A?A+1:t.collisionBoxArray.length,u,O,F,D,R,H,0,$,G,q)}(t,a,f,s,i,r,n,L,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,w,E,c,0,T,C,_,e,o,u,h,p)};if("line"===S)for(const n of np(e.geometry,0,0,ba,ba)){const e=ip(n,b,M,i.vertical||g,r,24,x,t.overscaling,ba);for(const i of e){g&&Lp(t,g.text,k,i)||z(n,i,p)}}else if("line-center"===S){for(const t of e.geometry)if(t.length>1){const e=ep(t,M,i.vertical||g,r,24,x);e&&z(t,e,p)}}else if("Polygon"===e.type)for(const t of Zc(e.geometry,0)){const e=yp(t,16);z(t[0],new Qh(e.x,e.y,0,0,void 0),p)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new Qh(t[0].x,t[0].y,0,0,void 0),p);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new Qh(e.x,e.y,0,0,void 0),p)}const Sp=32640;function kp(t,e,i,r,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=function(t,e,i,r,o,s,a,l){const c=[];if(0===e.positionedLines.length)return c;const u=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],r=e*i;return r>0?[e,-i]:r<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let p=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)p-=t.lineOffset;const d=e.positionedLines.length,f=p/d;let m=e.top-i[1];for(let t=0;t<d;++t){const r=e.positionedLines[t];m=mp(e,f,m,t);for(const t of r.positionedGlyphs){if(!t.rect)continue;const r=t.rect||{};let s=4,p=!0,d=1,f=0;if(t.imageName){const e=a[t.imageName];if(!e)continue;if(e.sdf){P("SDF images are not supported in formatted text and will be ignored.");continue}p=!1,d=e.pixelRatio,s=1/d}const _=(o||l)&&t.vertical,g=t.metrics.advance*t.scale/2,y=t.metrics,v=t.rect;if(null===v)continue;l&&e.verticalizable&&(f=t.imageName?g-t.metrics.width*t.scale/2:0);const x=o?[t.x+g,t.y]:[0,0];let b=[0,0],w=[0,0],T=!1;o||(_?(w=[t.x+g+h[0],t.y+h[1]-f],T=!0):b=[t.x+g+i[0],t.y+i[1]-f]);const M=v.w*t.scale/(d*(t.localGlyph?2:1)),E=v.h*t.scale/(d*(t.localGlyph?2:1));let C,S,k,A;if(_){const e=t.y-m,i=new n(-g,g-e),r=-Math.PI/2,o=new n(...w);C=new n(-g+b[0],b[1]),C._rotateAround(r,i)._add(o),C.x+=-e+g,C.y-=(y.left-s)*t.scale;const a=t.imageName?y.advance*t.scale:Qu*t.scale,l=String.fromCharCode(t.glyph);nh(l)?C.x+=(1-s)*t.scale:oh(l)?C.x+=a-y.height*t.scale+(-s-1)*t.scale:C.x+=t.imageName||y.width+2*s===v.w&&y.height+2*s===v.h?(a-E)/2:(a-(y.height+2*s)*t.scale)/2,S=new n(C.x,C.y-M),k=new n(C.x+E,C.y),A=new n(C.x+E,C.y-M)}else{const e=(y.left-s)*t.scale-g+b[0],i=(-y.top-s)*t.scale+b[1],r=e+M,o=i+E;C=new n(e,i),S=new n(r,i),k=new n(e,o),A=new n(r,o)}if(u){let t;t=o?new n(0,0):T?new n(h[0],h[1]):new n(i[0],i[1]),C._rotateAround(u,t),S._rotateAround(u,t),k._rotateAround(u,t),A._rotateAround(u,t)}const I=new n(0,0),L=new n(0,0);c.push({tl:C,tr:S,bl:k,br:A,tex:r,writingMode:e.writingMode,glyphOffset:x,sectionIndex:t.sectionIndex,isSDF:p,pixelOffsetTL:I,pixelOffsetBR:L,minFontScaleX:0,minFontScaleY:0})}}return c}(0,r,c,s,a,l,o,t.allowVerticalPlacement),v=t.textSizeData;let x=null;"source"===v.kind?(x=[Yu*s.layout.get("text-size").evaluate(l,{},g)],x[0]>Sp&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Yu*m.compositeTextSizes[0].evaluate(l,{},g),Yu*m.compositeTextSizes[1].evaluate(l,{},g)],(x[0]>Sp||x[1]>Sp)&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,c,a,l,h,e,i,u.lineStartIndex,u.lineLength,f,_,g);for(const e of p)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Ap(t){for(const e in t)return t[e];return null}function Ip(t,e,i,r,o,s,a,c,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const _=a.collisionPadding;if(_&&(f-=_[0],p-=_[1],m+=_[2],d+=_[3]),u){const t=new n(f,p),e=new n(m,p),i=new n(f,d),r=new n(m,d),o=l(u);let s=new n(0,0);h&&(s=new n(h[0],h[1])),t._rotateAround(o,s),e._rotateAround(o,s),i._rotateAround(o,s),r._rotateAround(o,s),f=Math.min(t.x,e.x,i.x,r.x),m=Math.max(t.x,e.x,i.x,r.x),p=Math.min(t.y,e.y,i.y,r.y),d=Math.max(t.y,e.y,i.y,r.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,f,p,m,d,c,r,o,s),t.length-1}function Pp(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Lp(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const zp=Qo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),{members:Dp}=zp,Rp=Qo([{name:"a_pos_3",components:3,type:"Int16"}]);var Op=Qo([{name:"a_pos",type:"Int16",components:2}]);const Fp=ba/Math.PI/2,Bp=2*Aa(1,0)*Fp*Math.PI,jp=[64,32,16],Np=-Fp,Vp=Fp,Up=[new Yl([Np,Np,Np],[Vp,Vp,Vp]),new Yl([Np,Np,Np],[0,0,Vp]),new Yl([0,Np,Np],[Vp,0,Vp]),new Yl([Np,0,Np],[0,Vp,Vp]),new Yl([0,0,Np],[Vp,Vp,Vp])];function $p(t,e,i,r=!0){const n=Pl([],t._camera.position,t.worldSize),o=[e,i,1,1];$l(o,o,t.pixelMatrixInverse),Ul(o,o,1/o[3]);const s=zl([],jl([],o,n)),a=t.globeMatrix,l=[a[12],a[13],a[14]],u=jl([],l,n),h=Ml(u),p=zl([],u),d=t.worldSize/(2*Math.PI),m=Dl(p,s),_=Math.asin(d/h);if(_<Math.acos(m)){if(!r)return null;const t=[],e=[];Pl(t,s,h/m),zl(e,jl(e,t,u)),zl(s,Cl(s,u,Pl(s,e,Math.tan(_)*h)))}const g=[];new Wl(n,s).closestPointOnSphere(l,d,g);const y=zl([],j(a,0)),v=zl([],j(a,1)),x=zl([],j(a,2)),b=Dl(y,g),w=Dl(v,g),T=Dl(x,g),M=c(Math.asin(-w/d));let E=c(Math.atan2(b,T));E=t.center.lng+function(t,e){const i=(e-t+180)%360-180;return i<-180?i+360:i}(t.center.lng,E);const C=Sa(E),S=f(ka(M),0,1);return new Da(C,S)}class Gp{constructor(t,e,i){this.a=jl([],t,i),this.b=jl([],e,i),this.center=i;const r=zl([],this.a),n=zl([],this.b);this.angle=Math.acos(Dl(r,n))}}function qp(t,e){if(0===t.angle)return null;let i;return i=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(t,e,i,r){const n=Math.sin(i);return t*(Math.sin((1-r)*i)/n)+e*(Math.sin(r*i)/n)}(t.a[e],t.b[e],t.angle,f(i,0,1))+t.center[e]}function Zp(t){if(t.z<=1)return Up[t.z+2*t.y+t.x];const[e,i]=Wp(t),r=[Qp(e[0],e[1]),Qp(e[0],i[1]),Qp(i[0],e[1]),Qp(i[0],i[1])],n=[Vp,Vp,Vp],o=[Np,Np,Np];for(const t of r)n[0]=Math.min(n[0],t[0]),n[1]=Math.min(n[1],t[1]),n[2]=Math.min(n[2],t[2]),o[0]=Math.max(o[0],t[0]),o[1]=Math.max(o[1],t[1]),o[2]=Math.max(o[2],t[2]);return new Yl(n,o)}function Hp(t,e,i){const r=e/t.worldSize,n=Number.MAX_VALUE,o=[-n,-n,-n],s=[n,n,n],a=fl(new Float64Array(16));if(gl(a,a,[r,r,r]),ml(a,a,t.globeMatrix),i.z<=1){const t=Zp(i).getCorners();for(let e=0;e<t.length;e++)Ol(t[e],t[e],a),Al(s,s,t[e]),Il(o,o,t[e]);return new Yl(s,o)}const[c,u]=Wp(i),h=new wa;h.setSouthWest([c[1],u[0]]),h.setNorthEast([u[1],c[0]]);const p=[Qp(h.getSouth(),h.getWest()),Qp(h.getSouth(),h.getEast()),Qp(h.getNorth(),h.getEast()),Qp(h.getNorth(),h.getWest())];for(let t=0;t<p.length;t++)Ol(p[t],p[t],a),Al(s,s,p[t]),Il(o,o,p[t]);if(h.contains(t.center)){o[2]=0;const e=t.point,i=[e.x*r,e.y*r,0];return Al(s,s,i),Il(o,o,i),new Yl(s,o)}const d=[a[12],a[13],a[14]],m=t.center.lng,_=f(t.center.lat,-85.051129,za),g=[Sa(m),ka(_)],y=h.getCenter().lng,v=f(h.getCenter().lat,-85.051129,za),x=[Sa(y),ka(v)];let b=new Array(3),w=0,T=g[0]-x[0];const M=g[1]-x[1];if(T>.5?T-=1:T<-.5&&(T+=1),Math.abs(T)>Math.abs(M))w=T>=0?1:3,b=d;else{w=M>=0?0:2;const t=[a[4],a[5],a[6]];let e;e=M>=0?-Math.sin(l(h.getSouth()))*Fp:-Math.sin(l(h.getNorth()))*Fp,b=Ll(b,d,t,e)}const E=p[w],C=p[(w+1)%4],S=new Gp(E,C,b),k=[qp(S,0)||E[0],qp(S,1)||E[1],qp(S,2)||E[2]];return s[2]=Math.min(E[2],C[2]),Al(s,s,k),Il(o,o,k),new Yl(s,o)}function Wp(t){const e=1<<t.z,i=t.x/e,r=(t.x+1)/e,n=(t.y+1)/e;return[[Pa(t.y/e),Ia(i)],[Pa(n),Ia(r)]]}function Xp(t,e,i,r=Fp){return i=l(i),[t*Math.sin(i)*r,-e*r,t*Math.cos(i)*r]}function Qp(t,e,i){return Xp(Math.cos(l(t)),Math.sin(l(t)),e,i)}function Yp(t,e,i){const r=Math.pow(2,i.z),n=(t/ba+i.x)/r;return Qp(Pa((e/ba+i.y)/r),Ia(n))}function Jp(t){return 16383/Math.max(...jl([],t.max,t.min))}function Kp(t){const e=fl(new Float64Array(16)),i=Jp(t);var r,n;return gl(e,e,[i,i,i]),_l(e,e,((r=[])[0]=-(n=t.min)[0],r[1]=-n[1],r[2]=-n[2],r)),e}function td(t){const e=fl(new Float64Array(16)),i=1/Jp(t);return _l(e,e,t.min),gl(e,e,[i,i,i]),e}function ed(t,e,i,r,n){const o=function(t){const e=ba/(2*Math.PI);return t/(2*Math.PI)/e}(i),s=[t,e,-i/(2*Math.PI)],a=fl(new Float64Array(16));return _l(a,a,s),gl(a,a,[o,o,o]),yl(a,a,l(-n)),vl(a,a,l(-r)),a}function id(t){return m(5,6,t)}function rd(t,e){const i=Qp(e.lat,e.lng);return o=(r=Sl([],function(t){const e=Qp(t._center.lat,t._center.lng);let i=Rl([],El(0,1,0),e);const r=xl([],-t.angle,e);i=Ol(i,i,r),xl(r,-t._pitch,i);const n=zl([],e);return Pl(n,n,t.cameraToCenterDistance/t.pixelsPerMeter*Bp),Ol(n,n,r),Cl([],e,n)}(t),i))[0],s=r[1],a=r[2],l=(n=i)[0],c=n[1],u=n[2],p=(h=Math.sqrt(o*o+s*s+a*a)*Math.sqrt(l*l+c*c+u*u))&&Dl(r,n)/h,Math.acos(Math.min(Math.max(p,-1),1));var r,n,o,s,a,l,c,u,h,p}const nd=l(85),od=Math.cos(nd),sd=Math.sin(nd);function ad(t,e){const i=t.fovAboveCenter,r=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,n=(t._camera.position[2]*t.worldSize-r)/Math.cos(t._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),s=Math.sin(t._pitch)*o+n;return Math.min(1.01*s,n*(1/t._horizonShift))}function ld(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const i=Math.pow(2,-t.z),r=t.x*i,n=(t.x+1)*i,o=t.y*i,s=(t.y+1)*i,a=Ia(r),l=Ia(n),c=Pa(o),u=Pa(s),h=e.project(a,c),p=e.project(l,c),d=e.project(l,u),f=e.project(a,u);let m=Math.min(h.x,p.x,d.x,f.x),_=Math.min(h.y,p.y,d.y,f.y),g=Math.max(h.x,p.x,d.x,f.x),y=Math.max(h.y,p.y,d.y,f.y);const v=i/16;function x(t,i,r,n,o,s){const a=(r+o)/2,l=(n+s)/2,c=e.project(Ia(a),Pa(l)),u=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),u>v&&(x(t,c,r,n,a,l),x(c,i,a,l,o,s))}x(h,p,r,o,n,o),x(p,d,n,o,n,s),x(d,f,n,s,r,s),x(f,h,r,s,r,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}const cd=fl(new Float32Array(16));class ud{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new Ma(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Aa(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return ad(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,r){const o=t.horizonLineFromTop(!1),s=new n(e,Math.max(o,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,r))}pointCoordinate3D(t,e,i){const r=new n(e,i);if(t.elevation)return t.elevation.pointCoordinate(r);{const e=this.pointCoordinate(t,r.x,r.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y<i}createInversionMatrix(t,e){return cd}createTileMatrix(t,e,i){let r,n,o;const s=i.canonical,a=fl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=ld(s,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,gl(a,a,[r/l.scale,r/l.scale,t.pixelsPerMeter/e])}else r=e/t.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return _l(a,a,[n,o,0]),gl(a,a,[r/ba,r/ba,1]),a}upVector(t,e,i){return[0,0,1]}upVectorScale(t,e,i){return{metersToTile:1}}}class hd extends ud{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,i]=this.parallels=t.parallels||[29.5,45.5],r=Math.sin(l(e));this.n=(r+Math.sin(l(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(t,e){const{n:i,c:r,r0:n}=this,o=l(t-this.center[0]),s=l(e),a=Math.sqrt(r-2*i*Math.sin(s))/i;return{x:a*Math.sin(o*i),y:a*Math.cos(o*i)-n,z:0}}unproject(t,e){const{n:i,c:r,r0:n}=this,o=n+e;let s=Math.atan2(t,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(t)*Math.sign(o));const a=l(this.center[0])*i;s=_(s,-Math.PI-a,Math.PI-a);const u=c(s/i)+this.center[0],h=Math.asin(f((r-(t*t+o*o)*i*i)/(2*i),-1,1)),p=f(c(h),-85.051129,za);return new Ma(u,p)}}const pd=1.340264,dd=-.081106,fd=893e-6,md=.003796,_d=Math.sqrt(3)/2;class gd extends ud{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const i=Math.asin(_d*Math.sin(e)),r=i*i,n=r*r*r;return{x:.5*(t*Math.cos(i)/(_d*(pd+3*dd*r+n*(7*fd+9*md*r)))/Math.PI+.5),y:1-.5*(i*(pd+dd*r+n*(fd+md*r))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=i*i,n=r*r*r;for(let t,o,s,a=0;a<12&&(o=i*(pd+dd*r+n*(fd+md*r))-e,s=pd+3*dd*r+n*(7*fd+9*md*r),t=o/s,i=f(i-t,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(t)<1e-12));++a);const o=_d*t*(pd+3*dd*r+n*(7*fd+9*md*r))/Math.cos(i),s=Math.asin(Math.sin(i)/_d),a=f(180*o/Math.PI,-180,180),l=f(180*s/Math.PI,-85.051129,za);return new Ma(a,l)}}class yd extends ud{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){return{x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const i=360*(t-.5),r=f(360*(.5-e),-85.051129,za);return new Ma(i,r)}}const vd=Math.PI/2;function xd(t){return Math.tan((vd+t)/2)}class bd extends ud{constructor(t){super(t),this.center=t.center||[0,30];const[e,i]=this.parallels=t.parallels||[30,30],r=l(e),n=l(i),o=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(xd(n)/xd(r)),this.f=o*Math.pow(xd(r),this.n)/this.n}project(t,e){e=l(e),t=l(t-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?e<-vd+i&&(e=-vd+i):e>vd-i&&(e=vd-i);const o=n/Math.pow(xd(e),r),s=o*Math.sin(r*t),a=n-o*Math.cos(r*t);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this,n=r-e,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(t*t+n*n);let a=Math.atan2(t,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(t)*o);const l=f(c(a/i)+this.center[0],-180,180),u=f(c(2*Math.atan(Math.pow(r/s,1/i))-vd),-85.051129,za);return new Ma(l,u)}}class wd extends ud{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:Sa(t),y:ka(e),z:0}}unproject(t,e){const i=Ia(t),r=Pa(e);return new Ma(i,r)}}const Td=l(za);class Md extends ud{project(t,e){const i=(e=l(e))*e,r=i*i;return{x:.5*((t=l(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const t=o*o;n=(i*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),i=f(i-n,-Td,Td)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=f(c(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=c(i);return new Ma(s,a)}}const Ed=l(za);class Cd extends ud{project(t,e){e=l(e),t=l(t);const i=Math.cos(e),r=2/Math.PI,n=Math.acos(i*Math.cos(t/2)),o=Math.sin(n)/n,s=.5*(t*r+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,m=p*p,_=1-u*h*h,g=_?1/_:0,y=_?Math.acos(n*h)*Math.sqrt(1/_):0,v=.5*(2*y*n*p+2*i/Math.PI)-t,x=.5*(y*o+r)-e,b=.5*g*(u*m+y*n*h*c)+1/Math.PI,w=g*(d*l/4-y*o*p),T=.125*g*(l*p-y*o*u*d),M=.5*g*(c*h+y*m*n)+.5,E=w*T-M*b;s=(x*w-v*M)/E,a=(v*T-x*b)/E,i=f(i-s,-Math.PI,Math.PI),r=f(r-a,-Ed,Ed)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Ma(c(i),c(r))}}class Sd extends ud{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:r}=this;return{x:l(t)*r*i+.5,y:-Math.sin(l(e))/r*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:r}=this,n=-(e-.5)/i,o=f(c((t-.5)/i)/r,-180,180),s=Math.asin(f(n*r,-1,1)),a=f(c(s),-85.051129,za);return new Ma(o,a)}}class kd extends wd{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(t,e,i){const r=Math.pow(2,i.z),n=(t/ba+i.x)/r,o=Qp(Pa((e/ba+i.y)/r),Ia(n));return Ol(o,o,Kp(Zp(i))),{x:o[0],y:o[1],z:o[2]}}locationPoint(t,e){const i=Qp(e.lat,e.lng),r=zl([],i),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Ll(i,i,r,Aa(1,0)*ba*o);const s=fl(new Float64Array(16));return ml(s,t.pixelMatrix,t.globeMatrix),Ol(i,i,s),new n(i[0],i[1])}pixelsPerMeter(t,e){return Aa(1,0)*e}pixelSpaceConversion(t,e,i){const r=gi(Aa(1,45)*e,Aa(1,t)*e,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const r=td(Zp(i.canonical));return ml(new Float64Array(16),t.globeMatrix,r)}createInversionMatrix(t,e){const{center:i}=t,r=fl(new Float64Array(16));return ml(r,r,Kp(Zp(e))),vl(r,r,l(i.lng)),yl(r,r,l(i.lat)),gl(r,r,[t._projectionScaler,t._projectionScaler,1]),Float32Array.from(r)}pointCoordinate(t,e,i,r){return $p(t,e,i,!0)||new Da(0,0)}pointCoordinate3D(t,e,i){const r=this.pointCoordinate(t,e,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(t,e){return!$p(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,r=t._centerAltitude*e,n=t._camera,o=t._camera.forward(),s=Cl([],Pl([],o,-i),[0,0,r]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,u=Math.tan(t.fovAboveCenter),h=Pl([],n.up(),u),p=Pl([],n.right(),u*c),d=zl([],Cl([],Cl([],o,h),p)),f=[];let m;if(new Wl(s,d).closestPointOnSphere(l,a,f)){const e=Cl([],f,l),i=jl([],e,s);m=Math.cos(t.fovAboveCenter)*Ml(i)}else{const t=jl([],s,l),e=jl([],l,s);zl(e,e);const i=Ml(t)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Dl(o,e));m*=Math.cos(r)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=id(t.zoom);if(i>0){const r=ad(t,Aa(1,t.center.lat)*t.worldSize),n=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return gi(e,r+n*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){const r=1<<t.z,n=(e/ba+t.x)/r;return Qp(Pa((i/ba+t.y)/r),Ia(n),1)}upVectorScale(t){return{metersToTile:Bp*Jp(Zp(t))}}}function Ad(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new wd(t);case"equirectangular":return new yd(t);case"naturalEarth":return new Md(t);case"equalEarth":return new gd(t);case"winkelTripel":return new Cd(t);case"albers":return i?new Sd(t):new hd(t);case"lambertConformalConic":return i?new Sd(t):new bd(t);case"globe":return new kd(t)}throw new Error(`Invalid projection name: ${t.name}`)}const Id=hu.VectorTileFeature.types,Pd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Ld(t,e,i,r,n,o,s,a,l,c,u,h,p){const d=a?Math.min(Sp,Math.round(a[0])):0,f=a?Math.min(Sp,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),o,s,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function zd(t,e,i,r,n,o,s){t.emplaceBack(e,i,r,n,o,s)}function Dd(t,e,i,r,n){t.emplaceBack(e,i,r,n),t.emplaceBack(e,i,r,n),t.emplaceBack(e,i,r,n),t.emplaceBack(e,i,r,n)}function Rd(t){for(const e of t.sections)if(yo(e.text))return!0;return!1}class Od{constructor(t){this.layoutVertexArray=new ss,this.indexArray=new fs,this.programConfigurations=t,this.segments=new xa,this.dynamicLayoutVertexArray=new is,this.opacityVertexArray=new ls,this.placedSymbolArray=new As,this.globeExtVertexArray=new as}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$u.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,qu.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Pd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Gu.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Pn(Od,"SymbolBuffers");class Fd{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new xa,this.collisionVertexArray=new ps,this.collisionVertexArrayExt=new ds}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Zu.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Hu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Pn(Fd,"CollisionBuffers");class Bd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fl([]),this.placementViewportMatrix=fl([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ju(this.zoom,e["text-size"]),this.iconSizeData=Ju(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Dh[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Od(new ua(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Od(new ua(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ls,this.lineVertexArray=new zs,this.symbolInstances=new Ps}calculateGlyphDependencies(t,e,i,r,n){for(let i=0;i<t.length;i++)if(e[t.charCodeAt(i)]=!0,r&&n){const r=rh[t.charAt(i)];r&&(e[r.charCodeAt(0)]=!0)}}populate(t,e,i,r){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof xe&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Po(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=n._featureFilter.needGeometry,y=$a(e,t);if(!n._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=Ua(e,i,r)),s&&1!==e.type&&i.z<=5){const t=y.geometry,e=1<<i.z,r=i.x,n=i.y,o=.98078528056;for(let i=0;i<t.length;i++)t[i]=Ba(t[i],(t=>t),((t,i)=>Dl(Qp(Pa((t.y/ba+n)/e),Ia((t.x/ba+r)/e),1),Qp(Pa((i.y/ba+n)/e),Ia((i.x/ba+r)/e),1))<o))}let v,x;if(u){const t=n.getValueAndResolveTokens("text-field",y,i,m),e=xe.factory(t);Rd(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ko()||this.hasRTLText&&Io.isParsed())&&(v=ih(e,n,y))}if(h){const t=n.getValueAndResolveTokens("icon-image",y,i,m);x=t instanceof be?t:be.fromString(t)}if(!v&&!x)continue;const b=this.sortFeaturesByKey?p.evaluate(y,{},i):void 0;if(this.features.push({id:l,text:v,icon:x,index:c,sourceLayerIndex:g,geometry:y.geometry,properties:e.properties,type:Id[e.type],sortKey:b}),x&&(d[x.name]=!0),v){const t=a.evaluate(y,{},i).join(","),e="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Dh.vertical)>=0;for(const i of v.sections)if(i.image)d[i.image.name]=!0;else{const r=uo(v.toString()),n=i.fontStack||t,o=f[n]=f[n]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function o(e){r.push(t[e]),n++}function s(t,e,n){const o=i[t];return delete i[t],i[e]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(t,i,n){const o=e[i];return delete e[i],e[t]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const u=t[c],h=u.geometry,p=u.text?u.text.toString():null;if(!p){o(c);continue}const d=l(p,h),f=l(p,h,!0);if(d in i&&f in e&&i[d]!==e[f]){const t=a(d,f,h),n=s(d,f,r[t].geometry);delete e[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[t].geometry=null}else d in i?s(d,f,h):f in e?a(d,f,h):(o(c),e[d]=n-1,i[f]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Ad(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length,r=t.segment;if(void 0!==r){let i=t.dist(e[r+1]),n=t.dist(e[r]);const o={};for(let t=r+1;t<e.length;t++)o[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:i},t<e.length-1&&(i+=e[t+1].dist(e[t]));for(let t=r||0;t>=0;t--)o[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:n},t>0&&(n+=e[t-1].dist(e[t]));for(let t=0;t<e.length;t++){const e=o[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,n,o,s,a,l,c,u,h,p,d){const f=t.indexArray,m=t.layoutVertexArray,_=t.globeExtVertexArray,g=t.segments.prepareSegment(4*e.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=g.vertexLength,x=this.allowVerticalPlacement&&s===Dh.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r<e.length;r++){const{tl:n,tr:s,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:v,minFontScaleX:w,minFontScaleY:T,glyphOffset:M,isSDF:E,sectionIndex:C}=e[r],S=g.vertexLength,k=M[1];if(Ld(m,l.x,l.y,n.x,k+n.y,h.x,h.y,i,E,y.x,y.y,w,T),Ld(m,l.x,l.y,s.x,k+s.y,h.x+h.w,h.y,i,E,v.x,y.y,w,T),Ld(m,l.x,l.y,c.x,k+c.y,h.x,h.y+h.h,i,E,y.x,v.y,w,T),Ld(m,l.x,l.y,u.x,k+u.y,h.x+h.w,h.y+h.h,i,E,v.x,v.y,w,T),a){const e=a.anchor,i=a.up;zd(_,e.x,e.y,e.z,i[0],i[1],i[2]),zd(_,e.x,e.y,e.z,i[0],i[1],i[2]),zd(_,e.x,e.y,e.z,i[0],i[1],i[2]),zd(_,e.x,e.y,e.z,i[0],i[1],i[2]),Dd(t.dynamicLayoutVertexArray,e.x,e.y,e.z,x)}else Dd(t.dynamicLayoutVertexArray,l.x,l.y,l.z,x);f.emplaceBack(S,S+1,S+2),f.emplaceBack(S+1,S+2,S+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(M[0]),r!==e.length-1&&C===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[C])}const w=a?a.anchor:l;t.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,v,c,u,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,h,0)}_commitLayoutVertex(t,e,i,r,n,o,s){t.emplaceBack(e,i,r,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(t,e,i,r,o,s,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=a.tileAnchorX,h=a.tileAnchorY;for(let t=0;t<4;t++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(e,-t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,t.padding),i.collisionVertexArrayExt.emplaceBack(e,-t.padding,t.padding),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,u,h,new n(t.x1,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,u,h,new n(t.x2,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,u,h,new n(t.x2,t.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,u,h,new n(t.x1,t.y2)),l.vertexLength+=4;const p=i.indexArray;p.emplaceBack(c,c+1),p.emplaceBack(c+1,c+2),p.emplaceBack(c+2,c+3),p.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(t,o,e,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(t,e,s);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(t,e){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Fd(us,Wu.members,bs),this.iconCollisionBox=new Fd(us,Wu.members,bs);const i=th(this.iconSizeData,t),r=th(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(t,e,i,r){const n=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),o=Ku(this.textSizeData,t,n)/Qu;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),n=Ku(this.iconSizeData,t,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(t,o,e,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(t,e,i,r,n){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(t,e,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(t,e){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=th(this.iconSizeData,t),r=th(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,e,i,r,n,o,s,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,padding:e.padding,projectedAnchorX:e.projectedAnchorX,projectedAnchorY:e.projectedAnchorY,projectedAnchorZ:e.projectedAnchorZ,tileAnchorX:e.tileAnchorX,tileAnchorY:e.tileAnchorY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=o;e<s;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const s=this.symbolInstances.get(t);r.push(0|Math.round(e*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),o}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Pn(Bd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Bd.MAX_GLYPHS=65535,Bd.addDynamicAttributes=Dd;const jd=new qo({"symbol-placement":new No(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new No(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new No(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vo(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new No(Gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new No(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new No(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new No(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new No(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vo(Gt.layout_symbol["icon-size"]),"icon-text-fit":new No(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new No(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vo(Gt.layout_symbol["icon-image"]),"icon-rotate":new Vo(Gt.layout_symbol["icon-rotate"]),"icon-padding":new No(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new No(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Vo(Gt.layout_symbol["icon-offset"]),"icon-anchor":new Vo(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new No(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new No(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new No(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new Vo(Gt.layout_symbol["text-field"]),"text-font":new Vo(Gt.layout_symbol["text-font"]),"text-size":new Vo(Gt.layout_symbol["text-size"]),"text-max-width":new Vo(Gt.layout_symbol["text-max-width"]),"text-line-height":new Vo(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Vo(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new Vo(Gt.layout_symbol["text-justify"]),"text-radial-offset":new Vo(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new No(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new Vo(Gt.layout_symbol["text-anchor"]),"text-max-angle":new No(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new No(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new Vo(Gt.layout_symbol["text-rotate"]),"text-padding":new No(Gt.layout_symbol["text-padding"]),"text-keep-upright":new No(Gt.layout_symbol["text-keep-upright"]),"text-transform":new Vo(Gt.layout_symbol["text-transform"]),"text-offset":new Vo(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new No(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new No(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new No(Gt.layout_symbol["text-optional"])});var Nd={paint:new qo({"icon-opacity":new Vo(Gt.paint_symbol["icon-opacity"]),"icon-color":new Vo(Gt.paint_symbol["icon-color"]),"icon-halo-color":new Vo(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vo(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vo(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new No(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new No(Gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Vo(Gt.paint_symbol["text-opacity"]),"text-color":new Vo(Gt.paint_symbol["text-color"],{runtimeType:ie,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Vo(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new Vo(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Vo(Gt.paint_symbol["text-halo-blur"]),"text-translate":new No(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new No(Gt.paint_symbol["text-translate-anchor"])}),layout:jd};class Vd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Jt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Pn(Vd,"FormatSectionOverride",{omit:["defaultValue"]});class Ud extends ga{constructor(t){super(t,Nd)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||zr(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Bd(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Nd.paint.overridableProperties){if(!Ud.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Vd(e),r=new Lr(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Rr("source",r):new Or("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Bo(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Ud.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Nd.paint.properties[e];let n=!1;const o=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof xe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof Se&&Me(e.value)===se?o(e.value.sections):e instanceof Le?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(t){return new ca(this,t)}}var $d={paint:new qo({"background-color":new No(Gt.paint_background["background-color"]),"background-pattern":new $o(Gt.paint_background["background-pattern"]),"background-opacity":new No(Gt.paint_background["background-opacity"])})},Gd={paint:new qo({"raster-opacity":new No(Gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new No(Gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new No(Gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new No(Gt.paint_raster["raster-brightness-max"]),"raster-saturation":new No(Gt.paint_raster["raster-saturation"]),"raster-contrast":new No(Gt.paint_raster["raster-contrast"]),"raster-resampling":new No(Gt.paint_raster["raster-resampling"]),"raster-fade-duration":new No(Gt.paint_raster["raster-fade-duration"])})};class qd extends ga{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var Zd={paint:new qo({"sky-type":new No(Gt.paint_sky["sky-type"]),"sky-atmosphere-sun":new No(Gt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new No(Gt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new No(Gt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new No(Gt.paint_sky["sky-gradient-radius"]),"sky-gradient":new Go(Gt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new No(Gt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new No(Gt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new No(Gt.paint_sky["sky-opacity"])})};function Hd(t,e,i){const r=[0,0,1],n=ql([]);return Hl(n,n,i?-l(t)+Math.PI:l(t)),Zl(n,n,-l(e)),Fl(r,r,n),zl(r,r)}const Wd={circle:class extends ga{constructor(t){super(t,ul)}createBucket(t){return new Za(t)}queryRadius(t){const e=t;return ol("circle-radius",this,e)+ol("circle-stroke-width",this,e)+sl(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,o,s,a){const l=ll(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Jl(t,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new ca(this,t)}},heatmap:class extends ga{createBucket(t){return new rc(t)}constructor(t){super(t,cc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=uc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return ol("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return Jl(t,r,s,a,l,!0,!0,new n(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new ca(this,t)}},hillshade:class extends ga{constructor(t){super(t,hc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ga{constructor(t){super(t,Jc)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new ca(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Qc(t)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,o){return!t.queryGeometry.isAboveHorizon&&Xa(al(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ga{constructor(t){super(t,wu)}createBucket(t){return new yu(t)}queryRadius(){return sl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new ca(this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l,c){const u=ll(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(e,i),p=this.paint.get("fill-extrusion-base").evaluate(e,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=t.tile.getBucket(this);if(f&&_ instanceof yu){const t=_.centroidVertexArray,e=c+1;if(e<t.length){const i=t.get(e);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;"globe"===s.projection.name&&(r=bu([r],[new n(0,0),new n(ba,ba)],t.tileID.canonical).map((t=>t.polygon)).flat());const g=function(t,e,i,r,o,s,a,l,c,u,h){return"globe"===t.projection.name?function(t,e,i,r,n,o,s,a,l,c,u){const h=[],p=[],d=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,r)=>{t[0]=e,t[1]=i,t[2]=r,t[3]=1},g=xu();i>0&&(i+=g),r+=g;for(const g of e){const e=[],y=[];for(const h of g){const p=h.x+n.x,g=h.y+n.y,v=t.projection.projectTilePoint(p,g,u),x=t.projection.upVector(u,h.x,h.y);let b=i,w=r;if(s){const t=Pu(p,g,i,r,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*d*b,v.y+x[1]*d*b,v.z+x[2]*d*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*d*w,v.y+x[1]*d*w,v.z+x[2]*d*w),Ol(f,f,o),Ol(m,m,o),e.push(Iu(f)),y.push(Iu(m))}h.push(e),p.push(y)}return[h,p]}(t,e,i,r,o,s,a,l,c,u,h):a?function(t,e,i,r,n,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const u=c.x+r.x,p=c.y+r.y,f=Pu(u,p,e,i,o,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,$l(h,h,n),h[3]=Math.max(h[3],1e-5);const m=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,$l(h,h,n),h[3]=Math.max(h[3],1e-5);const _=Iu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);t.push(m),d.push(_)}c.push(t),u.push(d)}return[c,u]}(e,i,r,o,s,a,l,c,u):function(t,e,i,r,o){const s=[],a=[],l=o[8]*e,c=o[9]*e,u=o[10]*e,h=o[11]*e,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=o[0]*e+o[4]*a+o[12],g=o[1]*e+o[5]*a+o[13],y=o[2]*e+o[6]*a+o[14],v=o[3]*e+o[7]*a+o[15],x=_+l,b=g+c,w=y+u,T=Math.max(v+h,1e-5),M=_+p,E=g+d,C=y+f,S=Math.max(v+m,1e-5),k=new n(x/T,b/T);k.z=w/T,t.push(k);const A=new n(M/S,E/S);A.z=C/S,i.push(A)}s.push(t),a.push(i)}return[s,a]}(e,i,r,o,s)}(s,r,p,h,u,a,f?l:null,d,m,s.center.lat,t.tileID.canonical),y=t.queryGeometry;return function(t,e,i){let r=1/0;Xa(i,e)&&(r=Au(i,e[0]));for(let n=0;n<e.length;n++){const o=e[n],s=t[n];for(let t=0;t<o.length-1;t++){const e=o[t],n=[e,o[t+1],s[t+1],s[t],e];Ha(i,n)&&(r=Math.min(r,Au(i,n)))}}return r!==1/0&&r}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class extends ga{constructor(t){super(t,Nu),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof _i,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Vu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Bu(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new ca(this,t)}queryRadius(t){const e=t,i=Uu(ol("line-width",this,e),ol("line-gap-width",this,e)),r=ol("line-offset",this,e);return i/2+Math.abs(r)+sl(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,o,s){if(t.queryGeometry.isAboveHorizon)return!1;const a=al(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),l=t.pixelToTileUnitsFactor/2*Uu(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[],r=new n(0,0);for(let n=0;n<t.length;n++){const o=t[n],s=[];for(let t=0;t<o.length;t++){const i=o[t-1],n=o[t],a=o[t+1],l=0===t?r:n.sub(i)._unit()._perp(),c=t===o.length-1?r:a.sub(n)._unit()._perp(),u=l._add(c)._unit();u._mult(1/(u.x*c.x+u.y*c.y)),s.push(u._mult(e)._add(n))}i.push(s)}return i}(r,c*t.pixelToTileUnitsFactor)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(il(t,n[e]))return!0;if(Qa(t,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}},symbol:Ud,background:class extends ga{constructor(t){super(t,$d)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends ga{constructor(t){super(t,Gd)}getProgramIds(){return["raster"]}},sky:class extends ga{constructor(t){super(t,Zd),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=uc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=t.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&P("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?Hd(o.azimuthal,90-o.polar,e):Hd(i[0],90-i[1],e)}const i=this.paint.get("sky-gradient-center");return Hd(i[0],90-i[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}}};class Xd{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,i,r){const{width:n,height:o}=t,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:p}=e;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!i||!1!==i.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===o){const{x:e,y:i}=r||{x:0,y:0};t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?a.texSubImage2D(a.TEXTURE_2D,0,e,i,a.RGBA,a.UNSIGNED_BYTE,t):a.texSubImage2D(a.TEXTURE_2D,0,e,i,n,o,a.RGBA,a.UNSIGNED_BYTE,t.data)}else this.size=[n,o],t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,t):a.texImage2D(a.TEXTURE_2D,0,this.format,n,o,0,this.format,a.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(t,e){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:t),this.filter=t),e!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Qd{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new ac({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const i=this.getKey(t,e);return this.positions[i]}trim(){const t=this.width,e=this.height=T(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let o=0,s=t[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=e/i*(r+1);if(s.isDash){const t=r-Math.abs(p);h=Math.sqrt(u*u+t*t)}else h=r-Math.sqrt(u*u+p*p);this.image.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=t[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return P("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&(P("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const i=this.width/s,o=this.getDashRanges(t,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===e?.5*i:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}Pn(Qd,"LineAtlas");class Yd{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Jd{constructor(){this.tasks={},this.taskQueue=[],E(["process"],this),this.invoker=new Yd(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){D();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){D();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<e&&(e=r.priority,t=i)}if(null===t)return null;const i=this.taskQueue[t];return this.taskQueue.splice(t,1),i}remove(){this.invoker.remove()}}class Kd{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const tf=["tile","layer","source","sourceLayer","state"];class ef{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=r,this.properties=t.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(t.id=this.id);for(const e of tf)void 0!==this[e]&&(t[e]=this[e]);return t}}const rf=32,nf=33,of=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&e?n=o=s=rf:i=r=a=rf;(e>>=1)>1;){const t=i+n>>1,l=r+o>>1;1&e?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=t,a=l}const l=4*t;of[l+0]=i,of[l+1]=r,of[l+2]=n,of[l+3]=o}const sf=new Uint16Array(2178),af=new Uint8Array(1089),lf=new Uint16Array(1089);function cf(t){return 0===t?-.03125:32===t?.03125:0}var uf=Qo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const hf={type:2,extent:ba,loadGeometry:()=>[[new n(0,0),new n(8193,0),new n(8193,8193),new n(0,8193),new n(0,0)]]};class pf{constructor(t,e,i,r,n){this.tileID=t,this.uid=b(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;e<H.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=ld(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,e,i){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Bd){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Bd&&e.hasRTLText){this.hasRTLText=!0,Io.isLoading()||Io.isLoaded()||"deferred"!==ko()||Ao();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new Ss}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Xd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Xd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Xd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Xr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let e=0;e<o.length;e++){const r=o.feature(e);if(s.needGeometry){const t=$a(r,!0);if(!s.filter(new Po(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!s.filter(new Po(this.tileID.overscaledZ),r))continue;const h=i.getId(r,n),p=new ef(r,a,l,c,h);p.tile=u,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=R(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length||!e)return;const i=this.latestFeatureIndex.loadVTLayers(),r=e.style.listImages();for(const n in this.buckets){if(!e.style.hasLayer(n))continue;const o=this.buckets[n],s=o.layers[0].sourceLayer||"_geojsonTileLayer",a=i[s],l=t[s];if(!a||!l||0===Object.keys(l).length)continue;if(o.update(l,a,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof Bu||o instanceof Qc){const t=e.style._getSourceCache(o.layers[0].source);e._terrain&&e._terrain.enabled&&t&&o.programConfigurations.needsUpload&&e._terrain._clearRenderCacheForTile(t.id,this.tileID)}const c=e&&e.style&&e.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<H.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=H.now()+t}setTexture(t,e){const i=e.context,r=i.gl;this.texture=e.getTileTexture(t.width),this.texture?this.texture.update(t,{useMipmap:!0}):(this.texture=new Xd(i,t,r.RGBA,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax))}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,e){if(!e||"mercator"===e.name||this._tileDebugBuffer)return;const i=Ua(hf,this.tileID.canonical,this.tileTransform)[0],r=new Jo,n=new ws;for(let t=0;t<i.length;t++){const{x:e,y:o}=i[t];r.emplaceBack(e,o),n.emplaceBack(t)}n.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,Op.members),this._tileDebugSegments=xa.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(t,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const i=Ua(hf,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const t=function(t,e){const i=ld(t,e),r=Math.pow(2,t.z);for(let n=0;n<nf;n++)for(let o=0;o<nf;o++){const s=Ia((t.x+(o+cf(o))/rf)/r),a=Pa((t.y+(n+cf(n))/rf)/r),l=e.project(s,a),c=n*nf+o;sf[2*c+0]=Math.round((l.x*i.scale-i.x)*ba),sf[2*c+1]=Math.round((l.y*i.scale-i.y)*ba)}af.fill(0),lf.fill(0);for(let t=2045;t>=0;t--){const e=4*t,i=of[e+0],r=of[e+1],n=of[e+2],o=of[e+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,u=r*nf+i,h=o*nf+n,p=a*nf+s,d=Math.hypot((sf[2*u+0]+sf[2*h+0])/2-sf[2*p+0],(sf[2*u+1]+sf[2*h+1])/2-sf[2*p+1])>=16;if(af[p]=af[p]||(d?1:0),t<1022){const t=(r+c>>1)*nf+(i+l>>1),e=(o+c>>1)*nf+(n+l>>1);af[p]=af[p]||af[t]||af[e]}}const n=new ts,o=new fs;let s=0;function a(t,e){const i=e*nf+t;return 0===lf[i]&&(n.emplaceBack(sf[2*i+0],sf[2*i+1],t*ba/rf,e*ba/rf),lf[i]=++s),lf[i]-1}function l(t,e,i,r,n,s){const c=t+i>>1,u=e+r>>1;if(Math.abs(t-n)+Math.abs(e-s)>1&&af[u*nf+c])l(n,s,t,e,c,u),l(i,r,n,s,c,u);else{const l=a(t,e),c=a(i,r),u=a(n,s);o.emplaceBack(l,c,u)}}return l(0,0,rf,rf,rf,0),l(rf,rf,0,0,0,rf),{vertices:n,indices:o}}(this.tileID.canonical,e);r=t.vertices,n=t.indices}else{r=new ts,n=new fs;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=fc(r.int16,void 0,4);for(let e=0;e<t.length;e+=3)n.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(r,uf.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(n),this._tileBoundsSegments=xa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(t,e){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!e||"globe"!==e.name)return;const i=this.tileID.canonical,r=Kp(Zp(i));this._makeGlobeTileDebugBorderBuffer(t,i,r),this._makeGlobeTileDebugTextBuffer(t,i,r)}_makeGlobeTileDebugBorderBuffer(t,e,i){const r=new Jo,n=new ws,o=new Ko,s=(t,s,a,l,c)=>{const u=(a-t)/(c-1),h=(l-s)/(c-1),p=r.length;for(let a=0;a<c;a++){const l=t+a*u,c=s+a*h;r.emplaceBack(l,c);const d=Yp(l,c,e),f=Ol(d,d,i);o.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(p+a)}},a=ba;s(0,0,a,0,16),s(a,0,a,a,16),s(a,a,0,a,16),s(0,a,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,Op.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(o,Rp.members),this._tileDebugSegments=xa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugTextBuffer(t,e,i){const r=new Jo,n=new fs,o=new Ko,s=25;n.reserve(32),r.reserve(s),o.reserve(s);const a=(t,e)=>s*t+e;for(let t=0;t<s;t++){const n=2048*t;for(let t=0;t<s;t++){const s=2048*t;r.emplaceBack(s,n);const a=Yp(s,n,e),l=Ol(a,a,i);o.emplaceBack(l[0],l[1],l[2])}}for(let t=0;t<4;t++)for(let e=0;e<4;e++){const i=a(t,e),r=a(t,e+1),o=a(t+1,e),s=a(t+1,e+1);n.emplaceBack(i,r,o),n.emplaceBack(o,r,s)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(n),this._tileDebugTextBuffer=t.createVertexBuffer(r,Op.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(o,Rp.members),this._tileDebugTextSegments=xa.simpleSegment(0,0,s,32)}}class df{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},v(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=v({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),v(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},v(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class ff{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function mf(t,e,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<t[s]||i[s]>e[s])return null}else{const a=1/r[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function _f(t,e,i,r,n,o,s,a,l,c,u){const h=r-t,p=n-e,d=o-i,f=s-t,m=a-e,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,v=u[0]*m-u[1]*f,x=h*g+p*y+d*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-t,T=c[1]-e,M=c[2]-i,E=(w*g+T*y+M*v)*b;if(E<0||E>1)return null;const C=T*d-M*p,S=M*h-w*d,k=w*p-T*h,A=(u[0]*C+u[1]*S+u[2]*k)*b;return A<0||E+A>1?null:(f*C+m*S+_*k)*b}function gf(t,e,i){return(t-e)/(i-e)}function yf(t,e,i,r,n,o,s,a,l){const c=1<<i,u=o-r,h=s-n,p=(t+1)/c*u+r,d=(e+0)/c*h+n,f=(e+1)/c*h+n;a[0]=(t+0)/c*u+r,a[1]=d,l[0]=p,l[1]=f}class vf{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),i=[];let r=Math.ceil(Math.pow(2,e));const n=1/r,o=(t,e,i,r,n)=>{const o=r?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;n[0]=t*i,n[1]=a,n[2]=s,n[3]=l};let s=new ff(r);const a=[];for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),n,!1,a);const i=bf(a[0],a[1],t),l=bf(a[2],a[1],t),c=bf(a[2],a[3],t),u=bf(a[0],a[3],t);s.minimums.push(Math.min(i,l,c,u)),s.maximums.push(Math.max(i,l,c,u)),s.leaves.push(1)}for(i.push(s),r/=2;r>=1;r/=2){const t=i[i.length-1];s=new ff(r);for(let e=0;e<r*r;e++){o(e%r,Math.floor(e/r),2,!0,a);const i=t.getElevation(a[0],a[1]),n=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),c=t.getElevation(a[0],a[3]),u=t.isLeaf(a[0],a[1]),h=t.isLeaf(a[2],a[1]),p=t.isLeaf(a[2],a[3]),d=t.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=u&&h&&p&&d;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0)}i.push(s)}return i}(this.dem),i=e.length-1,r=e[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(e,0,0,i,0)}raycastRoot(t,e,i,r,n,o,s=1){return mf([t,e,-100],[i,r,this.maximums[0]*s],n,o)}raycast(t,e,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,i,r,n,o,s);if(null==a)return null;const l=[],c=[],u=[],h=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){yf(f,m,_,t,e,i,r,u,h);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=bf(l,p,this.dem)*s,v=bf(c,p,this.dem)*s,x=bf(c,g,this.dem)*s,b=bf(l,g,this.dem)*s,w=_f(u[0],u[1],y,h[0],u[1],v,h[0],h[1],x,n,o),T=_f(h[0],h[1],x,u[0],h[1],b,u[0],u[1],y,n,o),M=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(M!==Number.MAX_VALUE)return M;{const t=Ll([],n,o,d);if(xf(y,v,b,x,gf(t[0],u[0],h[0]),gf(t[1],u[1],h[1]))>=t[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){yf((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,t,e,i,r,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+p]*s;const d=mf(u,h,n,o);if(null!=d){const t=d;l[p]=t;let e=!1;for(let i=0;i<g&&!e;i++)t>=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[g]=p),g++}}for(let t=0;t<g;t++){const e=c[t];p.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:_+1})}}return null}_addNode(t,e,i){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,i,r,n){if(1===t[r].isLeaf(e,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=t[o];let a=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const r=2*e+this._siblingOffset[t][0],n=2*i+this._siblingOffset[t][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),u=this._addNode(o.min,o.max,c);c&&(a|=1<<t),l||(l=u)}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(t,2*e+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r)}}function xf(t,e,i,r,n,o){return gi(gi(t,i,o),gi(e,r,o),n)}function bf(t,e,i){const r=i.dim,n=f(t*r-.5,0,r-1),o=f(e*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return xf(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const wf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Tf{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,i,r=!1,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return P(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const o=this.dim=e.height-2,s=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let t=0;t<o;t++)s[this._idx(-1,t)]=s[this._idx(0,t)],s[this._idx(o,t)]=s[this._idx(o-1,t)],s[this._idx(t,-1)]=s[this._idx(t,0)],s[this._idx(t,o)]=s[this._idx(t,o-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(o,-1)]=s[this._idx(o-1,0)],s[this._idx(-1,o)]=s[this._idx(0,o-1)],s[this._idx(o,o)]=s[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new vf(this)}get(t,e,i=!1){i&&(t=f(t,-1,this.dim),e=f(e,-1,this.dim));const r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(t){return wf[t]}get unpackVector(){return wf[this.encoding]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Tf.getUnpackVector(e);let n=Math.floor((t+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new lc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e<s;e++)for(let i=r;i<n;i++){const r=4*this._idx(i,e),n=4*this._idx(i+a,e+l);this.pixels[r+0]=t.pixels[n+0],this.pixels[r+1]=t.pixels[n+1],this.pixels[r+2]=t.pixels[n+2],this.pixels[r+3]=t.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Pn(Tf,"DEMData"),Pn(vf,"DemMinMaxQuadTree",{omit:["dem"]});class Mf{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Ef{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Ef.ReadOnly=!1,Ef.ReadWrite=!0,Ef.disabled=new Ef(519,Ef.ReadOnly,[0,1]);const Cf=7680;class Sf{constructor(t,e,i,r,n,o){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Sf.disabled=new Sf({func:519,mask:0},0,0,Cf,Cf,Cf);class kf{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}kf.Replace=[1,0],kf.disabled=new kf(kf.Replace,ge.transparent,[!1,!1,!1,!1]),kf.unblended=new kf(kf.Replace,ge.transparent,[!0,!0,!0,!0]),kf.alphaBlended=new kf([1,771],ge.transparent,[!0,!0,!0,!0]);const Af=1029,If=2305;class Pf{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}Pf.disabled=new Pf(!1,Af,If),Pf.backCCW=new Pf(!0,Af,If),Pf.backCW=new Pf(!0,Af,2304),Pf.frontCW=new Pf(!0,1028,2304),Pf.frontCCW=new Pf(!0,1028,If);class Lf extends $t{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Mf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new df,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const e in this._tiles){const i=this._tiles[e];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(t),i.prepare(this.map.style.imageManager)}else for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return y(this._tiles).map((t=>t.tileID)).sort(zf).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,o=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(zf).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new Ut(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=H.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Vt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Cu(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=this._updateRetainedTiles(r);if(Df(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=H.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Lf.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[r]=i}const o=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(n[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&e[r.key]){n[t]=i.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e])}for(const t in n)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,n);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),n=t[0].overscaledZ,o=Math.max(n-Lf.maxOverzooming,this._source.minzoom),s=Math.max(n+Lf.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,s,e);for(const r of t){let t=this._tiles[r.key];if(t.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let n=t.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t&&(e[o.key]=o,n=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return this._source.prepareTile&&this._source.prepareTile(e),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null;e=new pf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(e)||this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Vt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,s=Sa(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(f(s,...Rf(t,-1))-s),Math.abs(f(s,...Rf(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(f(s,...Rf(t,-1))-s),Math.abs(f(s,...Rf(t,0))-s),Math.abs(f(s,...Rf(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,n,e,i);o&&r.push(o)}}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Df(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=H.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}g(Array.from(i.values()),((t,e)=>{const i=new pf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function zf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Df(t){return"raster"===t||"image"===t||"video"===t}function Rf(t,e){const i=1<<t.z;return[t.x/i+e,(t.x+1)/i+e]}Lf.maxOverzooming=10,Lf.maxUnderzooming=3;class Of{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const r=i||t.findDEMTileFor(e);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<e.canonical.z-o.canonical.z;return new Of(r,r.tileSize/ba/s,[(e.canonical.x/s-o.canonical.x)*n.dim,(e.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(t,e){const i=e*this._scale+this._offset[1],r=Math.floor(t*this._scale+this._offset[0]),o=Math.floor(i);return new n(r,o)}getElevationAt(t,e,i,r){const n=t*this._scale+this._offset[0],o=e*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?gi(gi(l.get(s,a,r),l.get(s,a+1,r),o-a),gi(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(t,e,i){return this._dem.get(t,e,!!i)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Aa(1,t)*this._dem.stride}}class Ff{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new kn(ba,16,0),this.featureIndexArray=new Rs,this.promoteId=e}insert(t,e,i,r,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const a=this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<ba&&r[1]<ba&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hu.VectorTile(new lh(this.rawTileData)).layers,this.sourceLayerCoder=new Kd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},o=Xr(n.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>rl(s.bufferedTilespaceGeometry,t,e,i,r)));c.sort(jf);let u=null;a.elevation&&c.length>0&&(u=Of.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a<c.length;a++){const l=c[a];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,d,o,n.layers,n.availableImages,e,i,r,((e,i,r,n=0)=>(f||(f=Ua(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,r,f,this.z,t.transform,t.pixelPosMatrix,u,n))))}return h}loadMatchingFeature(t,e,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[u];if(r&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=$a(m,!0);if(!i.filter(new Po(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Po(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e<d.length;e++){const i=d[e];if(r&&r.indexOf(i)<0)continue;const u=o[i];if(!u)continue;let h={};void 0!==_&&a&&(h=a.getState(u.sourceLayer||"_geojsonTileLayer",_));const f=v({},s[i]);f.paint=Bf(f.paint,u.paint,m,h,n),f.layout=Bf(f.layout,u.layout,m,h,n);const g=!l||l(m,u,h,p);if(!g)continue;const y=new ef(m,this.z,this.x,this.y,_);y.layer=f;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=Xr(n);for(const n of t)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,e);return l}loadFeature(t){const{featureIndex:e,sourceLayerIndex:i}=t;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[e])return n[e];const o=this.vtLayers[r].feature(e);return n[e]=o,o}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}}function Bf(t,e,i,r,n){return S(t,((t,o)=>{const s=e instanceof jo?e.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function jf(t,e){return e-t}Pn(Ff,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Nf{constructor(t){const e={},i=[];for(const r in t){const n=t[r],o=e[r]={};for(const t in n.glyphs){const e=n.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,s={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(s),o[t]=s}}const{w:r,h:n}=Ph(i),o=new ac({width:r||1,height:n||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const n=r.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=e[i][t],a=n.metrics.localGlyph?2:1;ac.copy(n.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},n.bitmap)}}this.image=o,this.positions=e}}Pn(Nf,"GlyphAtlas");class Vf{constructor(t){this.tileID=new Cu(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=ld(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,e,i,r,n){this.status="parsing",this.data=t,this.collisionBoxArray=new Ss;const o=new Kd(Object.keys(t.layers).sort()),s=new Ff(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Qd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=e.familiesBySource[this.source];for(const e in u){const r=t.layers[e];if(!r)continue;let n=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?n=!0:l=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&P(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=o.encode(e),p=[];for(let t=0;t<r.length;t++){const i=r.feature(t),n=s.getId(i,e);p.push({feature:i,id:n,index:t,sourceLayerIndex:h})}for(const t of u[e]){const e=t[0];void 0!==this.isSymbolTile&&"symbol"===e.type!==this.isSymbolTile||e.minzoom&&this.zoom<Math.floor(e.minzoom)||e.maxzoom&&this.zoom>=e.maxzoom||"none"!==e.visibility&&(Uf(t,this.zoom,i),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=S(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{h||(h=t,p=e,x.call(this))}),void 0,!1,m):p={};const g=Object.keys(c.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{h||(h=t,d=e,x.call(this))}),void 0,!1,m):d={};const v=Object.keys(c.patternDependencies);function x(){if(h)return n(h);if(p&&d&&f){const t=new Nf(p),e=new zh(d,f);for(const r in a){const n=a[r];n instanceof Bd?(Uf(n.layers,this.zoom,i),Mp(n,p,t.positions,d,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):n.hasPattern&&(n instanceof Bu||n instanceof Qc||n instanceof yu)&&(Uf(n.layers,this.zoom,i),n.addFeatures(c,this.tileID.canonical,e.patternPositions,i,this.tileTransform))}this.status="done",n(null,{buckets:y(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?t.positions:null})}}v.length?r.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{h||(h=t,f=e,x.call(this))}),void 0,!1,m):f={},x.call(this)}}function Uf(t,e,i){const r=new Po(e);for(const e of t)e.recalculate(r,i)}class $f{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){const[t,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const t of n.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((t=>t!==r)),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function Gf(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=Pt(t.request,((t,r,n,o)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new hu.VectorTile(new lh(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),e()}}),e)}t.ARRAY_TYPE=pl,t.AUTH_ERR_MSG=rt,t.Aabb=Yl,t.Actor=class{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},E(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=D()?t:e,this.scheduler=new Jd}send(t,e,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=F(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Dn(e,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||D()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Rn(e.error)):i(null,Rn(e.data)))}else{const i=F(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Dn(e):null,data:Dn(r,i)},i)}:t=>{},n=Rn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,n,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],n.source)[t[1]](n,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=Mu,t.Color=ge,t.ColorMode=kf,t.CullFaceMode=Pf,t.DEMData=Tf,t.DataConstantProperty=No,t.DedupedRequest=$f,t.DepthMode=Ef,t.EXTENT=ba,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<<i,n=Math.floor(t.x),o=Math.floor((t.x-n)*r),s=Math.floor(t.y*r),a=this.findDEMTileFor(new Cu(i,n,i,o,s));return!(!a||!a.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const r=this._source();if(!r)return e;if(t.y<0||t.y>1)return e;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(t.x),a=t.x-s,l=new Cu(n,s,n,Math.floor(a*o),Math.floor(t.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return e;const u=c.dem,h=1<<c.tileID.canonical.z,p=(a*h-c.tileID.canonical.x)*u.dim,d=(t.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*gi(gi(u.get(f,m),u.get(f,m+1),d-m),gi(u.get(f+1,m),u.get(f+1,m+1),d-m),p-f)}getAtTileOffset(t,e,i){const r=1<<t.canonical.z;return this.getAtPointOrZero(new Da(t.wrap+(t.canonical.x+e/ba)/r,(t.canonical.y+i/ba)/r))}getAtTileOffsetFunc(t,e,i,r){return n=>{const o=this.getAtTileOffset(t,n.x,n.y),s=r.upVector(t.canonical,n.x,n.y);return Pl(s,s,o*r.upVectorScale(t.canonical,e,i).metersToTile),s}}getForTilePoints(t,e,i,r){const n=Of.create(this,t,r);return!!n&&(e.forEach((t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<<t.canonical.z-r.canonical.z;let o=t.canonical.x/n-r.canonical.x,s=t.canonical.y/n-r.canonical.y,a=0;for(let e=0;e<t.canonical.z-r.canonical.z&&!i.leaves[a];e++){o*=2,s*=2;const t=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+t,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},t.ErrorEvent=Ut,t.EvaluationParameters=Po,t.Event=Vt,t.Evented=$t,t.FillExtrusionBucket=yu,t.Frustum=Ql,t.FrustumCorners=Xl,t.GLOBE_METERS_TO_ECEF=Bp,t.GLOBE_RADIUS=Fp,t.GLOBE_SCALE_MATCH_LATITUDE=45,t.GLOBE_ZOOM_THRESHOLD_MAX=6,t.GLOBE_ZOOM_THRESHOLD_MIN=5,t.GlobeSharedBuffers=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const t of this._wireframeSegments)t.destroy()}}_createGrid(t){const e=new Jo,i=new fs,r=65;for(let t=0;t<r;t++)for(let i=0;i<r;i++)e.emplaceBack(i,t);this._gridSegments=[];for(let t=0,e=0;t<jp.length;t++){const n=jp[t];for(let t=0;t<n;t++)for(let e=0;e<64;e++){const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)}const o=64*n*2;this._gridSegments.push(xa.simpleSegment(0,e,(n+1)*r,o)),e+=o}this._gridBuffer=t.createVertexBuffer(e,Op.members),this._gridIndexBuffer=t.createIndexBuffer(i,!0)}_createPoles(t){const e=new fs;for(let t=0;t<=64;t++)e.emplaceBack(0,t+1,t+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new ys,r=new ys;this._poleSegments=[];for(let t=0,e=0;t<5;t++){const n=1<<t,o=512*n/Math.PI/2,s=360/n;i.emplaceBack(0,-o,0,0,0,.5,0),r.emplaceBack(0,-o,0,0,0,.5,1);for(let t=0;t<=64;t++){const e=t/64,n=gi(0,s,e),[a,l,c]=Xp(od,sd,n,o);i.emplaceBack(a,l,c,0,0,e,0),r.emplaceBack(a,l,c,0,0,e,1)}this._poleSegments.push(xa.simpleSegment(e,0,66,64)),e+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(i,Dp,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(r,Dp,!1)}getGridBuffers(t){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments[t]]}getPoleBuffers(t){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}getWirefameBuffers(t,e){if(!this._wireframeSegments){const e=new bs,i=64,r=i+1;this._wireframeSegments=[];for(let t=0,n=0;t<jp.length;t++){const o=jp[t];for(let t=0;t<o;t++)for(let n=0;n<i;n++){const i=t*r+n;e.emplaceBack(i,i+1),e.emplaceBack(i,i+r),e.emplaceBack(i,i+r+1)}const s=o*i*3;this._wireframeSegments.push(xa.simpleSegment(0,n,(o+1)*r,s)),n+=s}this._wireframeIndexBuffer=t.createIndexBuffer(e)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[e]]}},t.GlyphManager=cp,t.ImagePosition=Lh,t.LineAtlas=Qd,t.LngLat=Ma,t.LngLatBounds=wa,t.LocalGlyphMode=lp,t.MAX_MERCATOR_LATITUDE=za,t.MercatorCoordinate=Da,t.ONE_EM=Qu,t.OverscaledTileID=Cu,t.Properties=qo,t.RGBAImage=lc,t.Ray=Wl,t.RequestManager=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",it,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!nt(t))return t;const i=at(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!nt(t))return t;const i=at(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,r){if(!nt(t))return t;const n=at(t);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const n=at(t);return nt(t)?(n.path=`/styles/v1${n.path}/sprite${e}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${e}${i}`,lt(n))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!nt(t))return t;const r=at(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Q.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${X.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${X.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||X.ACCESS_TOKEN;return X.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,e){const i=at(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${X.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${X.TILE_URL_VERSION}/`,"")}`;let n=i.params;return e&&(n=n.filter((t=>!t.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&nt(e),r=[];for(const e of t.tiles||[])ot(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=at(X.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!X.REQUIRE_ACCESS_TOKEN)return lt(t);if(e=e||X.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),lt(t)}},t.ResourceType=St,t.SegmentVector=xa,t.SourceCache=Lf,t.StencilMode=Sf,t.StructArrayLayout1ui2=ws,t.StructArrayLayout2f1f2i16=hs,t.StructArrayLayout2i4=Jo,t.StructArrayLayout2ui4=bs,t.StructArrayLayout3f12=ds,t.StructArrayLayout3ui6=fs,t.StructArrayLayout4i8=ts,t.StructArrayLayout5f20=vs,t.Texture=Xd,t.Tile=pf,t.Transitionable=Do,t.Uniform1f=Ys,t.Uniform1i=class extends Qs{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends Qs{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends Qs{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=Js,t.UniformColor=Ks,t.UniformMatrix2f=class extends Qs{constructor(t,e){super(t,e),this.current=ia}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},t.UniformMatrix3f=class extends Qs{constructor(t,e){super(t,e),this.current=ea}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},t.UniformMatrix4f=class extends Qs{constructor(t,e){super(t,e),this.current=ta}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=Eu,t.ValidationError=Nr,t.VectorTileWorkerSource=class extends $t{constructor(t,e,i,r,n){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=n||Gf,this.loading={},this.loaded={},this.deduped=new $f(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Vf(t);o.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),e(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new hu.VectorTile(new lh(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const o={};if(n){const t=V(r);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,v({rawTileData:c.slice(0)},i,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(t,e){const i=this.loaded,r=t.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain,o.projection=t.projection,o.tileTransform=ld(t.tileID.canonical,t.projection);const s=(t,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),e(t,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(t,e){const i=t.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}},t.WritingMode=Dh,t.ZoomHistory=On,t.add=Cl,t.addDynamicAttributes=Dd,t.adjoint=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=n*c-r*u,t[2]=r*a-n*s,t[3]=a*l-o*u,t[4]=i*u-n*l,t[5]=n*o-i*a,t[6]=o*c-s*l,t[7]=r*l-i*c,t[8]=i*s-r*o,t},t.asyncAll=g,t.bezier=p,t.bindAll=E,t.boundsAttributes=uf,t.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=_(r-1,-1,t.length-1),o=_(r+1,-1,t.length-1),s=t[r],a=t[o],l=t[n].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*e/Math.sin(u/2));i.push(s.add(h))}return i},t.cacheEntryPossiblyAdded=function(t){Ct++,Ct>xt&&(t.getActor().send("enforceCacheSizeLimit",vt),Ct=0)},t.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:r}=t.point,n=ed(i,r,t.worldSize/t._projectionScaler,0,0);return ml(n,n,td(Zp(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:r,lat:n}=t._center;return ed(e,i,t.worldSize,r,n)},t.calculateGlobeMercatorMatrix=function(t){const e=t.worldSize,i=t.point,r=Aa(1,t.center.lat)*e,n=t.pixelsPerMeter,o=e/(r/t.pixelsPerMeter),s=fl(new Float64Array(16));return _l(s,s,[i.x,i.y,0]),gl(s,s,[o,o,n]),Float32Array.from(s)},t.circumferenceAtLatitude=Ca,t.clamp=f,t.clearTileCache=function(t){const i=[];for(const t in bt)i.push(e.caches.delete(t)),delete bt[t];t&&Promise.all(i).catch(t).then((()=>t()))},t.clipLine=np,t.clone=function(t){var e=new pl(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=A,t.collisionCircleLayout=Xu,t.config=X,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new pl(16);return pl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=dl,t.createExpression=Dr,t.createLayout=Qo,t.createStyleLayer=function(t){return"custom"===t.type?new qd(t):new Wd[t.type](t)},t.cross=Rl,t.degToRad=l,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},t.dot=Dl,t.ease=d,t.easeCubicInOut=h,t.emitValidationErrors=Sn,t.endsWith=C,t.enforceCacheSizeLimit=function(t){for(const e in bt)Tt(e),bt[e].then((e=>{e.keys().then((i=>{for(let r=0;r<i.length-t;r++)e.delete(i[r])}))}))},t.evaluateSizeForFeature=Ku,t.evaluateSizeForZoom=th,t.evaluateVariableOffset=Tp,t.evented=So,t.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},t.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},t.exported=H,t.exported$1=Q,t.extend=v,t.extend$1=qt,t.fillExtrusionHeightLift=xu,t.filterObject=k,t.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},t.fromQuat=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=i+i,a=r+r,l=n+n,c=i*s,u=r*s,h=r*a,p=n*s,d=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return t[0]=1-h-f,t[1]=u+g,t[2]=p-_,t[3]=0,t[4]=u-g,t[5]=1-c-f,t[6]=d+m,t[7]=0,t[8]=p+_,t[9]=d-m,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.fromRotation=function(t,e){var i=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.furthestTileCorner=function(t){const e=Math.round((t+45+360)%360/90)%4;return u[e]},t.getAABBPointSquareDist=function(t,e,i){let r=0;for(let n=0;n<2;++n){const o=i?i[n]:0;t[n]>o&&(r+=(t[n]-o)*(t[n]-o)),e[n]<o&&(r+=(o-e[n])*(o-e[n]))}return r},t.getAnchorAlignment=Zh,t.getAnchorJustification=Ep,t.getBounds=function(t){let e=1/0,i=1/0,r=-1/0,o=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),o=Math.max(o,n.y);return{min:new n(e,i),max:new n(r,o)}},t.getColumn=j,t.getGridMatrix=function(t,e,i){const[r,n]=e,o=.015625;return[0,(n[1]-r[1])*o,1<<t.z,(n[0]-r[0])/jp[i],0,t.y,r[0],r[1],o]},t.getImage=Bt,t.getJSON=function(t,e){return It(v(t,{type:"json"}),e)},t.getLatitudinalLod=function(t){const e=80.051129;t=f(t,-80.051129,e)/e*90;const i=Math.pow(Math.abs(Math.sin(l(t))),3);return Math.round(i*(jp.length-1))},t.getMapSessionAPI=_t,t.getPerformanceMeasurement=V,t.getProjection=Ad,t.getRTLTextPluginStatus=ko,t.getReferrer=At,t.getTilePoint=function(t,{x:e,y:i},r=0){return new n(((e-r)*t.scale-t.x)*ba,(i*t.scale-t.y)*ba)},t.getTileVec3=function(t,e,i=0){return El(((e.x-i)*t.scale-t.x)*ba,(e.y*t.scale-t.y)*ba,La(e.z,e.y))},t.getVideo=function(t,i){const r=e.document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r)};for(let i=0;i<t.length;i++){const n=e.document.createElement("source");Dt(t[i])||(r.crossOrigin="Anonymous"),n.src=t[i],r.appendChild(n)}return{cancel:()=>{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=fl(new Float64Array(16));return ml(i,t.pixelMatrix,t.globeMatrix),Ol(e,e,i),new n(e[0],e[1])},t.globeECEFOrigin=function(t,e){const i=[0,0,0];return Ol(i,i,Kp(Zp(e.canonical))),Ol(i,i,t),i},t.globeNormalizeECEF=Kp,t.globePixelsToTileUnits=function(t,e){return ba/(512*Math.pow(2,t))*Jp(Zp(e))},t.globePoleMatrixForTile=function(t,e,i){const r=fl(new Float64Array(16)),n=1<<t,o=360*(e/n-.5),s=i.point,a=i.worldSize/(i.tileSize*n);return _l(r,r,[s.x,s.y,-i.worldSize/Math.PI/2]),gl(r,r,[a,a,a]),yl(r,r,l(-i._center.lat)),vl(r,r,l(-i._center.lng+o)),Float32Array.from(r)},t.globeTileBounds=Zp,t.globeTileLatLngCorners=Wp,t.globeTiltAtLngLat=rd,t.globeToMercatorTransition=id,t.globeUseCustomAntiAliasing=function(t,e,i){const r=id(i.zoom),n=t.style.map._antialias,o=!!e.extStandardDerivatives,s=e.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===r&&!n&&!s&&o},t.identity=fl,t.identity$1=ql,t.invert=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*s,v=i*l-n*s,x=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,M=u*m-h*f,E=u*_-p*f,C=u*g-d*f,S=h*_-p*m,k=h*g-d*m,A=p*g-d*_,I=y*A-v*k+x*S+b*C-w*E+T*M;return I?(t[0]=(a*A-l*k+c*S)*(I=1/I),t[1]=(n*k-r*A-o*S)*I,t[2]=(m*T-_*w+g*b)*I,t[3]=(p*w-h*T-d*b)*I,t[4]=(l*C-s*A-c*E)*I,t[5]=(i*A-n*C+o*E)*I,t[6]=(_*x-f*T-g*v)*I,t[7]=(u*T-p*x+d*v)*I,t[8]=(s*k-a*C+c*M)*I,t[9]=(r*C-i*k-o*M)*I,t[10]=(f*w-m*x+g*y)*I,t[11]=(h*x-u*w-d*y)*I,t[12]=(a*E-s*S-l*M)*I,t[13]=(i*S-r*E+n*M)*I,t[14]=(m*v-f*b-_*y)*I,t[15]=(u*b-h*v+p*y)*I,t):null},t.isLngLatBehindGlobe=function(t,e){return rd(t,e)>Math.PI/2*1.01},t.isMapAuthenticated=function(t){return gt.has(t)},t.isMapboxURL=nt,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!F(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Pa,t.len=Vl,t.length=Ml,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=Gf,t.makeRequest=It,t.mapValue=function(t,e,i,r,n){return f((t-e)/(i-e)*(n-r)+r,r,n)},t.mercatorXfromLng=Sa,t.mercatorYfromLat=ka,t.mercatorZfromAltitude=Aa,t.mul=bl,t.mul$1=Nl,t.multiply=ml,t.multiply$1=function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],v=i[7],x=i[8];return t[0]=p*r+d*s+f*c,t[1]=p*n+d*a+f*u,t[2]=p*o+d*l+f*h,t[3]=m*r+_*s+g*c,t[4]=m*n+_*a+g*u,t[5]=m*o+_*l+g*h,t[6]=y*r+v*s+x*c,t[7]=y*n+v*a+x*u,t[8]=y*o+v*l+x*h,t},t.multiply$2=kl,t.nextPowerOfTwo=T,t.normalize=zl,t.normalize$1=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=r*s,t[2]=n*s,t[3]=o*s,t},t.number=gi,t.ortho=function(t,e,i,r,n,o,s){var a=1/(e-i),l=1/(r-n),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(s+o)*c,t[15]=1,t},t.pbf=lh,t.perspective=function(t,e,i,r,n){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(o=1/(r-n)),t[14]=2*n*r*o):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i},t.plugin=Io,t.pointGeometry=n,t.polygonContainsPoint=il,t.polygonIntersectsBox=rl,t.polygonIntersectsPolygon=Ha,t.polygonizeBounds=function(t,e,i=0,r=!0){const o=new n(i,i),s=t.sub(o),a=e.add(o),l=[s,new n(a.x,s.y),a,new n(s.x,a.y)];return r&&l.push(s.clone()),l},t.posAttributes=Op,t.postMapLoadEvent=ft,t.postTurnstileEvent=pt,t.potpack=Ph,t.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.radToDeg=c,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.registerForPluginStateChange=function(t){return t({pluginStatus:To,pluginURL:Mo}),So.on("pluginStateChange",t),t},t.removeAuthState=function(t){gt.delete(t)},t.renderColorRamp=uc,t.resample=Oa,t.rotateX=yl,t.rotateX$1=Zl,t.rotateY=vl,t.rotateY$1=Hl,t.rotateZ=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],u=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+c*r,t[1]=s*n+u*r,t[2]=a*n+h*r,t[3]=l*n+p*r,t[4]=c*n-o*r,t[5]=u*n-s*r,t[6]=h*n-a*r,t[7]=p*n-l*r,t},t.rotateZ$1=function(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+n*a,t[1]=n*l-r*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},t.scale=gl,t.scale$1=Ul,t.scale$2=Pl,t.scaleAndAdd=Ll,t.setCacheLimits=function(t,e){vt=t,xt=e},t.setColumn=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},t.setRTLTextPlugin=function(t,e,i=!1){if(To===vo||To===xo||To===bo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Mo=H.resolveURL(t),To=vo,wo=e,Co(),i||Ao()},t.smoothstep=m,t.spec=Gt,t.storeAuthState=function(t,e){e?gt.add(t):gt.delete(t)},t.sub=jl,t.subtract=Sl,t.symbolSize=eh,t.tileAABB=function(t,e,i,r,n,o,s,a,l){if("globe"===l.name)return Hp(t,e,new Mu(i,r,n));const c=ld({z:i,x:r,y:n},l);return new Yl([(o+c.x/c.scale)*e,e*(c.y/c.scale),s],[(o+c.x2/c.scale)*e,e*(c.y2/c.scale),a])},t.tileTransform=ld,t.transformMat3=function(t,e,i){var r=e[0],n=e[1],o=e[2];return t[0]=r*i[0]+n*i[3]+o*i[6],t[1]=r*i[1]+n*i[4]+o*i[7],t[2]=r*i[2]+n*i[5]+o*i[8],t},t.transformMat4=Ol,t.transformMat4$1=$l,t.transformQuat=Fl,t.translate=_l,t.transpose=function(t,e){if(t===e){var i=e[1],r=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=r,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},t.triggerPluginCompletionEvent=Eo,t.uniqueId=b,t.updateGlobeVertexNormal=function(t,e,i,r,n){const o=5*e+2;t.float32[o+0]=i,t.float32[o+1]=r,t.float32[o+2]=n},t.validateCustomStyleLayer=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateFilter=t=>Cn(ln(t)),t.validateFog=t=>Cn(vn(t)),t.validateLayer=t=>Cn(dn(t)),t.validateLight=t=>Cn(gn(t)),t.validateSource=t=>Cn(_n(t)),t.validateStyle=Tn,t.validateTerrain=t=>Cn(yn(t)),t.values=y,t.vectorTile=hu,t.version=U,t.warnOnce=P,t.window=e,t.wrap=_}));r(0,(function(t){function e(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const r of t)i+=`${e(r)},`;return`${i}]`}let i="{";for(const r of Object.keys(t).sort())i+=`${r}:${e(t[r])},`;return`${i}}`}function i(i){let r="";for(const n of t.refProperties)r+=`/${e(i[n])}`;return r}class r{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=function(t,e){const r={};for(let n=0;n<t.length;n++){const o=e&&e[t[n].id]||i(t[n]);e&&(e[t[n].id]=o);let s=r[o];s||(s=r[o]=[]),s.push(t[n])}const n=[];for(const t in r)n.push(r[t]);return n}(t.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(e)}}}class n{loadTile(e,i){const{uid:r,encoding:n,rawImageData:o,padding:s,buildQuadTree:a}=e,l=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap?this.getImageData(o,s):o;i(null,new t.DEMData(r,l,n,s<1,a))}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const i=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}var o=function t(e,i){var r,n=e&&e.type;if("FeatureCollection"===n)for(r=0;r<e.features.length;r++)t(e.features[r],i);else if("GeometryCollection"===n)for(r=0;r<e.geometries.length;r++)t(e.geometries[r],i);else if("Feature"===n)t(e.geometry,i);else if("Polygon"===n)s(e.coordinates,i);else if("MultiPolygon"===n)for(r=0;r<e.coordinates.length;r++)s(e.coordinates[r],i);return e};function s(t,e){if(0!==t.length){a(t[0],e);for(var i=1;i<t.length;i++)a(t[i],!e)}}function a(t,e){for(var i=0,r=0,n=0,o=t.length,s=o-1;n<o;s=n++){var a=(t[n][0]-t[s][0])*(t[s][1]+t[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const l=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return l.call(this,t,e,i)}}class u{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new c(this._features[t])}}var h=t.vectorTile.VectorTileFeature,p=d;function d(t,e){this.options=e||{},this.features=t,this.length=t.length}function f(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}d.prototype.feature=function(t){return new f(this.features[t],this.options.extent)},f.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i<e.length;i++){for(var r=e[i],n=[],o=0;o<r.length;o++)n.push(new t.pointGeometry(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},f.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var t=this.geometry,e=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<t.length;o++)for(var s=t[o],a=0;a<s.length;a++){var l=s[a];e=Math.min(e,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[e,r,i,n]},f.prototype.toGeoJSON=h.prototype.toGeoJSON;var m=g,_=p;function g(e){var i=new t.pbf;return function(t,e){for(var i in t.layers)e.writeMessage(3,y,t.layers[i])}(e,i),i.finish()}function y(t,e){var i;e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<t.length;i++)r.feature=t.feature(i),e.writeMessage(2,v,r);var n=r.keys;for(i=0;i<n.length;i++)e.writeStringField(3,n[i]);var o=r.values;for(i=0;i<o.length;i++)e.writeMessage(4,M,o[i])}function v(t,e){var i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,x,t),e.writeVarintField(3,i.type),e.writeMessage(4,T,i)}function x(t,e){var i=t.feature,r=t.keys,n=t.values,o=t.keycache,s=t.valuecache;for(var a in i.properties){var l=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),o[a]=c=r.length-1),e.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,p=s[h];void 0===p&&(n.push(l),s[h]=p=n.length-1),e.writeVarint(p)}}}function b(t,e){return(e<<3)+(7&t)}function w(t){return t<<1^t>>31}function T(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,s=i.length,a=0;a<s;a++){var l=i[a],c=1;1===r&&(c=l.length),e.writeVarint(b(1,c));for(var u=3===r?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==r&&e.writeVarint(b(2,u-1));var p=l[h].x-n,d=l[h].y-o;e.writeVarint(w(p)),e.writeVarint(w(d)),n+=p,o+=d}3===r&&e.writeVarint(b(7,1))}}function M(t,e){var i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}function E(t,e,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;C(t,e,s,r,n,o%2),E(t,e,i,r,s-1,o+1),E(t,e,i,s+1,n,o+1)}function C(t,e,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);C(t,e,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(n,Math.floor(i+(s-a)*c/s+u)),o)}const s=e[2*i+o];let a=r,l=n;for(S(t,e,r,i),e[2*n+o]>s&&S(t,e,r,n);a<l;){for(S(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*r+o]===s?S(t,e,r,l):(l++,S(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function S(t,e,i,r){k(t,i,r),k(e,2*i,2*r),k(e,2*i+1,2*r+1)}function k(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function A(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}m.fromVectorTileJs=g,m.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new p(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return g({layers:i})},m.GeoJSONWrapper=_;const I=t=>t[0],P=t=>t[1];class L{constructor(t,e=I,i=P,r=64,n=Float64Array){this.nodeSize=r,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(t.length),a=this.coords=new n(2*t.length);for(let r=0;r<t.length;r++)s[r]=r,a[2*r]=e(t[r]),a[2*r+1]=i(t[r]);E(s,a,r,0,s.length-1,0)}range(t,e,i,r){return function(t,e,i,r,n,o,s){const a=[0,t.length-1,0],l=[];let c,u;for(;a.length;){const h=a.pop(),p=a.pop(),d=a.pop();if(p-d<=s){for(let s=d;s<=p;s++)c=e[2*s],u=e[2*s+1],c>=i&&c<=n&&u>=r&&u<=o&&l.push(t[s]);continue}const f=Math.floor((d+p)/2);c=e[2*f],u=e[2*f+1],c>=i&&c<=n&&u>=r&&u<=o&&l.push(t[f]);const m=(h+1)%2;(0===h?i<=c:r<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?n>=c:o>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,n,o){const s=[0,t.length-1,0],a=[],l=n*n;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=o){for(let n=h;n<=u;n++)A(e[2*n],e[2*n+1],i,r)<=l&&a.push(t[n]);continue}const p=Math.floor((h+u)/2),d=e[2*p],f=e[2*p+1];A(d,f,i,r)<=l&&a.push(t[p]);const m=(c+1)%2;(0===c?i-n<=d:r-n<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?i+n>=d:r+n>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,t,e,i,this.nodeSize)}}const z={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},D=Math.fround||(R=new Float32Array(1),t=>(R[0]=+t,R[0]));var R;class O{constructor(t){this.options=G(Object.create(z),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:n}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;let s=[];for(let e=0;e<t.length;e++)t[e].geometry&&s.push(B(t[e],e));this.trees[r+1]=new L(s,q,Z,n,Float32Array),e&&console.timeEnd(o);for(let t=r;t>=i;t--){const i=+Date.now();s=this._cluster(s,t),this.trees[t]=new L(s,q,Z,n,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,s.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,o],e),s=this.getClusters([-180,r,n,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(V(i),U(o),V(n),U(r)),l=[];for(const t of a){const e=s.points[t];l.push(e.numPoints?j(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[e];if(!o)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o.x,o.y,s),l=[];for(const e of a){const i=n.points[e];i.parentId===t&&l.push(i.numPoints?j(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,u={features:[]};return this._addTileFeatures(r.range((e-a)/n,l,(e+1+a)/n,c),r.points,e,i,n,u),0===e&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.points,n,i,n,u),e===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.points,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(t,o.cluster_id,i,r,n):n<r?n++:t.push(e),t.length===i)break}return n}_addTileFeatures(t,e,i,r,n,o){for(const s of t){const t=e[s],a=t.numPoints;let l,c,u;if(a)l=N(t),c=t.x,u=t.y;else{const e=this.points[t.index];l=e.properties,c=V(e.geometry.coordinates[0]),u=U(e.geometry.coordinates[1])}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let p;a?p=t.id:this.options.generateId?p=t.index:this.points[t.index].id&&(p=this.points[t.index].id),void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(+t,this.options.maxZoom+1))}_cluster(t,e){const i=[],{radius:r,extent:n,reduce:o,minPoints:s}=this.options,a=r/(n*Math.pow(2,e));for(let r=0;r<t.length;r++){const n=t[r];if(n.zoom<=e)continue;n.zoom=e;const l=this.trees[e+1],c=l.within(n.x,n.y,a),u=n.numPoints||1;let h=u;for(const t of c){const i=l.points[t];i.zoom>e&&(h+=i.numPoints||1)}if(h>u&&h>=s){let t=n.x*u,s=n.y*u,a=o&&u>1?this._map(n,!0):null;const p=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,s+=r.y*c,r.parentId=p,o&&(a||(a=this._map(n,!0)),o(a,this._map(r)))}n.parentId=p,i.push(F(t/h,s/h,p,h,a))}else if(i.push(n),h>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?G({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?G({},r):r}}function F(t,e,i,r,n){return{x:D(t),y:D(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function B(t,e){const[i,r]=t.geometry.coordinates;return{x:D(V(i)),y:D(U(r)),zoom:1/0,index:e,parentId:-1}}function j(t){return{type:"Feature",id:t.id,properties:N(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),$(t.y)]}};var e}function N(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return G(G({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function V(t){return t/360+.5}function U(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function $(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function G(t,e){for(const i in e)t[i]=e[i];return t}function q(t){return t.x}function Z(t){return t.y}function H(t,e,i,r){for(var n,o=r,s=i-e>>1,a=i-e,l=t[e],c=t[e+1],u=t[i],h=t[i+1],p=e+3;p<i;p+=3){var d=W(t[p],t[p+1],l,c,u,h);if(d>o)n=p,o=d;else if(d===o){var f=Math.abs(p-s);f<a&&(n=p,a=f)}}o>r&&(n-e>3&&H(t,e,n,r),t[n+2]=o,i-n>3&&H(t,n,i,r))}function W(t,e,i,r,n,o){var s=n-i,a=o-r;if(0!==s||0!==a){var l=((t-i)*s+(e-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return(s=t-i)*s+(a=e-r)*a}function X(t,e,i,r){var n={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)Q(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r<e.length;r++)Q(t,e[r]);else if("MultiPolygon"===i)for(r=0;r<e.length;r++)for(var n=0;n<e[r].length;n++)Q(t,e[r][n])}(n),n}function Q(t,e){for(var i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function Y(t,e,i,r){if(e.geometry){var n=e.geometry.coordinates,o=e.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),a=[],l=e.id;if(i.promoteId?l=e.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)J(n,a);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)J(n[c],a);else if("LineString"===o)K(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<n.length;c++)K(n[c],a=[],s,!1),t.push(X(l,"LineString",a,e.properties));return}tt(n,a,s,!1)}else if("Polygon"===o)tt(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<e.geometry.geometries.length;c++)Y(t,{id:l,geometry:e.geometry.geometries[c],properties:e.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var u=[];tt(n[c],u,s,!0),a.push(u)}}t.push(X(l,o,a,e.properties))}}function J(t,e){e.push(et(t[0])),e.push(it(t[1])),e.push(0)}function K(t,e,i,r){for(var n,o,s=0,a=0;a<t.length;a++){var l=et(t[a][0]),c=it(t[a][1]);e.push(l),e.push(c),e.push(0),a>0&&(s+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var u=e.length-3;e[2]=1,H(e,0,u,i),e[u+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function tt(t,e,i,r){for(var n=0;n<t.length;n++){var o=[];K(t[n],o,i,r),e.push(o)}}function et(t){return t/360+.5}function it(t){var e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function rt(t,e,i,r,n,o,s,a){if(r/=e,o>=(i/=e)&&s<r)return t;if(s<i||o>=r)return null;for(var l=[],c=0;c<t.length;c++){var u=t[c],h=u.geometry,p=u.type,d=0===n?u.minX:u.minY,f=0===n?u.maxX:u.maxY;if(d>=i&&f<r)l.push(u);else if(!(f<i||d>=r)){var m=[];if("Point"===p||"MultiPoint"===p)nt(h,m,i,r,n);else if("LineString"===p)ot(h,m,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===p)at(h,m,i,r,n,!1);else if("Polygon"===p)at(h,m,i,r,n,!0);else if("MultiPolygon"===p)for(var _=0;_<h.length;_++){var g=[];at(h[_],g,i,r,n,!0),g.length&&m.push(g)}if(m.length){if(a.lineMetrics&&"LineString"===p){for(_=0;_<m.length;_++)l.push(X(u.id,p,m[_],u.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===m.length?(p="LineString",m=m[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===m.length?"Point":"MultiPoint"),l.push(X(u.id,p,m,u.tags))}}}return l.length?l:null}function nt(t,e,i,r,n){for(var o=0;o<t.length;o+=3){var s=t[o+n];s>=i&&s<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function ot(t,e,i,r,n,o,s){for(var a,l,c=st(t),u=0===n?ct:ut,h=t.start,p=0;p<t.length-3;p+=3){var d=t[p],f=t[p+1],m=t[p+2],_=t[p+3],g=t[p+4],y=0===n?d:f,v=0===n?_:g,x=!1;s&&(a=Math.sqrt(Math.pow(d-_,2)+Math.pow(f-g,2))),y<i?v>i&&(l=u(c,d,f,_,g,i),s&&(c.start=h+a*l)):y>r?v<r&&(l=u(c,d,f,_,g,r),s&&(c.start=h+a*l)):lt(c,d,f,m),v<i&&y>=i&&(l=u(c,d,f,_,g,i),x=!0),v>r&&y<=r&&(l=u(c,d,f,_,g,r),x=!0),!o&&x&&(s&&(c.end=h+a*l),e.push(c),c=st(t)),s&&(h+=a)}var b=t.length-3;d=t[b],f=t[b+1],m=t[b+2],(y=0===n?d:f)>=i&&y<=r&&lt(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&lt(c,c[0],c[1],c[2]),c.length&&e.push(c)}function st(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,i,r,n,o){for(var s=0;s<t.length;s++)ot(t[s],e,i,r,n,o,!1)}function lt(t,e,i,r){t.push(e),t.push(i),t.push(r)}function ct(t,e,i,r,n,o){var s=(o-e)/(r-e);return t.push(o),t.push(i+(n-i)*s),t.push(1),s}function ut(t,e,i,r,n,o){var s=(o-i)/(n-i);return t.push(e+(r-e)*s),t.push(o),t.push(1),s}function ht(t,e){for(var i=[],r=0;r<t.length;r++){var n,o=t[r],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=pt(o.geometry,e);else if("MultiLineString"===s||"Polygon"===s){n=[];for(var a=0;a<o.geometry.length;a++)n.push(pt(o.geometry[a],e))}else if("MultiPolygon"===s)for(n=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(pt(o.geometry[a][c],e));n.push(l)}i.push(X(o.id,s,n,o.tags))}return i}function pt(t,e){var i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(var r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function dt(t,e){if(t.transformed)return t;var i,r,n,o=1<<t.z,s=t.x,a=t.y;for(i=0;i<t.features.length;i++){var l=t.features[i],c=l.geometry,u=l.type;if(l.geometry=[],1===u)for(r=0;r<c.length;r+=2)l.geometry.push(ft(c[r],c[r+1],e,o,s,a));else for(r=0;r<c.length;r++){var h=[];for(n=0;n<c[r].length;n+=2)h.push(ft(c[r][n],c[r][n+1],e,o,s,a));l.geometry.push(h)}}return t.transformed=!0,t}function ft(t,e,i,r,n,o){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-o))]}function mt(t,e,i,r,n){for(var o=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<t.length;a++){s.numFeatures++,_t(s,t[a],o,n);var l=t[a].minX,c=t[a].minY,u=t[a].maxX,h=t[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function _t(t,e,i,r){var n=e.geometry,o=e.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)gt(s,n,t,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)gt(s,n[a],t,i,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)gt(s,c[a],t,i,!0,0===a)}if(s.length){var u=e.tags||null;if("LineString"===o&&r.lineMetrics){for(var h in u={},e.tags)u[h]=e.tags[h];u.mapbox_clip_start=n.start/n.size,u.mapbox_clip_end=n.end/n.size}var p={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==e.id&&(p.id=e.id),t.features.push(p)}}function gt(t,e,i,r,n,o){var s=r*r;if(r>0&&e.size<(n?s:r))i.numPoints+=e.length/3;else{for(var a=[],l=0;l<e.length;l+=3)(0===r||e[l+2]>s)&&(i.numSimplified++,a.push(e[l]),a.push(e[l+1])),i.numPoints++;n&&function(t,e){for(var i=0,r=0,n=t.length,o=n-2;r<n;o=r,r+=2)i+=(t[r]-t[o])*(t[r+1]+t[o+1]);if(i>0===e)for(r=0,n=t.length;r<n/2;r+=2){var s=t[r],a=t[r+1];t[r]=t[n-2-r],t[r+1]=t[n-1-r],t[n-2-r]=s,t[n-1-r]=a}}(a,o),t.push(a)}}function yt(t,e){var i=(e=this.options=function(t,e){for(var i in e)t[i]=e[i];return t}(Object.create(this.options),e)).debug;if(i&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)Y(i,t.features[r],e,r);else Y(i,"Feature"===t.type?t:{geometry:t},e);return i}(t,e);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(r=function(t,e){var i=e.buffer/e.extent,r=t,n=rt(t,1,-1-i,i,0,-1,2,e),o=rt(t,1,1-i,2+i,0,-1,2,e);return(n||o)&&(r=rt(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=ht(n,1).concat(r)),o&&(r=r.concat(ht(o,-1)))),r}(r,e)).length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function vt(t,e,i){return 32*((1<<t)*i+e)+t}function xt(t,e){const i=t.tileID.canonical;if(!this._geoJSONIndex)return e(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return e(null,null);const n=new u(r.features);let o=m(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),e(null,{vectorTile:n,rawData:o.buffer})}yt.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},yt.prototype.splitTile=function(t,e,i,r,n,o,s){for(var a=[t,e,i,r],l=this.options,c=l.debug;a.length;){r=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();var u=1<<e,h=vt(e,i,r),p=this.tiles[h];if(!p&&(c>1&&console.time("creation"),p=this.tiles[h]=mt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,n){if(e===l.maxZoom||e===n)continue;var f=1<<n-e;if(i!==Math.floor(o/f)||r!==Math.floor(s/f))continue}else if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==t.length){c>1&&console.time("clipping");var m,_,g,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,M=1+b;m=_=g=y=null,v=rt(t,u,i-b,i+T,0,p.minX,p.maxX,l),x=rt(t,u,i+w,i+M,0,p.minX,p.maxX,l),t=null,v&&(m=rt(v,u,r-b,r+T,1,p.minY,p.maxY,l),_=rt(v,u,r+w,r+M,1,p.minY,p.maxY,l),v=null),x&&(g=rt(x,u,r-b,r+T,1,p.minY,p.maxY,l),y=rt(x,u,r+w,r+M,1,p.minY,p.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(m||[],e+1,2*i,2*r),a.push(_||[],e+1,2*i,2*r+1),a.push(g||[],e+1,2*i+1,2*r),a.push(y||[],e+1,2*i+1,2*r+1)}}},yt.prototype.getTile=function(t,e,i){var r=this.options,n=r.extent,o=r.debug;if(t<0||t>24)return null;var s=1<<t,a=vt(t,e=(e%s+s)%s,i);if(this.tiles[a])return dt(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,u=e,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[vt(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?dt(this.tiles[a],n):null):null};class bt extends t.VectorTileWorkerSource{constructor(t,e,i,r,n){super(t,e,i,r,xt),n&&(this.loadGeoJSON=n)}loadData(e,i){const r=e&&e.request,n=r&&r.collectResourceTiming;this.loadGeoJSON(e,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{o(a,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=a.features.filter((t=>i.value.evaluate({zoom:0},t)));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new O(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[o,s]=i[e],a=t.createExpression(s),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);r[e]=a.value,n[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(o,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)o.accumulated=t[e],t[e]=n[e].evaluate(o,s)},e}(e)).load(a.features):function(t,e){return new yt(t,e)}(a,e.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(n){const i=t.getPerformanceMeasurement(r);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class wt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:bt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(t,e,i){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],i()}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded[e]=i;for(const r in this.workerSources[e]){const n=this.workerSources[e][r];for(const e in n)n[e]instanceof t.VectorTileWorkerSource&&(n[e].isSpriteLoaded=i,n[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const r=this.workerSources[t][i];for(const t in r)r[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setProjection(e,i){this.projections[e]=t.getProjection(i)}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,r){const n=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;n.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).loadTile(n,r)}loadDEMTile(e,i,r){const n=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(n,r)}reloadTile(e,i,r){const n=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;n.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).reloadTile(n,r)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][i]||(this.workerSources[t][e][i]=new this.workerSourceTypes[e]({send:(e,i,r,n,o,s)=>{this.actor.send(e,i,r,t,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])),this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new n),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new wt(self)),wt}));r(0,(function(t){function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],i[r]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(t).length!==Object.keys(i).length)return!1;for(const r in t)if(!e(t[r],i[r]))return!1;return!0}return t===i}var i=r;function r(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===n[e=t&&t.failIfMajorPerformanceCaveat]&&(n[e]=function(t){var e,i=function(t){var e=document.createElement("canvas"),i=Object.create(r.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=t,e.getContext("webgl",i)||e.getContext("experimental-webgl",i)}(t);if(!i)return!1;try{e=i.createShader(i.VERTEX_SHADER)}catch(t){return!1}return!(!e||i.isContextLost())&&(i.shaderSource(e,"void main() {}"),i.compileShader(e),!0===i.getShaderParameter(e,i.COMPILE_STATUS))}(e)),n[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var n={};function o(e,i,r){const n=t.window.document.createElement(e);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n}function s(e,i,r){const n=t.window.document.createElementNS("http://www.w3.org/2000/svg",e);for(const t of Object.keys(i))n.setAttributeNS(null,t,i[t]);return r&&r.appendChild(n),n}r.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a=t.window.document&&t.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function p(e){e.preventDefault(),e.stopPropagation(),t.window.removeEventListener("click",p,!0)}function d(){t.window.addEventListener("click",p,!0),t.window.setTimeout((()=>{t.window.removeEventListener("click",p,!0)}),0)}function f(t,e){const i=t.getBoundingClientRect();return g(t,i,e)}function m(t,e){const i=t.getBoundingClientRect(),r=[];for(let n=0;n<e.length;n++)r.push(g(t,i,e[n]));return r}function _(e){return void 0!==t.window.InstallTrigger&&2===e.button&&e.ctrlKey&&t.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function g(e,i,r){const n=e.offsetWidth===i.width?1:e.offsetWidth/i.width;return new t.pointGeometry((r.clientX-i.left)*n,(r.clientY-i.top)*n)}function y(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],s=i*o-n*r;return s?(t[0]=o*(s=1/s),t[1]=-r*s,t[2]=-n*s,t[3]=i*s,t):null}function v(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class x extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(e,i){const r={};for(const i of e){this.images[i]||this.fire(new t.Event("styleimagemissing",{id:i}));const e=this.images[i];e?r[i]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.warnOnce(`Image "${i}" 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.`)}i(null,r)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new t.ImagePosition(i,r);this.patterns[e]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.Texture(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.potpack(e),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,o=i.y+1,s=this.images[e].data,a=s.width,l=s.height;t.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),t.RGBAImage.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),t.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),t.RGBAImage.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),t.RGBAImage.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];v(t)&&this.updateImage(e,t)}}}const b=new t.Properties({anchor:new t.DataConstantProperty(t.spec.light.anchor),position:new class{constructor(){this.specification=t.spec.light.position}possiblyEvaluate(e,i){return function([e,i,r]){const n=t.degToRad(i+90),o=t.degToRad(r);return{x:e*Math.cos(n)*Math.sin(o),y:e*Math.sin(n)*Math.sin(o),z:e*Math.cos(o),azimuthal:i,polar:r}}(e.expression.evaluate(i))}interpolate(e,i,r){return{x:t.number(e.x,i.x,r),y:t.number(e.y,i.y,r),z:t.number(e.z,i.z,r),azimuthal:t.number(e.azimuthal,i.azimuthal,r),polar:t.number(e.polar,i.polar,r)}}},color:new t.DataConstantProperty(t.spec.light.color),intensity:new t.DataConstantProperty(t.spec.light.intensity)}),w="-transition";class T extends t.Evented{constructor(e){super(),this._transitionable=new t.Transitionable(b),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.validateLight,e,i))for(const i in e){const r=e[i];t.endsWith(i,w)?this._transitionable.setTransition(i.slice(0,-w.length),r):this._transitionable.setValue(i,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}const M=new t.Properties({source:new t.DataConstantProperty(t.spec.terrain.source),exaggeration:new t.DataConstantProperty(t.spec.terrain.exaggeration)}),E="-transition";class C extends t.Evented{constructor(e,i){super(),this._transitionable=new t.Transitionable(M),this.set(e),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i}get(){return this._transitionable.serialize()}set(e){for(const i in e){const r=e[i];t.endsWith(i,E)?this._transitionable.setTransition(i.slice(0,-E.length),r):this._transitionable.setValue(i,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}}function S(e,i,r,n){const o=t.smoothstep(45,65,r),[s,a]=k(e,n),l=t.length(i);let c=1-Math.min(1,Math.exp((l-s)/(a-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*o*e.alpha}function k(t,e){const i=.5/Math.tan(.5*e);return[t.range[0]+i,t.range[1]+i]}const A=new t.Properties({range:new t.DataConstantProperty(t.spec.fog.range),color:new t.DataConstantProperty(t.spec.fog.color),"high-color":new t.DataConstantProperty(t.spec.fog["high-color"]),"space-color":new t.DataConstantProperty(t.spec.fog["space-color"]),"horizon-blend":new t.DataConstantProperty(t.spec.fog["horizon-blend"]),"star-intensity":new t.DataConstantProperty(t.spec.fog["star-intensity"])}),I="-transition";class P extends t.Evented{constructor(e,i){super(),this._transitionable=new t.Transitionable(A),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=i}get state(){const e=this._transform,i="globe"===e.projection.name,r=t.globeToMercatorTransition(e.zoom),n=this.properties.get("range"),o=[.5,3];return{range:i?[t.number(o[0],n[0],r),t.number(o[1],n[1],r)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,i={}){if(!this._validate(t.validateFog,e,i)){for(const i of Object.keys(t.spec.fog))e&&void 0===e[i]&&(e[i]=t.spec.fog[i].default);for(const i in e){const r=e[i];t.endsWith(i,I)?this._transitionable.setTransition(i.slice(0,-I.length),r):this._transitionable.setValue(i,r)}}}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:t.smoothstep(45,65,e))*i.a}getOpacityAtLatLng(e,i){return this._transform.projection.supportsFog?function(e,i,r){const n=t.MercatorCoordinate.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0,s=[n.x,n.y,o];return t.transformMat4(s,s,r.mercatorFogMatrix),S(e,s,r.pitch,r._fov)}(this.state,e,i):0}getFovAdjustedRange(t){return this._transform.projection.supportsFog?k(this.state,t):[0,1]}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.emitValidationErrors(this,e.call(t.validateStyle,t.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}class L{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t.uniqueId();const r=this.workerPool.acquire(this.id);for(let t=0;t<r.length;t++){const e=new L.Actor(r[t],i,this.id);e.name=`Worker ${t}`,this.actors.push(e)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,i,r){t.asyncAll(this.actors,((t,r)=>{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function z(e,i,r){return i*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}L.Actor=t.Actor;class D{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,i){let r,n;if(e instanceof t.pointGeometry||"number"==typeof e[0]){const o=t.pointGeometry.convert(e);r=[t.pointGeometry.convert(e)],n=i.isPointAboveHorizon(o)}else{const o=t.pointGeometry.convert(e[0]),s=t.pointGeometry.convert(e[1]);r=[o,s],n=t.polygonizeBounds(o,s).every((t=>i.isPointAboveHorizon(t)))}return new D(r,i.getCameraPoint(),n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],n=t.polygonizeBounds(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<r.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),t.bufferConvexPolygon(n,e)}bufferedCameraGeometryGlobe(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],n=t.polygonizeBounds(i,r,e),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>r.y))+((o.x>i.x)+(o.x>r.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(e,i,r,n=0){const o=e.queryPadding/i._projectionScaler+1,s=r?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=e.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((i=>t.getTilePoint(e.tileTransform,i,a)));if(!t.polygonIntersectsBox(l,0,0,t.EXTENT,t.EXTENT))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((i=>t.getTileVec3(e.tileTransform,i,a))),u=c.map((e=>new t.pointGeometry(e[0],e[1]))),h=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),p=t.getTileVec3(e.tileTransform,h,a),d=c.map((e=>{const i=t.sub(e,e,p);return t.normalize(i,i),new t.Ray(p,i)})),f=z(e,1,i.zoom)*i._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=t.getBounds(l),m.min.x=t.clamp(m.min.x,0,t.EXTENT),m.min.y=t.clamp(m.min.y,0,t.EXTENT),m.max.x=t.clamp(m.max.x,0,t.EXTENT),m.max.y=t.clamp(m.max.y,0,t.EXTENT),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(t,e){const i=F(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),e):{polygon:this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=F(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),e):{polygon:this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,i){const r=function(e,i){const r=t.multiply([],i.pixelMatrix,i.globeMatrix),n=[0,-t.GLOBE_RADIUS,0,1],o=[0,t.GLOBE_RADIUS,0,1],s=[0,0,0,1];t.transformMat4$1(n,n,r),t.transformMat4$1(o,o,r),t.transformMat4$1(s,s,r);const a=new t.pointGeometry(n[0]/n[3],n[1]/n[3]),l=new t.pointGeometry(o[0]/o[3],o[1]/o[3]),c=t.polygonContainsPoint(e,a)&&n[3]<s[3],u=t.polygonContainsPoint(e,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(t,e,i){for(let r=1;r<t.length;r++){const n=O(e.pointCoordinate3D(t[r-1]).x),o=O(e.pointCoordinate3D(t[r]).x);if(i<0){if(n<o)return{idx:r,t:-n/(o-1-n)}}else if(o<n)return{idx:r,t:(1-n)/(o+1-n)}}return null}(e,i,c?-1:1);if(!h)return null;const{idx:p,t:d}=h;let f=p>1?R(e.slice(0,p),i):[],m=p<e.length?R(e.slice(p),i):[];f=f.map((e=>new t.pointGeometry(O(e.x),e.y))),m=m.map((e=>new t.pointGeometry(O(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=t.number(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new t.pointGeometry(0,g),new t.pointGeometry(0,0),new t.pointGeometry(1,0),new t.pointGeometry(1,g)]:[new t.pointGeometry(1,g),new t.pointGeometry(1,1),new t.pointGeometry(0,1),new t.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,i);if(r)return r;const n=function(e,i){let r=!1,n=-1/0,o=0;for(let t=0;t<e.length-1;t++)e[t].x>n&&(n=e[t].x,o=t);for(let t=0;t<e.length-1;t++){const i=(o+t)%(e.length-1),n=e[i],s=e[i+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===i&&(e[e.length-1].x+=1)):(s.x+=1,i+1===e.length-1&&(e[0].x+=1)),r=!0)}const s=t.mercatorXfromLng(i.center.lng);return r&&s<Math.abs(s-1)&&e.forEach((t=>{t.x-=1})),{polygon:e,unwrapped:r}}(R(e,i).map((e=>new t.pointGeometry(O(e.x),e.y))),i);return{polygon:n.polygon.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:n.unwrapped}}}function R(e,i){return t.resample(e,(t=>{const e=i.pointCoordinate3D(t);t.x=e.x,t.y=e.y}),1/256)}function O(t){return t<0?1+t%1:t%1}function F(t){return 100*t|0}function B(e,i,r,n,o){const s=function(r,n){if(r)return o(r);if(n){const r=t.pick(t.extend(n,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(r.vectorLayers=n.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),n.language_options&&(r.languageOptions=n.language_options),n.language&&n.language[n.id]&&(r.language=n.language[n.id]),n.worldview_options&&(r.worldviewOptions=n.worldview_options),n.worldview?r.worldview=n.worldview[n.id]:n.worldview_default&&(r.worldview=n.worldview_default),r.tiles=i.canonicalizeTileset(r,e.url),o(null,r)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url,null,r,n),t.ResourceType.Source),s):t.exported.frame((()=>s(null,e)))}class j{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),n=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x<o&&e.y>=n&&e.y<s}}class N{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const V={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class U{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=e.attributes[n.name];void 0!==o&&t.vertexAttribPointer(o,n.components,t[V[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ${constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class G extends ${getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class q extends ${getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Z extends ${getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class H extends ${getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class W extends ${getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class X extends ${getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Q extends ${getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Y extends ${getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class J extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class K extends ${getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class tt extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class et extends ${getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class it extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class rt extends ${getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class nt extends ${getDefault(){return t.Color.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class ot extends ${getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class st extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class at extends ${getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class lt extends ${getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class ct extends ${getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class ut extends ${getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ht extends ${getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class pt extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class dt extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class ft extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class mt extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class _t extends ${getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class gt extends ${constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class yt extends ${getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class vt extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class xt extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class bt extends ${constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class wt extends bt{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Tt extends bt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,this.attachment(),e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Mt extends Tt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Et{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const n=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new wt(t,n),r&&(this.depthAttachment=new Tt(t,n))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class Ct{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new G(this),this.clearDepth=new q(this),this.clearStencil=new Z(this),this.colorMask=new H(this),this.depthMask=new W(this),this.stencilMask=new X(this),this.stencilFunc=new Q(this),this.stencilOp=new Y(this),this.stencilTest=new J(this),this.depthRange=new K(this),this.depthTest=new tt(this),this.depthFunc=new et(this),this.blend=new it(this),this.blendFunc=new rt(this),this.blendColor=new nt(this),this.blendEquation=new ot(this),this.cullFace=new st(this),this.cullFaceSide=new at(this),this.frontFace=new lt(this),this.program=new ct(this),this.activeTexture=new ut(this),this.viewport=new ht(this),this.bindFramebuffer=new pt(this),this.bindRenderbuffer=new dt(this),this.bindTexture=new ft(this),this.bindVertexBuffer=new mt(this),this.bindElementBuffer=new _t(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new gt(this),this.pixelStoreUnpack=new yt(this),this.pixelStoreUnpackPremultiplyAlpha=new vt(this),this.pixelStoreUnpackFlipY=new xt(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=t.getExtension("OES_standard_derivatives"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new N(this,t,e)}createVertexBuffer(t,e,i){return new U(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i){return new Et(this,t,e,i)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(i){e(i.blendFunction,t.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor)),this.colorMask.set(i.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class St extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},i),t.extend(this,t.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=B(this._options,this.map._requestManager,null,null,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new j(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=t.exported.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(n,t.ResourceType.Tile),((r,n,o,s)=>(delete e.request,e.aborted?(e.state="unloaded",i(null)):r?(e.state="errored",i(r)):n?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:o,expires:s}),e.setTexture(n,this.map.painter),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))))}static loadTileData(t,e,i){t.setTexture(e,i)}static unloadTileData(t,e){t.texture&&e.saveTileTexture(t.texture)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let kt;function At(e,i,r,n,o,s,a,l){const c=[e,r,o,i,n,s,1,1,1],u=[a,l,1],h=t.adjoint([],c),[p,d,f]=t.transformMat3(u,u,t.transpose(h,h));return t.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class It extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=i||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((i,r)=>{if(this._loaded=!0,i)this.fire(new t.ErrorEvent(i));else if(r){const{HTMLImageElement:i}=t.window;this.image=r instanceof i?t.exported.getImageData(r):r,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const i=e.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),o=Math.max(o,t.y);const s=Math.max(n-i,o-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((i+n)/2*l),Math.floor((r+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const i=t.tileTransform(this.tileID,this.map.transform.projection),[r,n,o,s]=this.coordinates.map((e=>{const r=i.projection.project(e[0],e[1]);return t.getTilePoint(i,r)._round()}));this.perspectiveTransform=function(e,i,r,n,o,s,a,l,c,u){const h=At(0,0,e,0,0,i,e,i),p=At(r,n,o,s,a,l,c,u);return t.multiply$1(p,t.adjoint(h,h),p),[p[6]/p[8]*e/t.EXTENT,p[7]/p[8]*i/t.EXTENT]}(this.width,this.height,r.x,r.y,n.x,n.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new t.StructArrayLayout4i8;a.emplaceBack(r.x,r.y,0,0),a.emplaceBack(n.x,n.y,t.EXTENT,0),a.emplaceBack(s.x,s.y,0,t.EXTENT),a.emplaceBack(o.x,o.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture?this.texture.update(this.image):(this.texture=new t.Texture(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Pt={vector:class extends t.Evented{constructor(e,i,r,n){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(i,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"}));const i=this.language||this.map._language,r=this.worldview||this.map._worldview;this._tileJSONRequest=B(this._options,this.map._requestManager,i,r,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new t.ErrorEvent(n))):o&&(t.extend(this,o),o.bounds&&(this.tileBounds=new j(o.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(n)}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load((()=>{const t=this.map.style._getSourceCaches(this.id);for(const e of t)e.clearTiles()}))}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}_setLanguage(t){return t===this.language||this.setSourceProperty((()=>{this.language=t})),this}_setWorldview(t){return t===this.worldview?this:this.worldviewOptions&&t&&!this.worldviewOptions[t]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${t}".`),this):(this.setSourceProperty((()=>{this.worldview=t})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(n.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",n,o.bind(this));else if(e.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const i=t.loadVectorTile.call({deduped:this._deduped},n,((t,i)=>{t||!i?o.call(this,t):(n.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);e.request={cancel:i}}function o(r,n){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:St,"raster-dem":class extends St{constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,o,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap&&(null==kt&&(kt=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),kt),r=1-(o.width-t.prevPowerOfTwo(o.width))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?o:t.exported.getImageData(o,r),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded"}},geojson:class extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=t.extend({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.EXTENT,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new t.Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(e.request=this.map._requestManager.transformRequest(t.exported.resolveURL(i),t.ResourceType.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,((e,i)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(e.resourceTiming=i.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,i){const r=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(r,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,n)=>(delete e.request,e.unloadVectorData(),e.aborted?i(null):t?i(t):(e.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends It{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:It,canvas:class extends It{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,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 t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new j(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:i,z:r}=t.canonical;return this._implementation.hasTile({x:e,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const{x:r,y:n,z:o}=e.tileID.canonical,s=new t.window.AbortController,a=this._implementation.loadTile({x:r,y:n,z:o},{signal:s.signal});if(!a)return this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null);a.cancel=()=>s.abort(),e.request=a.then(function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):r?function(e){return e instanceof t.window.ImageData||e instanceof t.window.ImageBitmap||e instanceof t.window.HTMLCanvasElement}(r)?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t))}))}loadTileData(t,e){St.loadTileData(t,e,this._map.painter)}unloadTileData(t){St.unloadTileData(t,this._map.painter)}prepareTile(t){if(!this._implementation.prepareTile)return null;const{x:e,y:i,z:r}=t.tileID.canonical,n=this._implementation.prepareTile({x:e,y:i,z:r});return n?(this.loadTileData(t,n),t.state="loaded",n):null}unloadTile(t,e){if(this.unloadTileData(t),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z})))}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Lt=function(e,i,r,n){const o=new Pt[i.type](e,i,r,n);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],o),o};function zt(e,i){const r=t.identity([]);return t.scale(r,r,[.5*e.width,.5*-e.height,1]),t.translate(r,r,[1,-1,0]),t.multiply(r,r,e.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}function Dt(t,e,i,r,n,o,s,a=!1){const l=t.tilesIn(r,s,a);l.sort(Ot);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,n,o,zt(t.transform,r.tile.tileID),a)});const u=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in t){const r=t[i],n=o[i]=o[i]||{},s=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in u)u[e].forEach((e=>{const i=e.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?t.getFeatureState(r["source-layer"],i.id):{})}));return u}function Rt(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const o=i[t],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,e))}return r}function Ot(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Ft(){return null!=uo.workerClass?new uo.workerClass:new t.window.Worker(uo.workerUrl)}const Bt="mapboxgl_preloaded_worker_pool";class jt{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<jt.workerCount;)this.workers.push(new Ft);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Bt]}numActive(){return Object.keys(this.active).length}}let Nt;function Vt(){return Nt||(Nt=new jt),Nt}function Ut(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function $t(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Ut(t[i],e[t[i].ref]));return t}jt.workerCount=2;const Gt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function qt(t,e,i){i.push({command:Gt.addSource,args:[t,e[t]]})}function Zt(t,e,i){e.push({command:Gt.removeSource,args:[t]}),i[t]=!0}function Ht(t,e,i,r){Zt(t,i,r),qt(t,e,i)}function Wt(t,i,r){let n;for(n in t[r])if(t[r].hasOwnProperty(n)&&"data"!==n&&!e(t[r][n],i[r][n]))return!1;for(n in i[r])if(i[r].hasOwnProperty(n)&&"data"!==n&&!e(t[r][n],i[r][n]))return!1;return!0}function Xt(t,i,r,n,o,s){let a;for(a in i=i||{},t=t||{})t.hasOwnProperty(a)&&(e(t[a],i[a])||r.push({command:s,args:[n,a,i[a],o]}));for(a in i)i.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(e(t[a],i[a])||r.push({command:s,args:[n,a,i[a],o]}))}function Qt(t){return t.id}function Yt(t,e){return t[e.id]=e,t}class Jt{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.clamp(e,0,1);let i=1,r=this._distances[i];const n=e*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,s=this._distances[o],a=r-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Kt{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(t,e,i,r,n,o){this.circleCells[n].push(o)}_query(t,e,i,r,n,o){if(i<0||t>this.width||r<0||e>this.height)return!n&&[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let t=0;t<this.boxKeys.length;t++)s.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];s.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}return o?s.filter(o):s}return this._forEachCell(t,e,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(t,e,i,r,n){const o=t-i,s=t+i,a=e-i,l=e+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(t,e,i,r,n){return this._query(t,e,i,r,!1,n)}hitTest(t,e,i,r,n){return this._query(t,e,i,r,!0,n)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(t<=n[c+2]&&e<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const t=n[u],e=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const t=this.circles;for(const e of h)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return o.push(!0),!0}}}_forEachCell(t,e,i,r,n,o,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,o,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,o){const s=r-t,a=n-e,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(s-n)/2,u=Math.abs(e-(n+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const te=Math.tan(85*Math.PI/180);function ee(e,i,r,n,o,s,a){const l=t.create();if(r)if("globe"===s.name){const e=t.calculateGlobeLabelMatrix(o,i);t.multiply(l,l,e)}else{const e=y([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],n||t.rotateZ(l,l,o.angle)}else t.multiply(l,o.labelPlaneMatrix,e);return l}function ie(t,e,i,r,n,o,s){const a=ee(t,e,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function re(e,i,r,n,o,s,a){if(r){if("globe"===s.name){const l=ee(e,i,r,n,o,s,a);return t.invert(l,l),t.multiply(l,e,l),l}{const i=t.clone(e),r=t.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],t.multiply(i,i,r),n||t.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function ne(e,i,r=0){const n=[e.x,e.y,r,1];r?t.transformMat4$1(n,n,i):ge(n,n,i);const o=n[3];return{point:[n[0]/o,n[1]/o,n[2]/o],signedDistanceFromCamera:o}}function oe(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const n=r[3];return{point:[r[0]/n,r[1]/n,r[2]/n],signedDistanceFromCamera:n}}function se(t,e){return Math.min(.5+t/e*.5,1.5)}function ae(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function le(e,i,r,n,o,s,a,l,c,u){const h=r.transform,p=n?e.textSizeData:e.iconSizeData,d=t.evaluateSizeForZoom(p,r.transform.zoom),f="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,v=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b=!1;for(let n=0;n<v.length;n++){const f=v.get(n);if(f.writingMode!==t.WritingMode.vertical||b||0!==n&&v.get(n-1).writingMode===t.WritingMode.horizontal||(b=!0),(f.hidden||f.writingMode===t.WritingMode.vertical)&&!b){_e(f.numGlyphs,_);continue}b=!1;const w=new t.pointGeometry(f.tileAnchorX,f.tileAnchorY),T=c?c(w):[0,0,0],M=h.projection.projectTilePoint(w.x,w.y,u.canonical),E=[M.x+T[0],M.y+T[1],M.z+T[2]],C=[...E,1];if(t.transformMat4$1(C,C,i),!ae(C,m)){_e(f.numGlyphs,_);continue}const S=se(r.transform.cameraToCenterDistance,C[3]),k=t.evaluateSizeForFeature(p,d,f),A=a?k/S:k*S,I=ne(new t.pointGeometry(E[0],E[1]),o,E[2]);if(I.signedDistanceFromCamera<=0){_e(f.numGlyphs,_);continue}let P={};const L=a?null:c,z=he(f,A,!1,l,i,o,s,e.glyphOffsetArray,y,_,g,I.point,w,P,x,L,h.projection,u,a);b=z.useVertical,L&&z.needsFlipping&&(P={}),(z.notEnoughRoom||b||z.needsFlipping&&he(f,A,!0,l,i,o,s,e.glyphOffsetArray,y,_,g,I.point,w,P,x,L,h.projection,u,a).notEnoughRoom)&&_e(f.numGlyphs,_)}n?(e.text.dynamicLayoutVertexBuffer.updateData(_),g&&e.text.globeExtVertexBuffer.updateData(g)):(e.icon.dynamicLayoutVertexBuffer.updateData(_),g&&e.icon.globeExtVertexBuffer.updateData(g))}function ce(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m){const _=a.glyphStartIndex+a.numGlyphs,g=a.lineStartIndex,y=a.lineStartIndex+a.lineLength,v=e.getoffsetX(a.glyphStartIndex),x=e.getoffsetX(_-1),b=fe(t*v,i,r,n,o,s,a.segment,g,y,l,c,u,h,p,!0,d,f,m);if(!b)return null;const w=fe(t*x,i,r,n,o,s,a.segment,g,y,l,c,u,h,p,!0,d,f,m);return w?{first:b,last:w}:null}function ue(e,i,r,n){return e.writingMode===t.WritingMode.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:e.writingMode===t.WritingMode.vertical?i.y<r.y?{needsFlipping:!0}:null:0!==e.flipState&&function(t,e,i){const r=(e.x-t.x)*i;return 0===r||Math.abs((e.y-t.y)/r)>te}(i,r,n)?1===e.flipState?{needsFlipping:!0}:null:i.x>r.x?{needsFlipping:!0}:null}function he(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v){const x=i/24,b=e.lineOffsetX*x,w=e.lineOffsetY*x;let T;if(e.numGlyphs>1){const i=e.glyphStartIndex+e.numGlyphs,o=e.lineStartIndex,u=e.lineStartIndex+e.lineLength,h=ce(x,l,b,w,r,p,d,e,c,s,f,_,!1,g,y,v);if(!h)return{notEnoughRoom:!0};const M=oe(h.first.point,a).point,E=oe(h.last.point,a).point,C=new t.pointGeometry(M[0],M[1]),S=new t.pointGeometry(E[0],E[1]);if(n&&!r){const t=ue(e,C,S,m);if(e.flipState=t&&t.needsFlipping?1:2,t)return t}T=[h.first];for(let t=e.glyphStartIndex+1;t<i-1;t++)T.push(fe(x*l.getoffsetX(t),b,w,r,p,d,e.segment,o,u,c,s,f,_,!1,!1,g,y,v));T.push(h.last)}else{if(n&&!r){const i=ne(d,o).point,r=e.lineStartIndex+e.segment+1,n=new t.pointGeometry(c.getx(r),c.gety(r)),s=ne(n,o),a=s.signedDistanceFromCamera>0?s.point:de(d,n,i,1,o,void 0,g,y.canonical),l=ue(e,new t.pointGeometry(i[0],i[1]),new t.pointGeometry(a[0],a[1]),m);if(e.flipState=l&&l.needsFlipping?1:2,l)return l}const i=fe(x*l.getoffsetX(e.glyphStartIndex),b,w,r,p,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,s,f,_,!1,!1,g,y,v);if(!i)return{notEnoughRoom:!0};T=[i]}if(h)for(const e of T)t.updateGlobeVertexNormal(h,u.length+0,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+1,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+2,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+3,e.up[0],e.up[1],e.up[2]),t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);else for(const e of T)t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);return{}}function pe(e,i,r,n,o){const s=n.projectTilePoint(e.x,e.y,i);if(!o)return ne(s,r,s.z);const a=o(e);return ne(new t.pointGeometry(s.x+a[0],s.y+a[1]),r,s.z+a[2])}function de(e,i,r,n,o,s,a,l){const c=pe(e.add(e.sub(i)._unit()),l,o,a,s).point,u=t.sub([],r,c);return t.scaleAndAdd([],r,u,n/t.length(u))}function fe(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y){const v=n?e-i:e+i;let x=v>0?1:-1,b=0;n&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=x>0?l+a:l+a+1,T=o,M=o,E=0,C=0;const S=Math.abs(v),k=[],A=[];let I=s;const P=()=>{const e=w-x;return 0===E?s:new t.pointGeometry(u.getx(e),u.gety(e))},L=()=>de(P(),I,M,S-E+1,h,d,_,g.canonical);for(;E+C<=S;){if(w+=x,w<l||w>=c)return null;if(M=T,k.push(T),f&&A.push(I||P()),T=p[w],void 0===T){I=new t.pointGeometry(u.getx(w),u.gety(w));const e=pe(I,g.canonical,h,_,d);T=e.signedDistanceFromCamera>0?p[w]=e.point:L()}else I=null;E+=C,C=t.distance(M,T)}I=I||new t.pointGeometry(u.getx(w),u.gety(w));const z=P();m&&d&&(p[w]=T=void 0===p[w]?T:L(),C=t.distance(M,T));const D=(S-E)/C,R=I.sub(z).mult(D)._add(z),O=t.sub([],T,M),F=t.scaleAndAdd([],M,O,D);let B=[0,0,1],j=O[0],N=O[1];if(y&&(B=_.upVector(g.canonical,R.x,R.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[1,0,0],i=[0,1,0];e[0]=B[2],e[1]=0,e[2]=-B[0],t.cross(i,B,e),t.normalize(e,e),t.normalize(i,i),j=t.dot(O,e),N=t.dot(O,i)}if(r){const e=t.cross([],B,O);t.normalize(e,e),t.scaleAndAdd(F,F,e,r*x)}const V=b+Math.atan2(N,j);return k.push(F),f&&A.push(R),{point:F,angle:V,path:k,tilePath:A,up:B}}const me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _e(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(me,4*t)}}function ge(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const ye=100;class ve{constructor(t,e,i=new Kt(t.width+200,t.height+200,25),r=new Kt(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+ye,this.screenBottomBoundary=t.height+ye,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,p=i.tileID;if(h&&p){const e=t.getProjection().upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),r=t.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e[0]*h*r,c+=e[1]*h*r,u+=e[2]*h*r}const d=this.projectAndGetPerspectiveRatio(s,[l,c,u],i.tileID,"globe"===t.projection.name||!!h||this.transform.pitch>0,t.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*e+r.x-i.padding)*f+d.point.x,_=(i.y1*e+r.y-i.padding)*f+d.point.y,g=(i.x2*e+r.x+i.padding)*f+d.point.x,y=(i.y2*e+r.y+i.padding)*f+d.point.y,v=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!n&&this.grid.hitTest(m,_,g,y,a)||v?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,e.getProjection()):t=>[0,0,0],v=new t.pointGeometry(r.tileAnchorX,r.tileAnchorY),x=e.getProjection().projectTilePoint(r.tileAnchorX,r.tileAnchorY,m.canonical),b=y(v),w=[x.x+b[0],x.y+b[1],x.z+b[2]],T="globe"===e.projection.name,M=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,e.getProjection()),{perspectiveRatio:E}=M,C=(h?s/E:s*E)/t.ONE_EM,S=ne(new t.pointGeometry(w[0],w[1]),l,w[2]).point,k=M.signedDistanceFromCamera>0?ce(C,o,r.lineOffsetX*C,r.lineOffsetY*C,!1,S,v,r,n,l,{},g&&!h?y:null,h&&!!g,e.getProjection(),m,h):null;let A=!1,I=!1,P=!0;if(k&&!M.occluded){const e=.5*d*E+f,r=new t.pointGeometry(-100,-100),n=new t.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Jt,s=k.first,a=k.last;let l=[];for(let t=s.path.length-1;t>=1;t--)l.push(s.path[t]);for(let t=1;t<a.path.length;t++)l.push(a.path[t]);const h=2.5*e;if(c){const t=l.map(g&&!T?(t,e)=>{const i=y(e<s.path.length-1?s.tilePath[s.path.length-1-e]:a.tilePath[e-s.path.length+2]);return t[2]=i[2],oe(t,c)}:t=>oe(t,c));l=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const e=l.map((e=>new t.pointGeometry(e[0],e[1])));let i=1/0,o=-1/0,s=1/0,a=-1/0;for(let t=0;t<e.length;t++)i=Math.min(i,e[t].x),s=Math.min(s,e[t].y),o=Math.max(o,e[t].x),a=Math.max(a,e[t].y);m=i>=r.x&&o<=n.x&&s>=r.y&&a<=n.y?[e]:o<r.x||i>n.x||a<r.y||s>n.y?[]:t.clipLine([e],r.x,r.y,n.x,n.y)}for(const t of m){o.reset(t,.25*e);let r=0;r=o.length<=.5*e?1:Math.ceil(o.paddedLength/h)+1;for(let t=0;t<r;t++){const n=t/Math.max(r-1,1),s=o.lerp(n),a=s.x+ye,l=s.y+ye;_.push(a,l,e,0);const c=a-e,h=l-e,d=a+e,f=l+e;if(P=P&&this.isOffscreen(c,h,d,f),I=I||this.isInsideGrid(c,h,d,f),!i&&this.grid.hitTestCircle(a,l,e,p)&&(A=!0,!u))return{circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return{circles:!u&&A||!I?[]:_,offscreen:P,collisionDetected:A,occluded:M.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of e){const e=new t.pointGeometry(a.x+ye,a.y+ye);r=Math.min(r,e.x),n=Math.min(n,e.y),o=Math.max(o,e.x),s=Math.max(s,e.y),i.push(e)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const e of a){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new t.pointGeometry(e.x1,e.y1),new t.pointGeometry(e.x2,e.y1),new t.pointGeometry(e.x2,e.y2),new t.pointGeometry(e.x1,e.y2)];t.polygonIntersectsPolygon(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,e,i,r,n){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n){const o=e?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let e=0;e<t.length;e+=4)o.insertCircle(s,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(e,i,r,n,o){const s=[i[0],i[1],i[2],1];let a=!1;if(i[2]||this.transform.pitch>0){t.transformMat4$1(s,s,e);const n="globe"===o.name;this.fogState&&r&&!n&&(a=function(e,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return t.transformMat4(l,l,a),S(e,l,s.pitch,s._fov)}(this.fogState,i[0],i[1],i[2],r.toUnwrapped(),this.transform)>.9)}else ge(s,s,e);return{point:new t.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+ye,(-s[1]/s[3]+1)/2*this.transform.height+ye),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:n&&s[2]>s[3]||a}}isOffscreen(t,e,i,r){return i<ye||t>=this.screenRightBoundary||r<ye||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const e=t.identity([]);return t.translate(e,e,[-100,-100,0]),e}}function xe(e,i,r){const n=i.createTileMatrix(e,e.worldSize,r.toUnwrapped());return t.multiply(new Float32Array(16),e.projMatrix,n)}function be(t,e,i){if(e.projection.name===i.projection.name)return t.projMatrix;const r=i.clone();return r.setProjection(e.projection),xe(r,e.getProjection(),t)}function we(t,e,i){return e.name===i.projection.name?t.projMatrix:xe(i,e,t)}class Te{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Me{constructor(t,e,i,r,n,o=!1){this.text=new Te(t?t.text:null,e,i,n),this.icon=new Te(t?t.icon:null,e,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ee{constructor(t,e,i,r=!1){this.text=t,this.icon=e,this.skipFade=i,this.clipped=r}}class Ce{constructor(){this.invProjMatrix=t.create(),this.viewportMatrix=t.create(),this.circles=[]}}class Se{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class ke{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function Ae(e,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*i,c=-(a-.5)*r,u=t.evaluateVariableOffset(e,n);return new t.pointGeometry(l+u[0]*o,c+u[1]*o)}function Ie(e,i,r,n,o){const s=new t.pointGeometry(e,i);return r&&s._rotate(n?o:-o),s}class Pe{constructor(t,e,i,r,n){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new ve(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new ke(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const p=(d=r.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):xe(m,f,d));var d,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),v=i.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=ie(p,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);let w=null;if(_){const e=re(p,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);w=t.multiply([],this.transform.labelPlaneMatrix,e)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Se(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const M={bucket:o,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:M})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:M})}attemptAnchorPlacement(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],v=Ae(t,i,r,y,n),x=this.collisionIndex.placeCollisionBox(d,n,e,Ie(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Ie(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)&&x.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(e=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:n,prevAnchor:e},this.markUsedJustification(d,t,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:v,placedGlyphBoxes:x}}}placeLayerBucketPart(e,i,r,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),M="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let E=v&&(x||!o.hasIconData()||y),C=x&&(v||!o.hasTextData()||g);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),r&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const S=(e,n,d)=>{if(u){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(r,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new t.pointGeometry(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[e.crossTileID]=new Ee(!1,!1,!1,!0),void(i[e.crossTileID]=!0)}if(i[e.crossTileID])return;if(p)return void(this.placements[e.crossTileID]=new Ee(!1,!1,!1));let M=!1,S=!1,k=!0,A=!1,I=!1,P=null,L={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},D=null,R=null,O=null,F=0,B=0,j=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(B=d.verticalTextFeatureIndex);const N=t=>{t.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,t.tileAnchorX,t.tileAnchorY):0)},V=d.textBox;if(V){N(V);const i=i=>{let r=t.WritingMode.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e))}return r},r=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.WritingMode.vertical?(L=r(),z=L):L=i(),L&&L.box&&L.box.length)break}else L=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];l.indexOf(t.anchor)>0&&(l=l.filter((e=>e!==t.anchor)),l.unshift(t.anchor))}const c=(t,i,r)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),c=(t.x2-t.x1)*s+2*t.padding,u=(t.y2-t.y1)*s+2*t.padding,p=T&&!x?i:null;p&&N(p);let d={box:[],offscreen:!1,occluded:!1};const g=v?2*l.length:l.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(l[i%l.length],t,c,u,s,b,w,h,a,_,i>=l.length,e,n,o,r,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){M=!0,P=g.shift;break}}return d};r((()=>c(V,d.iconBox,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&N(i),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&e.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),L&&(M=L.box,k=L.offscreen,A=L.occluded);const u=i(L&&L.box);if(!M&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,u))}}else{const s=(i,r)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,i,new t.pointGeometry(0,0),v,h,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,e),this.placedOrientations[e.crossTileID]=r),l};r((()=>s(V,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?(N(i),s(i,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(L&&L.box&&L.box.length)}}if(D=L,M=D&&D.box&&D.box.length>0,k=D&&D.offscreen,A=D&&D.occluded,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),n=t.evaluateSizeForFeature(o.textSizeData,f,i),u=s.get("text-padding");R=this.collisionIndex.placeCollisionCircles(o,v,i,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,r,w,_.predicate,e.collisionCircleDiameter*n/t.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),M=v||R.circles.length>0&&!R.collisionDetected,k=k&&R.offscreen,A=R.occluded}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>{N(e);const i=T&&P?Ie(P.x,P.y,b,w,this.transform.angle):new t.pointGeometry(0,0),r=o.getSymbolInstanceIconSize(m,this.transform.zoom,n);return this.collisionIndex.placeCollisionBox(o,r,e,i,x,h,a,_.predicate)};z&&z.box&&z.box.length&&d.verticalIconBox?(O=e(d.verticalIconBox),S=O.box.length>0):(O=e(d.iconBox),S=O.box.length>0),k=k&&O.offscreen,I=O.occluded}const U=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,$=y||0===e.numIconVertices;if(U||$?$?U||(S=S&&M):M=S&&M:S=M=S&&M,M&&D&&D.box&&this.collisionIndex.insertCollisionBox(D.box,s.get("text-ignore-placement"),o.bucketInstanceId,z&&z.box&&B?B:F,_.ID),S&&O&&this.collisionIndex.insertCollisionBox(O.box,s.get("icon-ignore-placement"),o.bucketInstanceId,j,_.ID),R&&(M&&this.collisionIndex.insertCollisionCircles(R.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,_.ID),r)){const t=o.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Ce);for(let t=0;t<R.circles.length;t+=4)e.circles.push(R.circles[t+0]),e.circles.push(R.circles[t+1]),e.circles.push(R.circles[t+2]),e.circles.push(R.collisionDetected?1:0)}const G="globe"!==o.projection.name;E=E&&(G||!A),C=C&&(G||!I),this.placements[e.crossTileID]=new Ee(M||E,S||C,k||o.justReloaded),i[e.crossTileID]=!0};if(M){const t=o.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];S(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)S(o.symbolInstances.get(t),t,o.collisionArrays[t]);if(r&&o.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[o.bucketInstanceId];t.invert(e.invProjMatrix,a),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(e,i,r,n){let o;o=n===t.WritingMode.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.getAnchorJustification(i)];const s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const t of s)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,o=i===t.WritingMode.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},o=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=n[t];o?(this.opacities[t]=new Me(o,r,e.text,e.icon,null,e.clipped),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new Me(null,r,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new Me(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,o=!!e.layers[0].dynamicFilter(),s=new Me(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),d=new Me(null,0,a&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(a||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const f=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};let m=0;for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:_}=n;let g=this.opacities[_];i[_]?g=s:g||(g=d,this.opacities[_]=g),i[_]=!0;const y=a>0||l>0,v=n.numIconVertices>0,x=this.placedOrientations[n.crossTileID],b=x===t.WritingMode.vertical,w=x===t.WritingMode.horizontal||x===t.WritingMode.horizontalOnly;if(!y&&!v||g.isHidden()||m++,y){const t=Ne(g.text);f(e.text,a,b?Ve:t),f(e.text,l,w?Ve:t);const i=g.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||b?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,x);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(e,"left",n,o),this.markUsedOrientation(e,o,n))}if(v){const t=Ne(g.icon);n.placedIconSymbolIndex>=0&&(f(e.icon,n.numIconVertices,b?Ve:t),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=g.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,n.numVerticalIconVertices,w?Ve:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[r];if(i){let r=new t.pointGeometry(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(c){const t=this.variableOffsets[_];t?(r=Ae(t.anchor,t.width,t.height,t.textOffset,t.textScale),u&&r._rotate(h?this.transform.angle:-this.transform.angle)):n=!1}o&&(n=!g.clipped),i.textBox&&Le(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||b,r.x,r.y),i.verticalTextBox&&Le(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||w,r.x,r.y)}const s=n&&Boolean(!w&&i.verticalIconBox);i.iconBox&&Le(e.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?r.x:0,p?r.y:0),i.verticalIconBox&&Le(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?r.x:0,p?r.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function Le(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const ze=Math.pow(2,25),De=Math.pow(2,24),Re=Math.pow(2,17),Oe=Math.pow(2,16),Fe=Math.pow(2,9),Be=Math.pow(2,8),je=Math.pow(2,1);function Ne(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*ze+e*De+i*Re+e*Oe+i*Fe+e*Be+i*je+e}const Ve=0;class Ue{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(o,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<o.length;){const t=o[this._currentPartIndex];if(e.placeLayerBucketPart(t,this._seenCrossTileIDs,i,0===t.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class $e{constructor(t,e,i,r,n,o,s,a){this.placement=new Pe(t,n,o,s,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,i,r){const n=t.exported.now(),o=()=>{const e=t.exported.now()-n;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=n)&&(!t.maxzoom||t.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Ue(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ge=512/t.EXTENT/2;class qe{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(e,i){const r=Ge/Math.pow(2,i.canonical.z-this.tileID.canonical.z);return{x:Math.floor((i.canonical.x*t.EXTENT+e.tileAnchorX)*r),y:Math.floor((i.canonical.y*t.EXTENT+e.tileAnchorY)*r)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const o=t.get(n);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,e);for(const t of s)if(Math.abs(t.coord.x-a.x)<=r&&Math.abs(t.coord.y-a.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,o.crossTileID=t.crossTileID;break}}}}class Ze{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class He{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,r)}else{const o=n[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new qe(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class We{constructor(){this.layerIndexes={},this.crossTileIDs=new Ze,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i,r){let n=this.layerIndexes[t.id];void 0===n&&(n=this.layerIndexes[t.id]=new He);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,e,this.crossTileIDs)&&(o=!0),s[e.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Xe=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Qe=t.pick(Gt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Ye=t.pick(Gt,["setCenter","setZoom","setBearing","setPitch"]),Je={version:8,layers:[],sources:{}},Ke={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ti extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new L(Vt(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,i.localFontFamily?t.LocalGlyphMode.all:i.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new t.LineAtlas(256,512),this.crossTileSymbolIndex=new We,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=ti.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r._sourceCaches){const e=r._sourceCaches[t],i=e.getSource().type;"vector"!==i&&"geojson"!==i||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,i.accessToken);const n=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(n,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Je,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(e,i){if(i&&Xe(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=t.clone$1(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const r=$t(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let e of r)e=t.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(e){this._spriteRequest=function(e,i,r){let n,o,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,n=e,u())})),c=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,o=e,u())}));function u(){if(s)r(s);else if(n&&o){const e=t.exported.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=n[r],f=new t.RGBAImage({width:o,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[r]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.getSource(e.source);if(!i)return;const r=e.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Ke[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const n=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,n)}}for(const e in r){const i=this._sourceCaches[e];r[e]!==i.used&&i.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),Xe(this,t.validateStyle(i)))return!1;(i=t.clone$1(i)).layers=$t(i.layers);const r=function(t,i){if(!t)return[{command:Gt.setStyle,args:[i]}];let r=[];try{if(!e(t.version,i.version))return[{command:Gt.setStyle,args:[i]}];e(t.center,i.center)||r.push({command:Gt.setCenter,args:[i.center]}),e(t.zoom,i.zoom)||r.push({command:Gt.setZoom,args:[i.zoom]}),e(t.bearing,i.bearing)||r.push({command:Gt.setBearing,args:[i.bearing]}),e(t.pitch,i.pitch)||r.push({command:Gt.setPitch,args:[i.pitch]}),e(t.sprite,i.sprite)||r.push({command:Gt.setSprite,args:[i.sprite]}),e(t.glyphs,i.glyphs)||r.push({command:Gt.setGlyphs,args:[i.glyphs]}),e(t.transition,i.transition)||r.push({command:Gt.setTransition,args:[i.transition]}),e(t.light,i.light)||r.push({command:Gt.setLight,args:[i.light]}),e(t.fog,i.fog)||r.push({command:Gt.setFog,args:[i.fog]}),e(t.projection,i.projection)||r.push({command:Gt.setProjection,args:[i.projection]});const n={},o=[];!function(t,i,r,n){let o;for(o in i=i||{},t=t||{})t.hasOwnProperty(o)&&(i.hasOwnProperty(o)||Zt(o,r,n));for(o in i)i.hasOwnProperty(o)&&(t.hasOwnProperty(o)?e(t[o],i[o])||("geojson"===t[o].type&&"geojson"===i[o].type&&Wt(t,i,o)?r.push({command:Gt.setGeoJSONSourceData,args:[o,i[o].data]}):Ht(o,i,r,n)):qt(o,i,r))}(t.sources,i.sources,o,n);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&n[t.source]?r.push({command:Gt.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&n[a.source]&&(r.push({command:Gt.setTerrain,args:[void 0]}),a=void 0),r=r.concat(o),e(a,i.terrain)||r.push({command:Gt.setTerrain,args:[i.terrain]}),function(t,i,r){i=i||[];const n=(t=t||[]).map(Qt),o=i.map(Qt),s=t.reduce(Yt,{}),a=i.reduce(Yt,{}),l=n.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u<n.length;u++)p=n[u],a.hasOwnProperty(p)?h++:(r.push({command:Gt.removeLayer,args:[p]}),l.splice(l.indexOf(p,h),1));for(u=0,h=0;u<o.length;u++)p=o[o.length-1-u],l[l.length-1-u]!==p&&(s.hasOwnProperty(p)?(r.push({command:Gt.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-h),1)):h++,m=l[l.length-u],r.push({command:Gt.addLayer,args:[a[p],m]}),l.splice(l.length-u,0,p),c[p]=!0);for(u=0;u<o.length;u++)if(p=o[u],d=s[p],f=a[p],!c[p]&&!e(d,f))if(e(d.source,f.source)&&e(d["source-layer"],f["source-layer"])&&e(d.type,f.type)){for(_ in Xt(d.layout,f.layout,r,p,null,Gt.setLayoutProperty),Xt(d.paint,f.paint,r,p,null,Gt.setPaintProperty),e(d.filter,f.filter)||r.push({command:Gt.setFilter,args:[p,f.filter]}),e(d.minzoom,f.minzoom)&&e(d.maxzoom,f.maxzoom)||r.push({command:Gt.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Xt(d[_],f[_],r,p,_.slice(6),Gt.setPaintProperty):e(d[_],f[_])||r.push({command:Gt.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Xt(d[_],f[_],r,p,_.slice(6),Gt.setPaintProperty):e(d[_],f[_])||r.push({command:Gt.setLayerProperty,args:[p,_,f[_]]}))}else r.push({command:Gt.removeLayer,args:[p]}),m=l[l.lastIndexOf(p)+1],r.push({command:Gt.addLayer,args:[f,m]})}(s,i.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:Gt.setStyle,args:[i]}]}return r}(this.serialize(),i).filter((t=>!(t.command in Ye)));if(0===r.length)return!1;const n=r.filter((t=>!(t.command in Qe)));if(n.length>0)throw new Error(`Unimplemented: ${n.map((t=>t.command)).join(", ")}.`);return r.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(e,i){return this.getImage(e)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,i),this._afterImageUpdated(e),this)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateSource,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=Lt(e,i,this.dispatcher,this);n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:n.serialize(),sourceId:e})));const o=i=>{const r=(i?"symbol:":"other:")+e,o=this._sourceCaches[r]=new t.SourceCache(r,n,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[e]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const i=this.getSource(e);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(e);for(const e of r)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===e.type){if(Xe(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(n,e.source),e=t.clone$1(e),e=t.extend(e,{source:n})),this._validate(t.validateLayer,`layers.${n}`,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[n]&&o.source&&a&&"custom"!==o.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,r,n={}){this._checkLoaded();const o=this.getLayer(i);if(o){if(!e(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.validateFilter,`layers.${o.id}.filter`,r,{layerType:o.type},n)||(o.filter=t.clone$1(r),this._updateLayer(o)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const i=this.getLayer(e);return i&&t.clone$1(i.filter)}setLayoutProperty(i,r,n,o={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getLayoutProperty(r),n)||(s.setLayoutProperty(r,n,o),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(i,r,n,o={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getPaintProperty(r),n)||(s.setPaintProperty(r,n,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){const i=this.getLayer(t);return i&&i.getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,o=this.getSource(r);if(!o)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&n)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(r);for(const t of a)t.setFeatureState(n,e.id,i)}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.getSource(r);if(!n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.type,s="vector"===o?e.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(r);for(const t of a)t.removeFeatureState(s,e.id,i)}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.getSource(i);if(n){if("vector"!==n.type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(e(o)){i[o]=n;for(const e of t){const t=e[o];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(e(s))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<o)break;n.push(e),r.pop()}else for(const e of t){const t=e[s];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(e,i,r){i&&i.filter&&this._validate(t.validateFilter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=i&&i.layers?i.layers.some((t=>{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=D.createFromScreenPoints(e,r);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;i.layers&&!n[e]||o.push(Dt(this._sourceCaches[t],this._layers,this._serializedLayers,a,i,r,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(t,e,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(Ot);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],n=r[t];n.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of n)e.push(t)}}for(const e in a)a[e].forEach((r=>{const n=r.feature,o=i(t[e]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const r=this._getSourceCaches(e);let n=[];for(const t of r)n=n.concat(Rt(t,i));return n}addSourceType(t,e,i){return ti.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(ti.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e(t[i],r[i])){n=!0;break}if(!n)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(t,i),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,r=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===r){if("object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=t.clone$1(i),i=t.extend(i,{source:e})}if(this._validate(t.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode)this._createTerrain(i,r);else{const r=this.terrain,n=r.get();for(const e of Object.keys(t.spec.terrain))!i.hasOwnProperty(e)&&t.spec.terrain[e].default&&(i[e]=t.spec.terrain[e].default);for(const t in i)if(!e(i[t],n[t])){r.set(i),this.stylesheet.terrain=i;const t=this._setTransitionParameters({duration:0});r.updateTransitions(t);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new P(t,this.map.transform);this.stylesheet.fog=t;const i=this._setTransitionParameters({duration:0});e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,r=i.get();0===Object.keys(t).length&&i.set(t);for(const n in t)if(!e(t[n],r[n])){i.set(t),this.stylesheet.fog=t;const e=this._setTransitionParameters({duration:0});i.updateTransitions(e);break}}else this._createFog(t);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:t.exported.now(),transition:t.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new C(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(e,i,r,n,o={}){return(!o||!1!==o.validate)&&Xe(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:r,styleSpec:t.spec},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,i,r,n,o=!1){let s=!1,a=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng,e.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new $e(e,this._order,o,i,r,n,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(e){const i=this._getSourceCaches(e);return 0===i.length?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):i.every((t=>t.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}ti.getSourceType=function(t){return Pt[t]},ti.setSourceType=function(t,e){Pt[t]=e},ti.registerForPluginStateChange=t.registerForPluginStateChange;var ei="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ii="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let ri={},ni={};ri=ci("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),ni=ci("#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const oi=ci("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),si=ei,ai="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var li={background:ci("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:ci("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:ci("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:ci("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ci("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:ci("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:ci("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ci("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ci("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:ci("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:ci("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:ci("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:ci("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ci("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:ci("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:ci("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:ci("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:ci("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:ci("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:ci("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:ci("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxGradient:ci("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxCapture:ci("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:ci("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function ci(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=t.match(n),a=e.match(n),l=ei.match(n);let c=a?a.concat(s):s;i||(ri.staticUniforms&&(c=ri.staticUniforms.concat(c)),ni.staticUniforms&&(c=ni.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:t=t.replace(r,((t,e,i,r,n)=>(u[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return u[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:o,staticUniforms:c}}class ui{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,o,s,a,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!c&&this.boundIndexBuffer===n&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===s&&this.boundDynamicVertexBuffer2===a&&this.boundDynamicVertexBuffer3===l?(t.bindVertexArrayOES.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind()):this.freshBind(e,i,r,n,o,s,a,l)}freshBind(t,e,i,r,n,o,s,a){let l;const c=t.numAttributes,u=this.context,h=u.gl;if(u.extVertexArrayObject)this.vao&&this.destroy(),this.vao=u.extVertexArrayObject.createVertexArrayOES(),u.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a;else{l=u.currentNumAttributes||0;for(let t=c;t<l;t++)h.disableVertexAttribArray(t)}e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);o&&o.enableAttributes(h,t),s&&s.enableAttributes(h,t),a&&a.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),a&&(a.bind(),a.setVertexAttribPointers(h,t,n)),u.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function hi(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.MercatorCoordinate(0,n/r).toLngLat().lat,new t.MercatorCoordinate(0,(n+1)/r).toLngLat().lat]}function pi(e,i,r,n,o,s,a){const l=e.context,c=l.gl,u=r.fbo;if(!u)return;e.prepareDrawTile();const h=e.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const p=((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:hi(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:o,u_accent:s}})(e,r,n,e.terrain?i.projMatrix:null);e.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(r);h.draw(l,c.TRIANGLES,o,s,a,t.CullFaceMode.disabled,p,n.id,d,f,m)}function di(e,i,r){if(!i.needsDEMTextureUpload)return;const n=e.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new t.Texture(n,s,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function fi(e,i,r,n,o,s){const a=e.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),di(e,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const e=new t.Texture(a,{width:u,height:u,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(e.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,t.CullFaceMode.disabled,((e,i)=>{const r=i.stride,n=t.create();return t.ortho(n,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(n,n,[0,-t.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),r.id,p,d,f),i.needsHillshadePrepare=!1}const mi=(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image0:new t.Uniform1i(e,i.u_image0),u_skirt_height:new t.Uniform1f(e,i.u_skirt_height)}),_i=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),gi=(t,e,i,r,n,o,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yi(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const vi=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,n){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:n,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},xi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bi(t,e){const i=1<<t.z;return!e&&(0===t.x||t.x===i-1)||0===t.y||t.y===i-1}const wi=t=>({u_matrix:t});function Ti(e,i,r,n,o){if(o>0){const s=t.exported.now(),a=(s-e.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),p=h&&e.refreshedUponExpiration?1:t.clamp(h?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Mi extends t.SourceCache{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new L(Vt(),null),r=Lt("mock-dem",e,i,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class Ei extends t.SourceCache{constructor(t){const e=Lt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new L(Vt(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,r){if(e.freezeTileCoverage)return;this.transform=e;const n=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new t.Tile(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i}),{});for(const t in this._tiles)t in n||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ci extends t.OverscaledTileID{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class Si extends t.Elevation{constructor(e,i){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=function(e){const i=new t.StructArrayLayout4i8,r=new t.StructArrayLayout3ui6,n=131;i.reserve(17161),r.reserve(33800);const o=t.EXTENT/128,s=t.EXTENT+o/2,a=s+o;for(let e=-o;e<a;e+=o)for(let r=-o;r<a;r+=o){const n=r<0||r>s||e<0||e>s?24575:0,o=t.clamp(Math.round(r),0,t.EXTENT),a=t.clamp(Math.round(e),0,t.EXTENT);i.emplaceBack(o+n,a,o,a)}const l=(t,e)=>{const i=e*n+t;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)})),[i,r,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(r,t.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=t.SegmentVector.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ei(i.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Mi(i.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(e,i,r){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const n=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(n.get("source")),this._exaggeration=n.get("exaggeration");const o=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(i,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),i.updateElevation(!r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map((t=>{const e=i.getTileByID(t).tileID;return e.projMatrix=r.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new t.pointGeometry(r.x,r.y);e.sort(((e,i)=>{if(i.overscaledZ-e.overscaledZ)return i.overscaledZ-e.overscaledZ;const r=new t.pointGeometry(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),o=new t.pointGeometry(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=n.mult(1<<e.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(r)-s.distSqr(o)}))}(n,this.painter),this._previousZoom=r.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((t=>{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const i=s[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],o),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map((t=>new Ci(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),di(this.painter,r,n))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const n=t.tileID.canonical,o=Math.pow(2,e.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,i=e.gl;if(!this._emptyDepthBufferTexture){const r=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(e,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,i=e.gl;e.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),n=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new t.Texture(e,n,i.RGBA,{premultiply:!1}),o}setupElevationDraw(e,i,r){const n=this.painter.context,o=n.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=e.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,t.EXTENT,0),s.u_tile_br_up=c.upVector(u,t.EXTENT,t.EXTENT),s.u_tile_bl_up=c.upVector(u,0,t.EXTENT),s.u_tile_up_scale=r&&r.useDenormalizedUpVectorScale?t.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(r&&r.morphing&&this._useVertexMorphing){const t=r.morphing.srcDemTile,i=r.morphing.dstDemTile;d=r.morphing.phase,t&&i&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(p=t),this._prepareDemTileUniforms(e,i,s)&&(h=i))}if(p&&h?(n.activeTexture.set(o.TEXTURE2),h.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),n.activeTexture.set(o.TEXTURE4),p.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[e.tileID.key],n.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(e,h,s)?h.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),n.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&h){const e=(1<<h.tileID.canonical.z)*t.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=e}r&&r.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=r.labelPlaneMatrixInv),i.setTerrainUniformValues(n,s)}renderToBackBuffer(e){const i=this.painter,r=this.painter.context;0!==e.length&&(r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,i,r,n,o){if("globe"===e.transform.projection.name)!function(e,i,r,n,o){const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=e.transform,p=t.globeUseCustomAntiAliasing(e,s,h),d=(t,i)=>{if(c===t)return;const r=[xi[t],"PROJECTION_GLOBE_VIEW"];p&&r.push("CUSTOM_ANTIALIASING"),i&&r.push(xi[u]),l=e.useProgram("globeRaster",null,r),c=t},f=e.colorModeForRenderPass(),m=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);vi.update(o);const _=t.calculateGlobeMercatorMatrix(h),g=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],y=e.globeSharedBuffers,v=[h.width*t.exported.devicePixelRatio,h.height*t.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of n){const n=r.getTile(c),x=t.StencilMode.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];yi(b,w)&&vi.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=vi.getMorphValuesForProxy(c.key),M=T?1:0,E={useDenormalizedUpVectorScale:!0};T&&t.extend$1(E,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:t.easeCubicInOut(T.phase)}});const C=Float32Array.from(h.globeMatrix),S=t.globeTileLatLngCorners(c.canonical),k=t.getLatitudinalLod((S[0][0]+S[1][0])/2),A=t.getGridMatrix(c.canonical,S,k),I=t.globeNormalizeECEF(t.globeTileBounds(c.canonical)),P=gi(h.projMatrix,C,_,I,t.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,A);if(d(M,u),i.setupElevationDraw(n,l,E),e.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[i,r,n]=u?y.getWirefameBuffers(e.context,k):y.getGridBuffers(k);l.draw(s,p,m,x,f,t.CullFaceMode.backCCW,P,"globe_raster",i,r,n)}}})),y){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&o.push("CUSTOM_ANTIALIASING"),l=e.useProgram("globeRaster",null,o);for(const o of n){const{x:n,y:c,z:u}=o.canonical,p=0===c,d=c===(1<<u)-1,[_,x,b,w]=y.getPoleBuffers(u);if(w&&(p||d)){const c=r.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let y=t.globePoleMatrixForTile(u,n,h);const T=t.globeNormalizeECEF(t.globeTileBounds(o.canonical)),M=(e,i)=>e.draw(s,a.TRIANGLES,m,t.StencilMode.disabled,f,t.CullFaceMode.disabled,gi(h.projMatrix,y,y,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,{}),e.prepareDrawProgram(s,l,o.toUnwrapped()),p&&M(l,_),d&&(y=t.scale(t.create(),y,[1,-1,1]),M(l,x))}}}}(e,i,r,n,o);else{const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=(t,i)=>{if(c===t)return;const r=[xi[t]];i&&r.push(xi[u]),l=e.useProgram("terrainRaster",null,r),c=t},p=e.colorModeForRenderPass(),d=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);vi.update(o);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const _=u?a.LINES:a.TRIANGLES,[g,y]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),v=t.StencilMode.disabled,x=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];yi(x,b)&&vi.newMorphing(c.key,x,b,o,250),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=vi.getMorphValuesForProxy(c.key),T=w?1:0;let M;w&&(M={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:t.easeCubicInOut(w.phase)}});const E=_i(c.projMatrix,bi(c.canonical,f.renderWorldCopies)?m/10:m);h(T,u),i.setupElevationDraw(n,l,M),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,_,d,v,p,t.CullFaceMode.backCCW,E,"terrain_raster",i.gridBuffer,g,y)}}))}}(i,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][e]:void 0,p=void 0!==h?n.renderCache[h]:this.pool[c++],d=void 0!==h;if(o.texture=p.tex,d&&!p.dirty){a.push(o.tileID);continue}let f;r.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(r.clear({color:t.Color.transparent,stencil:0}),p.dirty=!1);for(let t=s.start;t<=s.end;++t){const e=i.style._layers[l[t]];if(e.isHidden(i.transform.zoom))continue;const n=i.style._getLayerSourceCache(e),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;r.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(p,o,e,n),f=n?n.id:null),i.renderLayer(i,n,e,s)}this.renderedToTile?(p.dirty=!0,a.push(o.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,n=0,o=!1;for(let s=0;s<e;++s){const e=t._layers[t.order[s]];this._style.isLayerDraped(e)?(o&&++r,++n):o||(o=!0,i=e.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter((t=>t.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const n=r.tileID,o=Math.pow(2,n.overscaledZ),{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,t,e,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,i=e.gl,r=this.drapeBufferSize;e.activeTexture.set(i.TEXTURE0);const n=new t.Texture(e,{width:r[0],height:r[1],data:null},i.RGBA);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=e.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(n.texture),o.depthAttachment=new Mt(e,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some((t=>{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),n=!!r&&1!==r.t,o=e.hasTransition();return"custom"!==e.type&&!i&&(n||o)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof St){t=!0;break}if(t)for(let t=0;t<this._style.order.length;++t){const e=this._style._layers[this._style.order[t]],i=e.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(e);if("raster"!==e.type||i||!r)continue;const n=e.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][r.id];if(e)for(const t of e){const e=Ti(r.getTile(t),r.findLoadedParent(t,0),r,this.painter.transform,n);(1!==e.opacity||0!==e.mix)&&this._clearRenderCacheForTile(r.id,t)}}}}_setupDrapedRenderBatches(){const t=this._style.order,e=t.length;if(0===e)return;const i=[];let r,n=0,o=this._style._layers[t[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<e;)o=this._style._layers[t[n]];for(;n<e;++n){const e=this._style._layers[t[n]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._drapedRenderBatches=i}_setupRenderCache(t){const e=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,e.renderCache.length>e.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i<t.length;++i){const r=Object.values(t[i]);e.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(e.getTileByID(o.key),void 0!==e.proxyCachedFBO[o.key]){const i=t[o.key],n=this.proxyToSource[o.key];let s=0;for(const t in n){const e=n[t],o=i[t];if(!o||o.length!==e.length||e.some(((e,i)=>e!==o[i]||r[t]&&r[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[o.key])e.renderCache[e.proxyCachedFBO[o.key][t]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of n)for(const r of i){if(e.proxyCachedFBO[r.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[r.key]={},e.proxyCachedFBO[r.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=e.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(e,i){const r=this.painter,n=this.painter.context,o=n.gl;r._tileClippingMaskIDs={},n.setColorMode(t.ColorMode.disabled),n.setDepthMode(t.DepthMode.disabled);const s=r.useProgram("clippingMask");for(const a of e){const e=r._tileClippingMaskIDs[a.key]=--i;s.draw(n,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(e){const i=this.painter.transform;if(e.x<0||e.x>i.width||e.y<0||e.y>i.height)return null;const r=[e.x,e.y,1,1];t.transformMat4$1(r,r,i.pixelMatrixInverse),t.scale$1(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=t.mercatorZfromAltitude(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=t.subtract([],r.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const e=this.painter,i=e.context,r=this.proxySourceCache,n=Math.ceil(e.width),o=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=i.gl,r=i.createFramebuffer(n,o,!0);i.activeTexture.set(e.TEXTURE0);const s=new t.Texture(i,{width:n,height:o,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,n,o);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,n,o]),function(e,i,r,n){if("globe"===e.transform.projection.name)return;const o=e.context,s=o.gl;o.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of n){const n=r.getTile(e),c=_i(e.projMatrix,0);i.setupElevationDraw(n,a),a.draw(o,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(e,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof It)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;e<n.length;e++){const o=n[e],s=this._findTileCoveringTileID(o,t);if(s){const e=this._createProxiedId(o,s,i[o.key]&&i[o.key][t.id]);r.push(e),this.proxyToSource[o.key][t.id]=[e]}}let o=!1;for(let n=0;n<e.length;n++){const s=t.getTile(e[n]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const e=this.proxyToSource[a.tileID.key][t.id],n=this._createProxiedId(a.tileID,s,i[a.tileID.key]&&i[a.tileID.key][t.id]);e?e.splice(e.length-1,0,n):this.proxyToSource[a.tileID.key][t.id]=[n],r.push(n),o=!0}}this._sourceTilesOverlap[t.id]=o}_setupProxiedCoordsForImageSource(e,i,r){if(!e.getSource().loaded())return;const n=this.proxiedCoords[e.id]=[],o=this.proxyCoords,s=e.getSource(),a=new t.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(t.MercatorCoordinate.fromLngLat).reduce(((t,e)=>(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,i)=>{const r=e.wrap+e.canonical.x/(1<<e.canonical.z),n=e.canonical.y/(1<<e.canonical.z),o=t.EXTENT/(1<<e.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return r+o<s+l.min.x||r>s+l.max.x||n+o<a+l.min.y||n>a+l.max.y};for(let t=0;t<o.length;t++){const s=o[t];for(let t=0;t<i.length;t++){const o=e.getTile(i[t]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,r[s.key]&&r[s.key][e.id]),l=this.proxyToSource[s.key][e.id];l?l.push(a):this.proxyToSource[s.key][e.id]=[a],n.push(a)}}}_createProxiedId(e,i,r){let n=this.orthoMatrix;if(r){const t=r.find((t=>t.key===i.tileID.key));if(t)return t}if(i.tileID.key!==e.key){const r=e.canonical.z-i.tileID.canonical.z;let o,s,a;n=t.create();const l=i.tileID.wrap-e.wrap<<e.overscaledZ;r>0?(o=t.EXTENT>>r,s=o*((i.tileID.canonical.x<<r)-e.canonical.x+l),a=o*((i.tileID.canonical.y<<r)-e.canonical.y)):(o=t.EXTENT<<-r,s=t.EXTENT*(i.tileID.canonical.x-(e.canonical.x+l<<-r)),a=t.EXTENT*(i.tileID.canonical.y-(e.canonical.y<<-r))),t.ortho(n,0,o,0,o,0,1),t.translate(n,n,[s,a,0])}return new Ci(i.tileID,e.key,n)}_findTileCoveringTileID(e,i){let r=i.getTile(e);if(r&&r.hasData())return r;const n=this._findCoveringTileCache[i.id],o=n[e.key];if(r=o?i.getTileByID(o):null,r&&r.hasData()||null===o)return r;let s=r?r.tileID:e,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const n=i.getSource().maxzoom;if(e.canonical.z>=n){const r=e.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,i.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,n,e.canonical.x>>r,e.canonical.y>>r)):0!==r&&(a=n,s=new t.OverscaledTileID(a,e.wrap,n,e.canonical.x>>r,e.canonical.y>>r))}s.key!==e.key&&(c.push(s.key),r=i.getTile(s))}const u=t=>{c.forEach((e=>{n[e]=t})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&u(r.tileID.key);const t=s.calculateScaledKey(a);if(r=i.getTileByID(t),r&&r.hasData())break;const e=n[t];if(null===e)break;void 0===e?c.push(t):r=i.getTileByID(e)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i=0;const r=new t.StructArrayLayout2ui4,n=131;for(let t=1;t<129;t++){for(let e=1;e<129;e++)i=t*n+e,r.emplaceBack(i,i+1),r.emplaceBack(i,i+n),r.emplaceBack(i+1,i+n),128===t&&r.emplaceBack(i+n,i+n+1);r.emplaceBack(i+1,i+1+n)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function ki(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class Ai{static cacheKey(t,e,i){let r=`${t}${i?i.cacheKey:""}`;for(const t of e)r+=`/${t}`;return r}constructor(e,i,r,n,o,s){const a=e.gl;this.program=a.createProgram();const l=ki(r.staticAttributes),c=n?n.getBinderAttributes():[],u=l.concat(c),h=r.staticUniforms?ki(r.staticUniforms):[],p=n?n.getBinderUniforms():[],d=h.concat(p),f=[];for(const t of d)f.indexOf(t)<0&&f.push(t);let m=n?n.defines():[];m=m.concat(s.map((t=>`#define ${t}`)));const _=m.concat(e.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,oi.fragmentSource,ni.fragmentSource,r.fragmentSource).join("\n"),g=m.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",si,oi.vertexSource,ni.vertexSource,ri.vertexSource,r.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,_),a.compileShader(y),a.attachShader(this.program,y);const v=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(v,g),a.compileShader(v),a.attachShader(this.program,v),this.attributes={};const x={};this.numAttributes=u.length;for(let t=0;t<this.numAttributes;t++)u[t]&&(a.bindAttribLocation(this.program,t,u[t]),this.attributes[u[t]]=t);a.linkProgram(this.program),a.deleteShader(v),a.deleteShader(y);for(let t=0;t<f.length;t++){const e=f[t];if(e&&!x[e]){const t=a.getUniformLocation(this.program,e);t&&(x[e]=t)}}this.fixedUniforms=o(e,x),this.binderUniforms=n?n.getUniforms(e,x):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((e,i)=>({u_dem:new t.Uniform1i(e,i.u_dem),u_dem_prev:new t.Uniform1i(e,i.u_dem_prev),u_dem_unpack:new t.Uniform4f(e,i.u_dem_unpack),u_dem_tl:new t.Uniform2f(e,i.u_dem_tl),u_dem_scale:new t.Uniform1f(e,i.u_dem_scale),u_dem_tl_prev:new t.Uniform2f(e,i.u_dem_tl_prev),u_dem_scale_prev:new t.Uniform1f(e,i.u_dem_scale_prev),u_dem_size:new t.Uniform1f(e,i.u_dem_size),u_dem_lerp:new t.Uniform1f(e,i.u_dem_lerp),u_exaggeration:new t.Uniform1f(e,i.u_exaggeration),u_depth:new t.Uniform1i(e,i.u_depth),u_depth_size_inv:new t.Uniform2f(e,i.u_depth_size_inv),u_meter_to_dem:new t.Uniform1f(e,i.u_meter_to_dem),u_label_plane_matrix_inv:new t.UniformMatrix4f(e,i.u_label_plane_matrix_inv),u_tile_tl_up:new t.Uniform3f(e,i.u_tile_tl_up),u_tile_tr_up:new t.Uniform3f(e,i.u_tile_tr_up),u_tile_br_up:new t.Uniform3f(e,i.u_tile_br_up),u_tile_bl_up:new t.Uniform3f(e,i.u_tile_bl_up),u_tile_up_scale:new t.Uniform1f(e,i.u_tile_up_scale)}))(e,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((e,i)=>({u_fog_matrix:new t.UniformMatrix4f(e,i.u_fog_matrix),u_fog_range:new t.Uniform2f(e,i.u_fog_range),u_fog_color:new t.Uniform4f(e,i.u_fog_color),u_fog_horizon_blend:new t.Uniform1f(e,i.u_fog_horizon_blend),u_fog_temporal_offset:new t.Uniform1f(e,i.u_fog_temporal_offset),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_globe_transition:new t.Uniform1f(e,i.u_globe_transition),u_is_globe:new t.Uniform1i(e,i.u_is_globe),u_viewport:new t.Uniform2f(e,i.u_viewport)}))(e,x))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_){const g=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(o);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(s[t]);d&&d.setUniforms(t,this.binderUniforms,h,{zoom:p});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[e];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new ui)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,_),g.drawElements(e,i.primitiveLength*y,g.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function Ii(t,e,i){const r=1/z(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const Pi=t.create(),Li=(e,i,r,n,o,s,a,l,c)=>{const u=i.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=t.create$1();"viewport"===u.properties.get("anchor")&&(t.fromRotation(d,-i.transform.angle),t.transformMat3(p,p,d));const f=u.properties.get("color"),m=i.transform,_={u_matrix:e,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+r,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Pi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(_.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],_.u_zoom_transition=a,_.u_inv_rot_matrix=c,_.u_merc_center=l,_.u_up_dir=m.projection.upVector(new t.CanonicalTileID(0,0,0),l[0]*t.EXTENT,l[1]*t.EXTENT),_.u_height_lift=s),_},zi=(e,i,r,n,o,s,a,l,c,u,h)=>{const p=Li(e,i,r,n,o,l,c,u,h),d={u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8};return t.extend(p,Ii(s,i,a),d)},Di=t=>({u_matrix:t}),Ri=(e,i,r,n)=>t.extend(Di(e),Ii(r,i,n)),Oi=(t,e)=>({u_matrix:t,u_world:e}),Fi=(e,i,r,n,o)=>t.extend(Ri(e,i,r,n),{u_world:o}),Bi=t.create(),ji=(e,i,r,n,o,s)=>{const a=e.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const e=t.globePixelsToTileUnits(a.zoom,i.canonical)*a._projectionScaler;c=Float32Array.from([e,0,0,e])}else c=a.calculatePixelsToTileUnitsMatrix(r);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(i.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Bi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=n,u.u_merc_center=o,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=t.globeToMercatorTransition(a.zoom);const e=o[0]*t.EXTENT,r=o[1]*t.EXTENT;u.u_up_dir=a.projection.upVector(new t.CanonicalTileID(0,0,0),e,r)}return u},Ni=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},Vi=(e,i,r,n)=>{const o=t.EXTENT/r.tileSize;return{u_matrix:e,u_camera_to_center_distance:i.getCameraToCenterDistance(n),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},Ui=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),$i=t.create(),Gi=(e,i,r,n,o,s,a)=>{const l=e.transform,c="globe"===l.projection.name,u=c?t.globePixelsToTileUnits(l.zoom,i.canonical)*l._projectionScaler:z(r,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:$i,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],h.u_zoom_transition=t.globeToMercatorTransition(l.zoom);const e=o[0]*t.EXTENT,r=o[1]*t.EXTENT;h.u_up_dir=l.projection.upVector(new t.CanonicalTileID(0,0,0),e,r)}return h},qi=(t,e,i,r,n,o,s,a)=>{const l=t.transform,c=l.calculatePixelsToTileUnitsMatrix(e),u={u_matrix:Wi(t,e,i,n),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Xi(i)){const i=Hi(e,t.transform);u.u_texsize=e.lineAtlasTexture.size,u.u_scale=[i,r.fromScale,r.toScale],u.u_mix=r.t}return u},Zi=(t,e,i,r,n,o)=>{const s=t.transform,a=Hi(e,s);return{u_matrix:Wi(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:o,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Hi(t,e){return 1/z(t,1,e.tileZoom)}function Wi(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Xi(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Qi=(t,e,i,r,n,o)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=n.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Yi(n.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function Yi(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Ji=t.create(),Ki=(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_)=>{const g=o.transform,y={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:g.width/g.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ji,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ji,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],y.u_zoom_transition=p,y.u_inv_rot_matrix=f,y.u_merc_center=d,y.u_camera_forward=g._camera.forward(),y.u_ecef_origin=t.globeECEFOrigin(g.globeMatrix,h.toUnwrapped()),y.u_tile_matrix=Float32Array.from(g.globeMatrix),y.u_up_vector=m),y},tr=(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_,g)=>t.extend(Ki(e,i,r,n,o,s,a,l,c,u,p,d,f,m,_,g),{u_gamma_scale:n?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+h}),er=(e,i,r,n,o,s,a,l,c,u,h,p,d,f,m,_)=>t.extend(tr(e,i,r,n,o,s,a,l,!0,c,!0,h,p,d,f,m,_),{u_texsize_icon:u,u_texture_icon:1}),ir=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),rr=(e,i,r,n,o,s)=>t.extend(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),o=i.imageManager.getPattern(t.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(r.tileID.canonical.x+r.tileID.wrap*l),h=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/z(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(n,s,r,o),{u_matrix:e,u_opacity:i}),nr={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.UniformMatrix2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),heatmapTexture:(e,i)=>({u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_dash_image:new t.Uniform1i(e,i.u_dash_image),u_gradient_image:new t.Uniform1i(e,i.u_gradient_image),u_image_height:new t.Uniform1f(e,i.u_image_height),u_texsize:new t.Uniform2f(e,i.u_texsize),u_scale:new t.Uniform3f(e,i.u_scale),u_mix:new t.Uniform1f(e,i.u_mix),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold),u_trim_offset:new t.Uniform2f(e,i.u_trim_offset)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights),u_perspective_transform:new t.Uniform2f(e,i.u_perspective_transform)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_cubemap:new t.Uniform1i(e,i.u_cubemap),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_center_direction:new t.Uniform3f(e,i.u_center_direction),u_radius:new t.Uniform1f(e,i.u_radius),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxCapture:(e,i)=>({u_matrix_3f:new t.UniformMatrix3f(e,i.u_matrix_3f),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_sun_intensity:new t.Uniform1f(e,i.u_sun_intensity),u_color_tint_r:new t.Uniform4f(e,i.u_color_tint_r),u_color_tint_m:new t.Uniform4f(e,i.u_color_tint_m),u_luminance:new t.Uniform1f(e,i.u_luminance)}),globeRaster:(e,i)=>({u_proj_matrix:new t.UniformMatrix4f(e,i.u_proj_matrix),u_globe_matrix:new t.UniformMatrix4f(e,i.u_globe_matrix),u_normalize_matrix:new t.UniformMatrix4f(e,i.u_normalize_matrix),u_merc_matrix:new t.UniformMatrix4f(e,i.u_merc_matrix),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_image0:new t.Uniform1i(e,i.u_image0),u_grid_matrix:new t.UniformMatrix3f(e,i.u_grid_matrix),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_viewport:new t.Uniform2f(e,i.u_viewport)}),globeAtmosphere:(e,i)=>({u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_horizon:new t.Uniform1f(e,i.u_horizon),u_transition:new t.Uniform1f(e,i.u_transition),u_fadeout_range:new t.Uniform1f(e,i.u_fadeout_range),u_color:new t.Uniform4f(e,i.u_color),u_high_color:new t.Uniform4f(e,i.u_high_color),u_space_color:new t.Uniform4f(e,i.u_space_color),u_star_intensity:new t.Uniform1f(e,i.u_star_intensity),u_star_density:new t.Uniform1f(e,i.u_star_density),u_star_size:new t.Uniform1f(e,i.u_star_size),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset),u_horizon_angle:new t.Uniform1f(e,i.u_horizon_angle),u_rotation_matrix:new t.UniformMatrix4f(e,i.u_rotation_matrix)})};let or;function sr(e,i,r,n,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=e.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m<n.length;m++){const _=n[m],g=i.getTile(_),y=g.getBucket(r);if(!y)continue;const v=be(_,y,u);let x=v;0===o[0]&&0===o[1]||(x=e.translatePosMatrix(v,g,o,s));const b=a?y.textCollisionBox:y.iconCollisionBox,w=y.collisionCircleArray;if(w.length>0){const e=t.create(),i=x;t.mul(e,y.placementInvProjMatrix,u.glCoordMatrix),t.mul(e,e,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:e,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(e.terrain&&e.terrain.setupElevationDraw(g,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,Vi(x,u,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=e.useProgram("collisionCircle"),_=new t.StructArrayLayout2f1f2i16;_.resize(4*d),_._trim();let g=0;for(const t of p)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],o=t.circleArray[i+2],s=t.circleArray[i+3];_.emplace(g++,r,n,o,s,0),_.emplace(g++,r,n,o,s,1),_.emplace(g++,r,n,o,s,2),_.emplace(g++,r,n,o,s,3)}(!or||or.length<2*d)&&(or=function(e){const i=2*e,r=new t.StructArrayLayout3ui6;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(d));const y=l.createIndexBuffer(or,!0),v=l.createVertexBuffer(_,t.collisionCircleLayout.members,!0);for(const i of p){const n={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(i.projection),u_viewport_size:[x.width,x.height]};m.draw(l,c.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,n,r.id,v,y,t.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,u.zoom)}var x;v.destroy(),y.destroy()}const ar=t.create();function lr(e,i,r,n,o,s){const{horizontalAlign:a,verticalAlign:l}=t.getAnchorAlignment(e),c=-(a-.5)*i,u=-(l-.5)*r,h=t.evaluateVariableOffset(e,n);return new t.pointGeometry((c/o+h[0])*s,(u/o+h[1])*s)}function cr(e,i,r,n,o,s,a,l,c,u,h){const p=e.text.placedSymbolArray,d=e.text.dynamicLayoutVertexArray,f=e.icon.dynamicLayoutVertexArray,m={},_=we(l,e.getProjection(),s),g=s.elevation,y=e.getProjection().upVectorScale(l.canonical,s.center.lat,s.worldSize);d.clear();for(let f=0;f<p.length;f++){const v=p.get(f),x=e.allowVerticalPlacement&&!v.placedOrientation,b=v.hidden||!v.crossTileID||x?null:n[v.crossTileID];if(b){const n=new t.pointGeometry(v.tileAnchorX,v.tileAnchorY),p=e.getProjection().upVector(l.canonical,n.x,n.y),f=g?g.getAtTileOffset(l,n.x,n.y):0,x=oe([v.projectedAnchorX+f*p[0]*y.metersToTile,v.projectedAnchorY+f*p[1]*y.metersToTile,v.projectedAnchorZ+f*p[2]*y.metersToTile],r?_:a),w=se(s.getCameraToCenterDistance(e.getProjection()),x.signedDistanceFromCamera);let T=o.evaluateSizeForFeature(e.textSizeData,u,v)*w/t.ONE_EM;r&&(T*=e.tilePixelRatio/c);const{width:M,height:E,anchor:C,textOffset:S,textScale:k}=b,A=lr(C,M,E,S,k,T);let I;if(r){const t=n.add(A),{x:i,y:r,z:o}=e.getProjection().projectTilePoint(t.x,t.y,l.canonical);I=oe([i+f*p[0]*y.metersToTile,r+f*p[1]*y.metersToTile,o+f*p[2]*y.metersToTile],a).point}else{const t=i?A.rotate(-s.angle):A;I=[x.point[0]+t.x,x.point[1]+t.y,0]}const P=e.allowVerticalPlacement&&v.placedOrientation===t.WritingMode.vertical?Math.PI/2:0;for(let e=0;e<v.numGlyphs;e++)t.addDynamicAttributes(d,I[0],I[1],I[2],P);h&&v.associatedIconIndex>=0&&(m[v.associatedIconIndex]={shiftedAnchor:I,angle:P})}else _e(v.numGlyphs,d)}if(h){f.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const r=i.get(e);if(r.hidden)_e(r.numGlyphs,f);else{const i=m[e];if(i)for(let e=0;e<r.numGlyphs;e++)t.addDynamicAttributes(f,i.shiftedAnchor[0],i.shiftedAnchor[1],i.shiftedAnchor[2],i.angle);else _e(r.numGlyphs,f)}}e.icon.dynamicLayoutVertexBuffer.updateData(f)}e.text.dynamicLayoutVertexBuffer.updateData(d)}function ur(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function hr(e,i,r,n,o,s,a,l,c,u,h,p){const d=e.context,f=d.gl,m=e.transform,_="map"===l,g="map"===c,y=_&&"point"!==r.layout.get("symbol-placement"),v=_&&!g&&!y,x=void 0!==r.layout.get("symbol-sort-key").constantOr(1);let b=!1;const w=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),T=[t.mercatorXfromLng(m.center.lng),t.mercatorYfromLat(m.center.lat)],M=r.layout.get("text-variable-anchor"),E="globe"===m.projection.name,C=[],S=[0,-1,0];let k=S;!E&&!m.mercatorFromTransition||_||(k=function(e){const i=e._camera.getWorldToCamera(e.worldSize,1),r=t.multiply([],i,e.globeMatrix);t.invert(r,r);const n=[0,0,0],o=[0,1,0,0];return t.transformMat4$1(o,o,r),n[0]=o[0],n[1]=o[1],n[2]=o[2],t.normalize(n,n),n}(m));for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c)continue;if("mercator"===c.projection.name&&E)continue;const h=o?c.text:c.icon;if(!h||c.fullyClipped||!h.segments.get().length)continue;const p=h.programConfigurations.get(r.id),d=o||c.sdfIcons,w=o?c.textSizeData:c.iconSizeData,A=g||0!==m.pitch,I=t.evaluateSizeForZoom(w,m.zoom);let P,L,z,D,R=[0,0],O=null;if(o){if(L=n.glyphAtlasTexture,z=f.LINEAR,P=n.glyphAtlasTexture.size,c.iconsInText){R=n.imageAtlasTexture.size,O=n.imageAtlasTexture;const t="composite"===w.kind||"camera"===w.kind;D=A||e.options.rotating||e.options.zooming||t?f.LINEAR:f.NEAREST}}else{const t=1!==r.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;L=n.imageAtlasTexture,z=d||e.options.rotating||e.options.zooming||t||A?f.LINEAR:f.NEAREST,P=n.imageAtlasTexture.size}const F="globe"===c.projection.name,B=F?k:S,j=F?t.globeToMercatorTransition(m.zoom):0,N=we(l,c.getProjection(),m),V=m.calculatePixelsToTileUnitsMatrix(n),U=ee(N,n.tileID.canonical,g,_,m,c.getProjection(),V),$=e.terrain&&g&&y?t.invert(t.create(),U):ar,G=re(N,n.tileID.canonical,g,_,m,c.getProjection(),V),q=M&&c.hasTextData(),Z="none"!==r.layout.get("icon-text-fit")&&q&&c.hasIconData();if(y){const t=m.elevation,i=t?t.getAtTileOffsetFunc(l,m.center.lat,m.worldSize,c.getProjection()):t=>[0,0,0],r=ie(N,n.tileID.canonical,g,_,m,c.getProjection(),V);le(c,N,e,o,r,G,g,u,i,l)}const H=y||o&&M||Z,W=e.translatePosMatrix(N,n,s,a),X=H?ar:U,Q=e.translatePosMatrix(G,n,s,a,!0),Y=c.getProjection().createInversionMatrix(m,l.canonical),J=[];e.terrain&&g&&J.push("PITCH_WITH_MAP_TERRAIN"),F&&J.push("PROJECTION_GLOBE_VIEW"),H&&J.push("PROJECTED_POS_ON_VIEWPORT");const K=d&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let tt;tt=d?c.iconsInText?er(w.kind,I,v,g,e,W,X,Q,P,R,l,j,T,Y,B,c.getProjection()):tr(w.kind,I,v,g,e,W,X,Q,o,P,!0,l,j,T,Y,B,c.getProjection()):Ki(w.kind,I,v,g,e,W,X,Q,o,P,l,j,T,Y,B,c.getProjection());const et={program:e.useProgram(ur(d,o,c),p,J),buffers:h,uniformValues:tt,atlasTexture:L,atlasTextureIcon:O,atlasInterpolation:z,atlasInterpolationIcon:D,isSDF:d,hasHalo:K,tile:n,labelPlaneMatrixInv:$};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)C.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:et})}else C.push({segments:h.segments,sortKey:0,state:et})}b&&C.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of C){const i=t.state;if(e.terrain&&e.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!E,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,pr(i.buffers,t.segments,r,e,i.program,w,h,p,n)),n.u_is_halo=0}pr(i.buffers,t.segments,r,e,i.program,w,h,p,i.uniformValues)}}function pr(e,i,r,n,o,s,a,l,c){const u=n.context;o.draw(u,u.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,r.id,e.layoutVertexBuffer,e.indexBuffer,i,r.paint,n.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer)}function dr(e,i,r,n,o,s,a){const l=e.context.gl,c=r.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=r.getCrossfadeParameters();let p,d,f,m,_;a?(d=u&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const g of n){const n=i.getTile(g);if(u&&!n.patternsLoaded())continue;const y=n.getBucket(r);if(!y)continue;e.prepareDrawTile();const v=y.programConfigurations.get(r.id),x=e.useProgram(d,v);u&&(e.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&v.setConstantPatternPositions(e,i)}const w=e.translatePosMatrix(g.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Fi(w,e,h,n,t):Oi(w,t)}else m=y.indexBuffer,_=y.segments,f=u?Ri(w,e,h,n):Di(w);e.prepareDrawProgram(e.context,x,g.toUnwrapped()),x.draw(e.context,p,o,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,f,r.id,y.layoutVertexBuffer,m,_,r.paint,e.transform.zoom,v)}}function fr(e,i,r,n,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=r.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?t.fillExtrusionHeightLift():0,_="globe"===u.projection.name,g=_?t.globeToMercatorTransition(u.zoom):0,y=[t.mercatorXfromLng(u.center.lng),t.mercatorYfromLat(u.center.lat)],v=[];_&&v.push("PROJECTION_GLOBE_VIEW");for(const x of n){const n=i.getTile(x),b=n.getBucket(r);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(r.id),T=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,v);if(e.terrain){const t=e.terrain;if(e.style.terrainSetForDrapingOnly())t.setupElevationDraw(n,T,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(t.setupElevationDraw(n,T,{useMeterToDem:!0}),mr(l,i,x,b,r,t),!b.centroidVertexBuffer){const t=T.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}}p&&(e.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const M=h.constantOr(null);if(M&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[M.to.toString()],i=t.patternPositions[M.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const E=e.translatePosMatrix(x.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),C=u.projection.createInversionMatrix(u,x.canonical),S=r.paint.get("fill-extrusion-vertical-gradient"),k=p?zi(E,e,S,f,x,d,n,m,g,y,C):Li(E,e,S,f,x,m,g,y,C);e.prepareDrawProgram(l,T,x.toUnwrapped()),T.draw(l,l.gl.TRIANGLES,o,s,a,t.CullFaceMode.backCCW,k,r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,r.paint,e.transform.zoom,w,e.terrain?b.centroidVertexBuffer:null,_?b.layoutVertexExtBuffer:null)}}function mr(e,i,r,n,o,s){const a=[e=>{let i=e.canonical.x-1,r=e.wrap;return i<0&&(i=(1<<e.canonical.z)-1,r--),new t.OverscaledTileID(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>{let i=e.canonical.x+1,r=e.wrap;return i===1<<e.canonical.z&&(i=0,r++),new t.OverscaledTileID(e.overscaledZ,r,e.canonical.z,i,e.canonical.y)},e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],l=t=>{const e=i.getSource().minzoom,r=t=>{const e=i.getTileByID(t);if(e&&e.hasData())return e.getBucket(o)},n=[0,-1,1];for(const i of n){if(t.overscaledZ+i<e)continue;const n=r(t.calculateScaledKey(t.overscaledZ+i));if(n)return n}},c=[0,0,0],u=(e,i)=>(c[0]=Math.min(e.min.y,i.min.y),c[1]=Math.max(e.max.y,i.max.y),c[2]=t.EXTENT-i.min.x>e.max.x?i.min.x-t.EXTENT:e.max.x,c),h=(e,i)=>(c[0]=Math.min(e.min.x,i.min.x),c[1]=Math.max(e.max.x,i.max.x),c[2]=t.EXTENT-i.min.y>e.max.y?i.min.y-t.EXTENT:e.max.y,c),p=[(t,e)=>u(t,e),(t,e)=>u(e,t),(t,e)=>h(t,e),(t,e)=>h(e,t)],d=new t.pointGeometry(0,0);let f,m,_;const g=(e,i,n,o,a)=>{const l=[[o?n:e,o?e:n,0],[o?n:i,o?i:n,0]],c=a<0?t.EXTENT+a:a,u=[o?c:(e+i)/2,o?(e+i)/2:c,0];return 0===n&&a<0||0!==n&&a>0?s.getForTilePoints(_,[u],!0,m):l.push(u),s.getForTilePoints(r,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let e=0;e<4;e++){const i=(e<2?1:5)-e,o=n.borders[e];if(0===o.length)continue;const c=_=a[e](r),u=l(c);if(!(u&&u instanceof t.FillExtrusionBucket&&u.enableTerrain))continue;if(n.borderDoneWithNeighborZ[e]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===n.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(r);if(!t||!t.dem)return;f=t}const h=u.borders[i];let y=0;const v=u.borderDoneWithNeighborZ[i]!==n.canonical.z;if(n.canonical.z===u.canonical.z){for(let r=0;r<o.length;r++){const s=n.featuresOnBorder[o[r]],a=s.borders[e];let l;for(;y<h.length&&(l=u.featuresOnBorder[h[y]],!(l.borders[i][1]>a[0]+3));)v&&u.encodeCentroid(void 0,l,!1),y++;if(l&&y<h.length){const r=y;let o=0;for(;!(l.borders[i][0]>a[1]-3)&&(o++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[r]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=r),n.encodeCentroid(void 0,s,!1),v&&u.encodeCentroid(void 0,l,!1);continue}const c=p[e](s,l),f=e%2?t.EXTENT-1:0;d.x=g(c[0],Math.min(t.EXTENT-1,c[1]),f,e<2,c[2]),d.y=0,n.encodeCentroid(d,s,!1),v&&u.encodeCentroid(d,l,!1)}else n.encodeCentroid(void 0,s,!1)}n.borderDoneWithNeighborZ[e]=u.canonical.z,n.needsCentroidUpdate=!0,v&&(u.borderDoneWithNeighborZ[i]=n.canonical.z,u.needsCentroidUpdate=!0)}else{for(const t of o)n.encodeCentroid(void 0,n.featuresOnBorder[t],!1);if(v){for(const t of h)u.encodeCentroid(void 0,u.featuresOnBorder[t],!1);u.borderDoneWithNeighborZ[i]=n.canonical.z,u.needsCentroidUpdate=!0}n.borderDoneWithNeighborZ[e]=u.canonical.z,n.needsCentroidUpdate=!0}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(e)}const _r=new t.Color(1,0,0,1),gr=new t.Color(0,1,0,1),yr=new t.Color(0,0,1,1),vr=new t.Color(1,0,1,1),xr=new t.Color(0,1,1,1);function br(t,e,i,r){Tr(t,0,e+i/2,t.transform.width,i,r)}function wr(t,e,i,r){Tr(t,e-i/2,0,i,t.transform.height,r)}function Tr(e,i,r,n,o,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,n*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Mr(e,i,r){const n=e.context,o=n.gl,s="globe"===e.transform.projection.name,a=r.projMatrix,l=e.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=i.getTileByID(r.key);e.terrain&&e.terrain.setupElevationDraw(c,l);const u=t.DepthMode.disabled,h=t.StencilMode.disabled,p=e.colorModeForRenderPass(),d="$debug";n.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(e.context,e.transform.projection):c._makeDebugTileBoundsBuffers(e.context,e.transform.projection);const f=c._tileDebugBuffer||e.debugBuffer,m=c._tileDebugIndexBuffer||e.debugIndexBuffer,_=c._tileDebugSegments||e.debugSegments;l.draw(n,o.LINE_STRIP,u,h,p,t.CullFaceMode.disabled,Ui(a,t.Color.red),d,f,m,_,null,null,null,c._globeTileDebugBorderBuffer);const g=c.latestRawTileData,y=Math.floor((g&&g.byteLength||0)/1024),v=i.getTile(r).tileSize,x=512/Math.min(v,512)*(r.overscaledZ/e.transform.zoom)*.5;let b=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(b+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||e.debugBuffer,T=c._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,M=c._tileDebugTextSegments||e.debugSegments;l.draw(n,o.TRIANGLES,u,h,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Ui(a,t.Color.transparent,x),d,w,T,M,null,null,null,c._globeTileDebugTextBuffer)}const Er=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Cr}=Er;function Sr(t,e,i,r){t.emplaceBack(e,i,r)}class kr{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Sr(this.vertexArray,-1,-1,1),Sr(this.vertexArray,1,-1,1),Sr(this.vertexArray,-1,1,1),Sr(this.vertexArray,1,1,1),Sr(this.vertexArray,-1,-1,-1),Sr(this.vertexArray,1,-1,-1),Sr(this.vertexArray,-1,1,-1),Sr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Cr),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Ar(e,i,r,n,o,s){const a=e.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,r,n)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),n),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Ir=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Pr{constructor(e){const i=new t.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new t.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(i,Ir.members),this.indexBuffer=e.createIndexBuffer(r),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Lr={symbol:function(e,i,r,n,o){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,i,r,n,o,s,a){const l=i.transform,c="map"===o,u="map"===s;for(const i of e){const e=n.getTile(i),o=e.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const s=t.evaluateSizeForZoom(o.textSizeData,l.zoom),h=we(i,o.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(e),d=ee(h,e.tileID.canonical,u,c,l,o.getProjection(),p),f="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(s){const r=Math.pow(2,l.zoom-e.tileID.overscaledZ);cr(o,c,u,a,t.symbolSize,l,d,i,r,s,f)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&hr(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,a),0!==r.paint.get("text-opacity").constantOr(1)&&hr(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(sr(e,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),sr(e,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,p=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),d=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="globe"===h.projection.name,_=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],g=[];for(let o=0;o<n.length;o++){const s=n[o],a=i.getTile(s),c=a.getBucket(r);if(!c||c.projection.name!==h.projection.name)continue;const u=c.programConfigurations.get(r.id),p=Ni(r);m&&p.push("PROJECTION_GLOBE_VIEW");const d=e.useProgram("circle",u,p),f=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,v=c.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),b={programConfiguration:u,program:d,layoutVertexBuffer:f,globeExtVertexBuffer:y,indexBuffer:v,uniformValues:ji(e,s,a,x,_,r),tile:a};if(l){const e=c.segments.get();for(const i of e)g.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:b})}else g.push({segments:c.segments,sortKey:0,state:b})}l&&g.sort(((t,e)=>t.sortKey-e.sortKey));const y={useDepthForOcclusion:!m};for(const i of g){const{programConfiguration:n,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:_,tile:g}=i.state,v=i.segments;e.terrain&&e.terrain.setupElevationDraw(g,o,y),e.prepareDrawProgram(c,o,g.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,p,d,f,t.CullFaceMode.disabled,_,r.id,s,l,v,r.paint,h.zoom,n,m?a:null)}},heatmap:function(e,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,s=o.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i,r){const n=t.gl,o=e.width*r,s=e.height*r;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=t.createFramebuffer(o,s,!1),function(t,e,i,r,n,o){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,n,o,0,s.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,0,e,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)}(o,e,r,"globe"===e.transform.projection.name?.5:.25),o.clear({color:t.Color.transparent});const c=e.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,d=[t.mercatorXfromLng(c.center.lng),t.mercatorYfromLat(c.center.lat)];for(let f=0;f<n.length;f++){const m=n[f];if(i.hasRenderableParent(m))continue;const _=i.getTile(m),g=_.getBucket(r);if(!g||g.projection.name!==c.projection.name)continue;const y=g.programConfigurations.get(r.id),v=e.useProgram("heatmap",y,h),{zoom:x}=e.transform;e.terrain&&e.terrain.setupElevationDraw(_,v),e.prepareDrawProgram(o,v,m.toUnwrapped());const b=c.projection.createInversionMatrix(c,m.canonical);v.draw(o,s.TRIANGLES,t.DepthMode.disabled,a,l,p,Gi(e,m,_,b,d,x,r.paint.get("heatmap-intensity")),r.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,r.paint,e.transform.zoom,y,u?g.globeExtVertexBuffer:null)}o.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,i){const r=e.context,n=r.gl,o=i.heatmapFbo;if(!o)return;r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new t.Texture(r,i.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,n.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,((t,e,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,i),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,n){if("translucent"!==e.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=e.terrain&&e.terrain.renderingToTexture?1:t.exported.devicePixelRatio,u=r.paint.get("line-dasharray"),h=u.constantOr(1),p=r.layout.get("line-cap"),d=r.paint.get("line-pattern"),f=d.constantOr(1),m=r.paint.get("line-gradient"),_=r.getCrossfadeParameters(),g=f?"linePattern":"line",y=e.context,v=y.gl,x=(t=>{const e=[];Xi(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET");const r=t.paint.get("line-pattern").constantOr(1),n=1!==t.paint.get("line-opacity").constantOr(1);return!r&&n&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(r);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const o of n){const n=i.getTile(o);if(f&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;e.prepareDrawTile();const w=s.programConfigurations.get(r.id),T=e.useProgram(g,w,x),M=d.constantOr(null);if(M&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[M.to.toString()],i=t.patternPositions[M.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const E=u.constantOr(null),C=p.constantOr(null);if(!f&&E&&C&&n.lineAtlas){const t=n.lineAtlas,e=t.getDash(E.to,C),i=t.getDash(E.from,C);e&&i&&w.setConstantPatternPositions(e,i)}let[S,k]=r.paint.get("line-trim-offset");if("round"===C||"square"===C){const t=1;S!==k&&(0===S&&(S-=t),1===k&&(k+=t))}const A=e.terrain?o.projMatrix:null,I=f?Zi(e,n,r,_,A,c):qi(e,n,r,_,A,s.lineClipsArray.length,c,[S,k]);if(m){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-o.canonical.z):1;l=t.clamp(t.nextPowerOfTwo(s.maxLineLength/t.EXTENT*1024*n),256,y.maxTextureSize)}n.gradient=t.renderColorRamp({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new t.Texture(y,n.gradient,v.RGBA),n.version=r.gradientVersion,a=n.texture}y.activeTexture.set(v.TEXTURE1),a.bind(r.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}h&&(y.activeTexture.set(v.TEXTURE0),n.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),w.updatePaintBuffers(_)),f&&(y.activeTexture.set(v.TEXTURE0),n.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),w.updatePaintBuffers(_)),e.prepareDrawProgram(y,T,o.toUnwrapped());const P=i=>{T.draw(y,v.TRIANGLES,a,i,l,t.CullFaceMode.disabled,I,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const i=e.stencilModeForClipping(o).ref;0===i&&e.terrain&&y.clear({stencil:0});const r={func:v.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,P(new t.StencilMode(r,i,255,v.KEEP,v.KEEP,v.INVERT)),I.u_alpha_discard_threshold=0,P(new t.StencilMode(r,i,255,v.KEEP,v.KEEP,v.KEEP))}else P(e.stencilModeForClipping(o))}b&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const o=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);dr(e,i,r,n,o,a,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const o=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);dr(e,i,r,n,o,a,!0)}},"fill-extrusion":function(e,i,r,n){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))fr(e,i,r,n,s,t.StencilMode.disabled,t.ColorMode.disabled),fr(e,i,r,n,s,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const o=e.colorModeForRenderPass();fr(e,i,r,n,s,t.StencilMode.disabled,o)}}},hillshade:function(e,i,r,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const o=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,u]="translucent"!==e.renderPass||l?[{},n]:e.stencilConfigForOverlap(n);for(const n of u){const o=i.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===e.renderPass)fi(e,o,r,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):c[n.overscaledZ];pi(e,n,o,r,s,t,a)}}o.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,i,r,n,o,s){if("translucent"!==e.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!n.length)return;const a=e.context,l=a.gl,c=i.getSource(),u=e.useProgram("raster"),h=e.colorModeForRenderPass(),p=e.terrain&&e.terrain.renderingToTexture,[d,f]=c instanceof It||p?[{},n]:e.stencilConfigForOverlap(n),m=f[f.length-1].overscaledZ,_=!e.options.moving;for(const n of f){const o=p?t.DepthMode.disabled:e.depthModeForSublayer(n.overscaledZ-m,1===r.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=n.toUnwrapped(),g=i.getTile(n);if(p&&(!g||!g.hasData()))continue;const y=p?n.projMatrix:e.transform.calculateProjMatrix(f,_),v=e.terrain&&p?e.terrain.stencilModeForRTTOverlap(n):d[n.overscaledZ],x=s?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(x);const b=i.findLoadedParent(n,0),w=Ti(g,b,i,e.transform,x);let T,M;e.terrain&&e.terrain.prepareDrawTile();const E="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(E,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(E,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),M=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(E,l.CLAMP_TO_EDGE);const C=Qi(y,M||[0,0],T||1,w,r,c instanceof It?c.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,u,f),c instanceof It)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,t.StencilMode.disabled,h,t.CullFaceMode.disabled,C,r.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:n,tileBoundsSegments:s}=e.getTileBoundsBuffers(g);u.draw(a,l.TRIANGLES,o,v,h,t.CullFaceMode.disabled,C,r.id,i,n,s)}}e.resetStencilClippingMasks()},background:function(e,i,r,n){const o=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=r.paint.get("background-pattern");if(e.isPatternMissing(h))return;const p=!h&&1===o.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==p)return;const d=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===p?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),_=e.useProgram(h?"backgroundPattern":"background");let g,y=n;y||(g=e.getBackgroundTiles(),y=Object.values(g).map((t=>t.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));const v=r.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),x=n?p.projMatrix:e.transform.calculateProjMatrix(y);e.prepareDrawTile();const b=i?i.getTile(p):g?g[p.key]:new t.Tile(p,u,c.zoom,e),w=h?rr(x,s,e,h,{tileID:p,tileSize:u},v):ir(x,s,o);e.prepareDrawProgram(a,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:M,tileBoundsSegments:E}=e.getTileBoundsBuffers(b);_.draw(a,l.TRIANGLES,f,d,m,t.CullFaceMode.disabled,w,r.id,T,M,E)}},sky:function(e,i,r){const n=e.transform,o="mercator"===n.projection.name||"globe"===n.projection.name?1:t.smoothstep(7,8,n.zoom),s=r.paint.get("sky-opacity")*o;if(0===s)return;const a=e.context,l=r.paint.get("sky-type"),c=new t.DepthMode(a.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===e.renderPass?r.needsSkyboxCapture(e)&&(function(e,i,r,n){const o=e.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!1),i.skyboxGeometry=new kr(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(e,!0),c=e.useProgram("skyboxCapture"),u=new Float64Array(16);t.identity(u),t.rotateY(u,u,.5*-Math.PI),Ar(o,i,c,u,l,0),t.identity(u),t.rotateY(u,u,.5*Math.PI),Ar(o,i,c,u,l,1),t.identity(u),t.rotateX(u,u,.5*-Math.PI),Ar(o,i,c,u,l,2),t.identity(u),t.rotateX(u,u,.5*Math.PI),Ar(o,i,c,u,l,3),t.identity(u),Ar(o,i,c,u,l,4),t.identity(u),t.rotateY(u,u,Math.PI),Ar(o,i,c,u,l,5),o.viewport.set([0,0,e.width,e.height])}(e,r),r.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,i,r,n,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((t,e,i,r,n)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(e,!1),0,n,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u):"gradient"===l&&"sky"===e.renderPass&&function(e,i,r,n,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new kr(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new t.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,i,r,n,o)=>({u_matrix:e,u_color_ramp:0,u_center_direction:i,u_radius:t.degToRad(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(e,!1),i.paint.get("sky-gradient-radius"),n,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u)},debug:function(t,e,i){for(let r=0;r<i.length;r++)Mr(t,e,i[r])},custom:function(e,i,r){const n=e.context,o=r.implementation;if(e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes("custom"))t.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===e.renderPass){const t=o.prerender;t&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),t.call(o,n.gl,e.transform.customLayerMatrix()),n.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(t.StencilMode.disabled);const i="3d"===o.renderingMode?new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,t.DepthMode.ReadOnly);n.setDepthMode(i),o.render(n.gl,e.transform.customLayerMatrix()),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}};class zr{constructor(e,i){this.context=new Ct(e),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=t.SourceCache.maxUnderzooming+t.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new We,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(t,e){const i=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Si(this,t));const r=this._terrain;this.transform.elevation=i?r:null,r.update(t,this.transform,e)}_updateFog(t){const e=t.fog;if(!e||"globe"===this.transform.projection.name||e.getOpacity(this.transform.pitch)<1||e.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=e.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,i){if(this.width=e*t.exported.devicePixelRatio,this.height=i*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const n=new t.StructArrayLayout2i4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(n,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const o=new t.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(t.EXTENT,0,t.EXTENT,0),o.emplaceBack(0,t.EXTENT,0,t.EXTENT),o.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(o,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout1ui2;for(const t of[0,1,3,2,0])a.emplaceBack(t);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=t.create();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new Pr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,i.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,i,r){if(!i||this.currentStencilSource===i.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(const e of r)if(void 0===this._tileClippingMaskIDs[e.key]){t=!0;break}if(!t)return}this.currentStencilSource=i.id;const n=this.context,o=n.gl;this.nextStencilID+r.length>256&&this.clearStencil(),n.setColorMode(t.ColorMode.disabled),n.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const r=i.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(r);s.draw(n,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(e.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new t.StencilMode({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const i=this.context.gl;return new t.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){const i=this.context.gl,r=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=r[r.length-1].overscaledZ,o=r[0].overscaledZ-n+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let r=0;r<o;r++)e[r+n]=new t.StencilMode({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[e,r]}return[{[n]:t.StencilMode.disabled},r]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new t.ColorMode([e.CONSTANT_COLOR,e.ONE],new t.Color(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?t.ColorMode.unblended:t.ColorMode.alphaBlended}depthModeForSublayer(e,i,r){if(!this.opaquePassEnabledForLayer())return t.DepthMode.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new t.DepthMode(r||this.context.gl.LEQUAL,i,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(t.exported.now()),this.imageManager.beginFrame();const r=this.style.order,n=this.style._sourceCaches;for(const t in n){const e=n[t];e.used&&e.prepare(this.context)}const o={},s={},a={};for(const t in n){const e=n[t];o[t]=e.getVisibleCoordinates(),s[t]=o[t].slice().reverse(),a[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<r.length;t++)if(this.style._layers[r[t]].is3D()){this.opaquePassCutoff=t;break}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new t.GlobeSharedBuffers(this.context)),t.isMapAuthenticated(this.context.gl)){this.renderPass="offscreen";for(const t of r){const i=this.style._layers[t],r=e._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?s[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}if(this.depthRangeFor3D=[0,1-(e.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:i.showOverdrawInspector?t.Color.black:t.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky())continue;const n=i?s[i.id]:void 0;this._renderTileClippingMasks(t,i,n),this.renderLayer(this,i,t,n)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,i){const r=e.context,n=r.gl,o=e.transform,s=new t.DepthMode(n.LEQUAL,t.DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=t.globeToMercatorTransition(o.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=t.identity$1([]);t.rotateY$1(p,p,-t.degToRad(o._center.lng)),t.rotateX$1(p,p,t.degToRad(o._center.lat)),t.rotateZ$1(p,p,o.angle),t.rotateX$1(p,p,-o._pitch);const d=t.fromQuat(new Float32Array(16),p),f=t.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=t.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),g=t.globeUseCustomAntiAliasing(e,r,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=e.frameCounter/1e3%1,v=t.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),b=Math.acos(x/v),w=((e,i,r,n,o,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:e,u_frustum_tr:i,u_frustum_br:r,u_frustum_bl:n,u_horizon:o,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,_,c,u,h,f,y,b,d);e.prepareDrawProgram(r,a);const T=e.atmosphereBuffer;T&&a.draw(r,n.TRIANGLES,s,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);t.isSky()&&this.renderLayer(this,i,t,i?s[i.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(t)){if(t.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const n=i?("symbol"===t.type?a:s)[i.id]:void 0;this._renderTileClippingMasks(t,i,i?o[i.id]:void 0),this.renderLayer(this,i,t,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let i=null;t.values(this.style._layers).forEach((t=>{const r=e._getLayerSourceCache(t);r&&!t.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom<r.getSource().maxzoom)&&(i=r)})),i&&this.options.showTileBoundaries&&Lr.debug(this,i,i.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;br(t,t.transform.height-(e.top||0),3,_r),br(t,e.bottom||0,3,gr),wr(t,e.left||0,3,yr),wr(t,t.transform.width-(e.right||0),3,vr);const i=t.transform.centerPoint;!function(t,e,i,r){Tr(t,e-1,i-10,2,20,r),Tr(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,xr)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(t.window.performance.now()),this.saveCanvasCopy())}}renderLayer(t,e,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes(i.type)||Lr[i.type](t,e,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const t=this.context.extTimerQuery,e=t.createQueryEXT();this.deferredRenderGpuTimeQueries.push(e),t.beginQueryEXT(t.TIME_ELAPSED_EXT,e)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){const t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),e[i]=o}return e}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;const e=this.context.extTimerQuery;let i=0;for(const r of t)i+=e.getQueryObjectEXT(r,e.QUERY_RESULT_EXT)/1e6,e.deleteQueryEXT(r);return i}translatePosMatrix(e,i,r,n,o){if(!r[0]&&!r[1])return e;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e]}const a=[o?r[0]:z(i,r[0],this.transform.zoom),o?r[1]:z(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return t.translate(l,e,a),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=Ai.cacheKey(t,n,e);return this.cache[o]||(this.cache[o]=new Ai(this.context,t,li[t],e,nr[t],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,i,r){if(this.terrain&&this.terrain.renderingToTexture)return;const n=this.style.fog;if(n){const o=n.getOpacity(this.transform.pitch),s=((e,i,r,n,o,s,a,l,c,u,h)=>{const p=e.transform,d=i.properties.get("color").toArray01();d[3]=n;const f=e.frameCounter/1e3%1;return{u_fog_matrix:r?p.calculateFogTileMatrix(r):e.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:t.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,n,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);i.setFogUniformValues(e,s)}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,i=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const n of r)i[n.key]=e[n.key]||new t.Tile(n,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Dr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),n=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Dr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Rr(e,i){const r=t.getColumn(e,3);t.fromQuat(e,i),t.setColumn(e,3,r)}function Or(e,i){const r=t.identity$1([]);return t.rotateZ$1(r,r,-i),t.rotateX$1(r,r,-e),r}function Fr(e,i){const r=[e[0],e[1],0],n=[i[0],i[1],0];if(t.length(r)>=1e-15){const e=t.normalize([],r);t.scale$2(n,e,t.dot(n,e)),i[0]=n[0],i[1]=n[1]}const o=t.cross([],i,e);if(t.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Or(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class Br{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){if(e){const i=e instanceof t.MercatorCoordinate?e:new t.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(i.x=t.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(e,i){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,n=this.position,o=t.MercatorCoordinate.fromLngLat(e,r),s=[o.x-n.x,o.y-n.y,o.z-n.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Fr(s,i)}setPitchBearing(e,i){this.orientation=Or(t.degToRad(e),t.degToRad(-i))}}class jr{constructor(e,i){this._transform=t.identity([]),this.orientation=i,this.position=e}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=t.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var i;e&&t.setColumn(this._transform,3,[(i=e)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||t.identity$1([]),e&&Rr(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=Or(t,e),Rr(this._transform,this._orientation)}forward(){const e=t.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=t.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=t.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,i){const r=new Float64Array(16);return t.invert(r,this.getWorldToCamera(e,i)),r}getWorldToCameraPosition(e,i,r){const n=this.position;t.scale$2(n,n,-e);const o=new Float64Array(16);return t.fromScaling(o,[r,r,r]),t.translate(o,o,n),o[10]*=i,o}getWorldToCamera(e,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return t.conjugate(n,this._orientation),t.scale$2(o,o,-e),t.fromQuat(r,n),t.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(e,i,r,n){const o=new Float64Array(16);return t.perspective(o,e,i,r,n),o}getDistanceToElevation(e){const i=0===e?0:t.mercatorZfromAltitude(e,this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new jr([...this.position],[...this.orientation])}}function Nr(e,i){const r=Ur(e.projection,e.zoom,e.width,e.height),n=function(e,i,r,n,o){const s=new t.LngLat(r.lng-180*$r,r.lat),a=new t.LngLat(r.lng+180*$r,r.lat),l=e.project(s.lng,s.lat),c=e.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=t.MercatorCoordinate.fromLngLat(r);h.y=t.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=e.project(p.lng,p.lat),f=t.MercatorCoordinate.fromLngLat(p);f.x+=$r;const m=f.toLngLat(),_=e.project(m.lng,m.lat),g=qr(_.x-d.x,_.y-d.y,u),y=t.MercatorCoordinate.fromLngLat(p);y.y+=$r;const v=y.toLngLat(),x=e.project(v.lng,v.lat),b=qr(x.x-d.x,x.y-d.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=t.identity([]);t.rotateZ(T,T,-u*(1-(o?0:n)));const M=t.identity([]);return t.scale(M,M,[1,1-(1-w)*n,1]),M[4]=-b.x/b.y*n,t.rotateZ(M,M,u),t.multiply(M,T,M),M}(e.projection,0,e.center,r,i),o=Vr(e);return t.scale(n,n,[o,o,1]),n}function Vr(e){const i=e.projection,r=Ur(e.projection,e.zoom,e.width,e.height),n=Gr(i,e.center),o=Gr(i,t.LngLat.convert(i.center));return Math.pow(2,n*r+(1-r)*o)}function Ur(e,i,r,n,o=1/0){const s=e.range;if(!s)return 0;const a=Math.min(o,Math.max(r,n)),l=Math.log(a/1024)/Math.LN2;return t.smoothstep(s[0]+l,s[1]+l,i)}const $r=1/4e4;function Gr(e,i){const r=t.clamp(i.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),n=new t.LngLat(i.lng-180*$r,r),o=new t.LngLat(i.lng+180*$r,r),s=e.project(n.lng,r),a=e.project(o.lng,r),l=t.MercatorCoordinate.fromLngLat(n),c=t.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function qr(t,e,i){const r=Math.cos(i),n=Math.sin(i);return{x:t*r-e*n,y:t*n+e*r}}class Zr{constructor(e,i,r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Dr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new jr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const t=new Zr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){const e=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||e)&&this._updateCameraOnTerrain(),(t||e)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const n=!e(r,this.getProjection());return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.pointGeometry(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const i=-e*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+o*a,t[1]=n*l+s*a,t[2]=r*-a+o*l,t[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<i.length;s++){const a=new t.pointGeometry(i[s][0]*this.width,r+i[s][1]*(this.height-r)),l=e.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const t=this._seaLevelZoom,e=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*e,r=this._mercatorZfromZoom(t),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(e){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let r;r=e.z<this._camera.position[2]?[i.x,i.y,i.z]:[e.x,e.y,e.z];const n=t.length(t.sub([],this._camera.position,r));return t.clamp(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let i=!1;if(e.orientation&&!t.exactEquals(e.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(e.orientation)),e.position){const r=[e.position.x,e.position.y,e.position.z];t.exactEquals$1(r,this._camera.position)||(this._setCameraPosition(r),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,i=new Br;return i.position=new t.MercatorCoordinate(e[0],e[1],e[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(e){if(!t.length$1(e))return!1;t.normalize$1(e,e);const i=t.transformQuat([],[0,0,-1],e),r=t.transformQuat([],[0,-1,0],e);if(r[2]<0)return!1;const n=Fr(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(e){const i=this.zoomScale(this.minZoom)*this.tileSize,r=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;e[2]=t.clamp(e[2],n/r,n/i),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const i=[new t.UnwrappedTileID(0,e)];if(this.renderWorldCopies){const r=this.pointCoordinate(new t.pointGeometry(0,0)),n=this.pointCoordinate(new t.pointGeometry(this.width,0)),o=this.pointCoordinate(new t.pointGeometry(this.width,this.height)),s=this.pointCoordinate(new t.pointGeometry(0,this.height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new t.UnwrappedTileID(r,e))}return i}coveringTiles(e){let i=this.coveringZoomLevel(e);const r=i,n=this.elevation&&!e.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==e.minzoom&&i<e.minzoom)return[];void 0!==e.maxzoom&&i>e.maxzoom&&(i=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<i,c=[l*s.x,l*s.y,0],u="globe"===this.projection.name,h=!u,p=t.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,h),d=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*t.mercatorZfromAltitude(1,this.center.lat),m=this._camera.position[2]/t.mercatorZfromAltitude(1,this.center.lat),_=[l*d.x,l*d.y,m*(h?1:f)],g=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?i:0,v=e.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,x=e.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?Vr(this):1,w=e=>{const i=1/4e4,r=new t.MercatorCoordinate(e.x+i,e.y,e.z),n=new t.MercatorCoordinate(e.x,e.y+i,e.z),o=e.toLngLat(),s=r.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},T=e=>{const i=v,r=x;return{aabb:t.tileAABB(this,l,0,0,0,e,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:e,fullyVisible:!1}},M=[];let E=[];const C=i,S=e.reparseOverscaled?r:i,k=t=>t*t,A=k((m-this._centerAltitude)*f),I=t=>{if(!this._elevation||!t.tileID||!o)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=P(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},P=e=>{if(e.zoom<y)return!0;if(e.zoom===C)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const i=e.aabb.distanceX(_),o=e.aabb.distanceY(_);let s=A,l=1;if(u){s=k(e.aabb.distanceZ(_));const i=Math.pow(2,e.zoom),r=t.latFromMercatorY((e.y+1)/i),n=t.latFromMercatorY(e.y/i),o=Math.min(Math.max(a,r),n),c=t.circumferenceAtLatitude(o)/t.circumferenceAtLatitude(a);if(l=o===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=t.GLOBE_ZOOM_THRESHOLD_MIN&&e.zoom===C-1&&c>=.9)return!0}else if(n&&(s=k(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,e.zoom),r=w(new t.MercatorCoordinate((e.x+.5)/i,(e.y+.5)/i));l=r>.85?1:r}const c=i*i+o*o+s;return c<k((1<<C-e.zoom)*g*l*((t,e)=>{if(e*k(.707)<t)return 1;const i=Math.sqrt(e/t);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,A),c))};if(this.renderWorldCopies)for(let t=1;t<=3;t++)M.push(T(-t)),M.push(T(t));for(M.push(T(0));M.length>0;){const r=M.pop(),s=r.x,a=r.y;let h=r.fullyVisible;if(!h){const t=r.aabb.intersects(p);if(0===t)continue;h=2===t}if(r.zoom!==C&&P(r))for(let e=0;e<4;e++){const i=(s<<1)+e%2,c=(a<<1)+(e>>1),p={aabb:o?r.aabb.quadrant(e):t.tileAABB(this,l,r.zoom+1,i,c,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:c,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};n&&!u&&(p.tileID=new t.OverscaledTileID(r.zoom+1===C?S:r.zoom+1,r.wrap,r.zoom+1,i,c),I(p)),M.push(p)}else{const n=r.zoom===C?S:r.zoom;if(e.minzoom&&e.minzoom>n)continue;const o=c[0]-(.5+s+(r.wrap<<r.zoom))*(1<<i-r.zoom),l=c[1]-.5-a,u=r.tileID?r.tileID:new t.OverscaledTileID(n,r.wrap,r.zoom,s,a);E.push({tileID:u,distanceSq:o*o+l*l})}}if(this.fogCullDistSq){const i=this.fogCullDistSq,r=this.horizonLineFromTop();E=E.filter((n=>{const o=[0,0,0,1],s=[t.EXTENT,t.EXTENT,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());t.transformMat4$1(o,o,a),t.transformMat4$1(s,s,a);const l=t.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;e.isTerrainDEM||(o=u.getMinMaxForTile(n.tileID)),o||(o={min:x,max:v});const s=t.furthestTileCorner(this.rotation),a=[s[0]*t.EXTENT,s[1]*t.EXTENT,o.max];t.transformMat4(a,a,i),c=(1-a[1])*this.height*.5<r}return l<i||c}))}return E.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),r=this.projection.project(e.lng,i);return new t.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,i){let r,n;const o=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;r=(i.x-o.x)/t,n=(i.y-o.y)/t}else{const t=this.pointCoordinate(i),e=this.pointCoordinate(o);r=t.x-e.x,n=t.y-e.y}const s=this.locationCoordinate(e);this.setLocation(new t.MercatorCoordinate(s.x-r,s.y-n))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e,i){const r=i?t.mercatorZfromAltitude(i,e.lat):void 0,n=this.projection.project(e.lng,e.lat);return new t.MercatorCoordinate(n.x,n.y,r)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(e,i){const r=null!=i?i:this._centerAltitude,n=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.transformMat4$1(n,n,this.pixelMatrixInverse),t.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];t.scale$1(n,n,1/n[3]),t.scale$1(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(e){const i=[e.x,e.y,0,1],r=[e.x,e.y,1,1];return t.transformMat4$1(i,i,this.pixelMatrixInverse),t.transformMat4$1(r,r,this.pixelMatrixInverse),t.scale$1(i,i,1/i[3]),t.scale$1(r,r,1/r[3]),i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,r[2]=t.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,t.scale$1(i,i,1/this.worldSize),t.scale$1(r,r,1/this.worldSize),new t.Ray([i[0],i[1],i[2]],t.normalize([],t.sub([],r,i)))}rayIntersectionCoordinate(e){const{p0:i,p1:r,t:n}=e,o=t.mercatorZfromAltitude(i[2],this._center.lat),s=t.mercatorZfromAltitude(r[2],this._center.lat);return new t.MercatorCoordinate(t.number(i[0],r[0],n)/this.worldSize,t.number(i[1],r[1],n)/this.worldSize,t.number(o,s,n))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new t.MercatorCoordinate(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(e.y>n)return this.pointCoordinate(e);const o=.02*n,s=e.clone();for(let e=0;e<10&&n-r>o;e++){s.y=t.number(r,n,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(n=s.y,i=e):r=s.y}return i?new t.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}_coordinatePoint(e,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,n=[e.x*this.worldSize,e.y*this.worldSize,r+e.toAltitude(),1];return t.transformMat4$1(n,n,this.pixelMatrix),n[3]>0?new t.pointGeometry(n[0]/n[3],n[1]/n[3]):new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,i){const r=new t.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),n=new t.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new t.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new t.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(r,e),l=this.pointCoordinate(n,e);const c=this.pointCoordinate(o,i),u=this.pointCoordinate(s,i),h=(t,e)=>(e.y-t.y)/(e.x-t.x);return a.y>1&&l.y>=0?a=new t.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new t.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new t.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new t.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new t.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBounds(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=t.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=t.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=t.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=t.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,e){return this.projection.createTileMatrix(this,e,t)}calculateDistanceTileData(e){const i=e.key,r=this._distanceTileDataCache;if(r[i])return r[i];const n=e.canonical,o=1/this.height,s=this.cameraWorldSize/this.zoomScale(n.z),a=(n.x+Math.pow(2,n.z)*e.wrap)*s,l=n.y*s,c=this.point,u=this.angle,h=Math.sin(-u),p=-Math.cos(-u);return r[i]={bearing:[h,p],center:[(c.x-a)*o,(c.y-l)*o],scale:s/t.EXTENT*o},r[i]}calculateFogTileMatrix(e){const i=e.key,r=this._fogTileMatrixCache;if(r[i])return r[i];const n=this.projection.createTileMatrix(this,this.cameraWorldSize,e);return t.multiply(n,this.worldToFogMatrix,n),r[i]=new Float32Array(n),r[i]}calculateProjMatrix(e,i=!1){const r=e.key,n=i?this._alignedProjMatrixCache:this._projMatrixCache;if(n[r])return n[r];const o=this.calculatePosMatrix(e,this.worldSize);return t.multiply(o,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.alignedProjMatrix:this.projMatrix,o),n[r]=new Float32Array(o),n[r]}calculatePixelsToTileUnitsMatrix(e){const i=e.tileID.key,r=this._pixelsToTileUnitsCache;if(r[i])return r[i];const n=function(e,i){const{scale:r}=e.tileTransform,n=r*t.EXTENT/(e.tileSize*Math.pow(2,i.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return o=new Float32Array(4),l=(s=i.inverseAdjustmentMatrix)[1],c=s[2],u=s[3],p=(a=[n,n])[1],o[0]=s[0]*(h=a[0]),o[1]=l*h,o[2]=c*p,o[3]=u*p,o;var o,s,a,l,c,u,h,p}(e,this);return r[i]=n,r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const i=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=this._camera.forward(),o=t.mercatorZfromAltitude(1,this._center.lat);r[2]/=o,n[2]/=o,t.normalize(n,n);const s=e.raycast(r,n,e.exaggeration());if(s){const e=t.scaleAndAdd([],r,n,s),i=new t.MercatorCoordinate(e[0],e[1],t.mercatorZfromAltitude(e[2],t.latFromMercatorY(e[1]))),a=(i.z+t.length([i.x-r[0],i.y-r[1],i.z-r[2]*o]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const i=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=e.getAtPointOrZero(new t.MercatorCoordinate(...r)),o=this._minimumHeightOverTerrain()*Math.cos(t.degToRad(this._maxPitch)),s=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*n;if(s<o){const e=this.locationCoordinate(this._center,this._centerAltitude),i=[e.x-r[0],e.y-r[1],e.z-r[2]],n=t.length(i);i[2]-=(o-s)/this._projectionScaler;const a=t.length(i);if(0===a)return;t.scale$2(i,i,n/a*this._projectionScaler),this._camera.position=[e.x-i[0],e.y-i[1],e.z*this._projectionScaler-i[2]],this._camera.orientation=Fr(i,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const e=this.center;return e.lat=t.clamp(e.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(e.lng=t.clamp(e.lng,this.minLng,this.maxLng)),this.center=e,void(this._constraining=!1)}const e=this._unmodified,{x:i,y:r}=this.point;let n=0,o=i,s=r;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(r-l<c&&(s=c+l),r+l>u&&(s=u-l),u-c<this.height&&(n=Math.max(n,this.height/(u-c)),s=(u+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const t=this.worldMinX*this.scale,e=this.worldMaxX*this.scale,r=this.worldSize/2-(t+e)/2;o=(i+r+this.worldSize)%this.worldSize-r,o-a<t&&(o=t+a),o+a>e&&(o=e-a),e-t<this.width&&(n=Math.max(n,this.width/(e-t)),o=(e+t)/2)}o===i&&s===r||(this.center=this.unproject(new t.pointGeometry(o,s))),n&&(this.zoom+=this.scaleZoom(n)),this._constrainCameraAltitude(),this._unmodified=e,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,i=this.pixelsPerMeter;if("globe"===this.projection.name){const e=t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,i=t.mercatorZfromAltitude(1,t.GLOBE_SCALE_MATCH_LATITUDE)*this.worldSize;this._mercatorScaleRatio=e/i}const r=Ur(this.projection,this.zoom,this.width,this.height,1024);this._projectionScaler=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,r),this.cameraToCenterDistance=this.getCameraToCenterDistance(this.projection),this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const n=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?i:1),o=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height;let s=t.mul([],o,n);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),i=t.identity([]);t.translate(i,i,[e.x*this.worldSize,e.y*this.worldSize,0]),t.multiply(i,i,Nr(this)),t.translate(i,i,[-e.x*this.worldSize,-e.y*this.worldSize,0]),t.multiply(s,s,i),this.inverseAdjustmentMatrix=function(t){const e=Nr(t,!0);return y([],[e[0],e[1],e[4],e[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=t.scale([],s,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=s,this.invProjMatrix=t.invert(new Float64Array(16),this.projMatrix);const a=t.invert([],o);this.frustumCorners=t.FrustumCorners.fromInvProjectionMatrix(a,this.horizonLineFromTop(),this.height);const l=new Float32Array(16);t.identity(l),t.scale(l,l,[1,-1,1]),t.rotateX(l,l,this._pitch),t.rotateZ(l,l,this.angle);const c=t.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),u=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;c[8]=2*-e.x/this.width,c[9]=2*(e.y+u)/this.height,this.skyboxMatrix=t.multiply(l,c,l);const h=this.point,p=h.x,d=h.y,f=this.width%2/2,m=this.height%2/2,_=Math.cos(this.angle),g=Math.sin(this.angle),v=p-Math.round(p)+_*f+g*m,x=d-Math.round(d)+_*m+g*f,b=new Float64Array(s);if(t.translate(b,b,[v>.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,s=t.create(),t.scale(s,s,[this.width/2,-this.height/2,1]),t.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=t.create(),t.scale(s,s,[1,-1,1]),t.translate(s,s,[-1,-1,0]),t.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=t.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(e,e,n),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height/this._projectionScaler,o=[e,e,i];t.scale$2(o,o,n),t.scale$2(r,r,-1),t.multiply$2(r,r,o);const s=t.create();t.translate(s,s,r),t.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,i,n)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,t/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=e[2];let n=1;r>0&&(n=Math.min((i-this._camera.position[2])/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,n),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,i,a),this._pitch=t.clamp(r,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(n,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(t.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,i){const r=Math.min(e.x,i.x),n=Math.max(e.x,i.x),o=Math.min(e.y,i.y),s=Math.max(e.y,i.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new t.pointGeometry(r,o),new t.pointGeometry(n,s),new t.pointGeometry(r,s),new t.pointGeometry(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const t of a){const e=this.pointRayIntersection(t);if(e.t<0)return!0;const i=this.rayIntersectionCoordinate(e);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.pointGeometry(0,0),new t.pointGeometry(this.width,this.height))}zoomDeltaToMovement(e,i){const r=t.length(t.sub([],this._camera.position,e)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const n=Math.max(r[3],1e-6);return[r[0]/n,r[1]/n,r[2]/n,n]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.pointGeometry(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}}getCameraToCenterDistance(t){const e=Ur(t,this.zoom,this.width,this.height,1024),i=t.pixelSpaceConversion(this.center.lat,this.worldSize,e);return.5/Math.tan(.5*this._fov)*this.height*i}}function Hr(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,e),i=!1)};return()=>(i=!0,r||n(),r)}class Wr{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Hr(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(e){const i=this._map;if(!i)return"";const r=i.getCenter(),n=Math.round(100*i.getZoom())/100,o=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,o),a=Math.round(r.lng*s)/s,l=Math.round(r.lat*s)/s,c=i.getBearing(),u=i.getPitch();let h="";if(h+=e?`/${a}/${l}/${n}`:`${n}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const e=this._hashName;let i=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(i=!0,`${r}=${h}`):t})).filter((t=>t));return i||r.push(`${e}=${h}`),`#${r.join("&")}`}return`#${h}`}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}const Xr={linearity:.3,easing:t.bezier(0,0,.3,1)},Qr=t.extend({deceleration:2500,maxSpeed:1400},Xr),Yr=t.extend({deceleration:20,maxSpeed:1400},Xr),Jr=t.extend({deceleration:1e3,maxSpeed:360},Xr),Kr=t.extend({deceleration:1e3,maxSpeed:90},Xr);class tn{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=rn(i.pan.mag(),r,t.extend({},Qr,e||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,en(n,o)}if(i.zoom){const t=rn(i.zoom,r,Yr);n.zoom=this._map.transform.zoom+t.amount,en(n,t)}if(i.bearing){const e=rn(i.bearing,r,Jr);n.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),en(n,e)}if(i.pitch){const t=rn(i.pitch,r,Kr);n.pitch=this._map.transform.pitch+t.amount,en(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function en(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function rn(e,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=t.clamp(e*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class nn extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r,n={}){const o=f(i.getCanvasContainer(),r),s=i.unproject(o);super(e,t.extend({point:o,lngLat:s,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class on extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r){const n="touchend"===e?r.changedTouches:r.touches,o=m(i.getCanvasContainer(),n),s=o.map((t=>i.unproject(t))),a=o.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class sn extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class an{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new sn(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new nn(t.type,this._map,t))}mouseup(t){this._map.fire(new nn(t.type,this._map,t))}preclick(e){const i=t.extend({},e);i.type="preclick",this._map.fire(new nn(i.type,this._map,i))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new nn(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new nn(t.type,this._map,t))}mouseover(t){this._map.fire(new nn(t.type,this._map,t))}mouseout(t){this._map.fire(new nn(t.type,this._map,t))}touchstart(t){return this._firePreventable(new on(t.type,this._map,t))}touchmove(t){this._map.fire(new on(t.type,this._map,t))}touchend(t){this._map.fire(new on(t.type,this._map,t))}touchcancel(t){this._map.fire(new on(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new nn(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new nn(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cn{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(u(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),a=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=s-n+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,n=i;if(this.reset(),d(),r.x!==n.x||r.y!==n.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function un(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class hn{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=un(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=un(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class pn{constructor(t){this.singleTap=new hn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class dn{constructor(){this._zoomIn=new pn({numTouches:1,numTaps:2}),this._zoomOut=new pn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fn={0:1,2:2};class mn{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=_(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=fn[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&_(t)===this._eventButton&&(this._moved&&d(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _n extends mn{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class gn extends mn{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class yn extends mn{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class vn{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),t.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new t.pointGeometry(0,0)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.preventDefault(),this._calculateTransform(t,e,i)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const n=un(r,i),o=new t.pointGeometry(0,0),s=new t.pointGeometry(0,0);let a=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(o._add(e),s._add(e.sub(i)),a++,n[t]=e)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class xn{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const r=this._firstTwoTouches;if(!r)return;t.preventDefault();const[n,o]=r,s=bn(i,e,n),a=bn(i,e,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=bn(i,e,r),s=bn(i,e,n);o&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function bn(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function wn(t,e){return Math.log(t/e)/Math.LN2}class Tn extends xn{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(wn(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:wn(this._distance,i),pinchAround:e}}}function Mn(t,e){return 180*t.angleWith(e)/Math.PI}class En extends xn{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Mn(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Mn(t,this._startVector);return Math.abs(i)<e}}function Cn(t){return Math.abs(t.y)>Math.abs(t.x)}class Sn extends xn{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Cn(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),o=t[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return Cn(t)&&Cn(e)&&o}}const kn={panStep:100,bearingStep:15,pitchStep:10};class An{constructor(){const t=kn;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:In,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function In(t){return t*(2-t)}const Pn=4.000244140625;class Ln{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%Pn==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=f(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform,i=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Pn?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),i=o(e);s=t.number(n,r,i),e<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.bezier(o,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!t.window.document.fullscreenElement||!!t.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class zn{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Dn{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rn{constructor(){this._tap=new pn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class On{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fn{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Bn{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const jn=t=>t.zoom||t.drag||t.pitch||t.rotate;class Nn extends t.Event{}class Vn{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,i){const r=t.sub([],i,e);this.radius=t.length(r[2]<0?t.div([],r,this.constants):[r[0],r[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$1(e,e,this.constants);const i=t.scale$2([],e,this.radius);if(i[2]>0){const e=t.scale$2([],[0,0,1],t.dot(i,[0,0,1])),r=t.scale$2([],t.normalize([],[i[0],i[1],0]),this.radius),n=t.add([],i,t.scale$2([],t.sub([],t.add([],r,e),i),2));i[0]=n[0],i[1]=n[1]}return i}}function Un(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class $n{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new tn(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Vn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,i,r]of this._listeners)e.addEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,i,r]of this._listeners)e.removeEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new an(e,t));const r=e.boxZoom=new cn(e,t);this._add("boxZoom",r);const n=new dn,o=new Dn;e.doubleClickZoom=new zn(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Rn;this._add("tapDragZoom",s);const a=e.touchPitch=new Sn(e);this._add("touchPitch",a);const l=new gn(t),c=new yn(t);e.dragRotate=new Fn(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new _n(t),h=new vn(e,t);e.dragPan=new On(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new En,d=new Tn;e.touchZoomRotate=new Bn(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ln(e));const f=e.scrollZoom=new Ln(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new An;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!jn(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,n={needsRenderFrame:!1},o={},s={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,t);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[e||t.type]&&(h=c[e||t.type](t,l,a),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const t in this._previousActiveHandlers)s[t]||(c[t]=r);this._previousActiveHandlers=s,(Object.keys(c).length||Un(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Un(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,n,o){if(!r)return;t.extend(e,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.aroundCoord&&(e.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.extend(i,o),t.extend(r,s);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const n=this._map,o=n.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Un(e)){const t=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",t!==o.zoom&&this._map._update(!0)}if(!Un(e))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=e;void 0!==d&&(h=d),(t=>i.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a){const e=o.pointCoordinate(h);if("globe"===o.projection.name){const i=t.latFromMercatorY(e.y),r=o.center.lat,n=Math.min(t.mercatorZfromAltitude(1,i)/t.mercatorZfromAltitude(1,r),2);a=a.rotate(-o.angle),f[0]=-a.x/o.worldSize*n,f[1]=-a.y/o.worldSize*n}else{const t=o.pointCoordinate(h.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const m=o.zoom,_=[0,0,0];if(l){const e=s(p||o.pointCoordinate3D(h)),i={dir:t.normalize([],t.sub([],e,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(e,l);t.scale$2(_,i.dir,r)}}const g=t.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const n=jn(this._eventsInProgress),o=jn(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,a[`${t}end`]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=jn(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;e?(i(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:l})):(this._map.fire(new t.Event("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new t.Event(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{this._frameId=void 0,this.handleEvent(new Nn("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Gn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class qn extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(e,i){"globe"===this.transform.projection.name&&t.warnOnce('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),e=t.LngLatBounds.convert(e);const r=i&&i.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,i)}_extendCameraOptions(e){const i={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=t.extend({padding:i,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t}}return e.padding=t.extend(i,e.padding),e}_cameraForBoxAndBearing(e,i,r,n){const o=this._extendCameraOptions(n),s=this.transform,a=s.padding,l=s.project(t.LngLat.convert(e)),c=s.project(t.LngLat.convert(i)),u=new t.pointGeometry(l.x,c.y),h=new t.pointGeometry(c.x,l.y),p=-t.degToRad(r),d=l.rotate(p),f=c.rotate(p),m=u.rotate(p),_=h.rotate(p),g=new t.pointGeometry(Math.max(d.x,f.x,m.x,_.x),Math.max(d.y,f.y,m.y,_.y)),y=new t.pointGeometry(Math.min(d.x,f.x,m.x,_.x),Math.min(d.y,f.y,m.y,_.y)),v=g.sub(y),x=(s.width-((a.left||0)+(a.right||0)+o.padding.left+o.padding.right))/v.x,b=(s.height-((a.top||0)+(a.bottom||0)+o.padding.top+o.padding.bottom))/v.y;if(b<0||x<0)return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const w=Math.min(s.scaleZoom(s.scale*Math.min(x,b)),o.maxZoom),T="number"==typeof o.offset.x&&"number"==typeof o.offset.y?new t.pointGeometry(o.offset.x,o.offset.y):t.pointGeometry.convert(o.offset),M=new t.pointGeometry((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(r*Math.PI/180),E=T.add(M).mult(s.scale/s.zoomScale(w));return{center:s.unproject(l.add(c).div(2).sub(E)),zoom:w,bearing:r}}_cameraForBox(e,i,r,n,o){const s=this._extendCameraOptions(o);r=r||0,n=n||0,e=t.LngLat.convert(e),i=t.LngLat.convert(i);const a=this.transform.clone();a.padding=s.padding;const l=this.getFreeCameraOptions(),c=new t.LngLat(.5*(e.lng+i.lng),.5*(e.lat+i.lat)),u=.5*(r+n);if(a._camera.position[2]<t.mercatorZfromAltitude(u,c.lat))return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(c),a.setFreeCameraOptions(l);const h=t.MercatorCoordinate.fromLngLat(e),p=t.MercatorCoordinate.fromLngLat(i),d=a.pointRayIntersection(a.centerPoint,u),f=[(m=a.rayIntersectionCoordinate(d)).x,m.y,m.z];var m;const _=a.screenPointToMercatorRay(a.centerPoint),g="globe"!==a.projection.name;let y,v=0;do{const i=Math.floor(a.zoom),o=1<<i,s=Math.min(o*h.x,o*p.x),l=Math.min(o*h.y,o*p.y),c=Math.max(o*h.x,o*p.x),u=Math.max(o*h.y,o*p.y),d=new t.Aabb([s,l,r],[c,u,n]),m=t.Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,i,g);if(2!==d.intersects(m)){y&&(a._camera.position=t.scaleAndAdd([],a._camera.position,_.dir,-y),a._updateStateFromCamera());break}const v=t.sub([],a._camera.position,f);y=.5*t.length(v),a._camera.position=t.scaleAndAdd([],a._camera.position,_.dir,y);try{a._updateStateFromCamera()}catch(e){return void t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(e,i,r){return"globe"===this.transform.projection.name&&t.warnOnce("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(e,i),i,r)}_raycastElevationBox(e,i){const r=this.transform.elevation;if(!r)return;const n=new t.pointGeometry(e.x,i.y),o=new t.pointGeometry(i.x,e.y),s=r.pointCoordinate(e);if(!s)return;const a=r.pointCoordinate(i);if(!a)return;const l=r.pointCoordinate(n);if(!l)return;const c=r.pointCoordinate(o);if(!c)return;const u=new t.MercatorCoordinate(s[0],s[1]).toLngLat(),h=new t.MercatorCoordinate(a[0],a[1]).toLngLat(),p=new t.MercatorCoordinate(l[0],l[1]).toLngLat(),d=new t.MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(u.lng,Math.min(h.lng,Math.min(p.lng,d.lng))),m=Math.min(u.lat,Math.min(h.lat,Math.min(p.lat,d.lat))),_=Math.max(u.lng,Math.max(h.lng,Math.max(p.lng,d.lng))),g=Math.max(u.lat,Math.max(h.lat,Math.max(p.lat,d.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),v=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new t.LngLat(f,m),maxLngLat:new t.LngLat(_,g),minAltitude:y,maxAltitude:v}}fitScreenCoordinates(e,i,r,n,o){let s,a,l,c;"globe"===this.transform.projection.name&&t.warnOnce("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const u=t.pointGeometry.convert(e),h=t.pointGeometry.convert(i),p=this._raycastElevationBox(u,h);if(p)s=p.minLngLat,a=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(u,h))return this;s=this.transform.pointLocation(u),a=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(t.pointGeometry.convert(e)),this.transform.pointLocation(t.pointGeometry.convert(i)),r,n):this._cameraForBox(s,a,l,c,n),n,o)}_fitInternal(e,i,r){return e?(delete(i=t.extend(e,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(e,i){this.stop();const r=e.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in e&&r.zoom!==+e.zoom&&(n=!0,r.zoom=+e.zoom),void 0!==e.center&&(r.center=t.LngLat.convert(e.center)),"bearing"in e&&r.bearing!==+e.bearing&&(o=!0,r.bearing=+e.bearing),"pitch"in e&&r.pitch!==+e.pitch&&(s=!0,r.pitch=+e.pitch),null==e.padding||r.isPaddingEqual(e.padding)||(r.padding=e.padding),e.preloadOnly?(this._preloadTiles(r),this):(this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),n&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),o&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),s&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||t.warnOnce(Gn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return t.warnOnce(Gn),this;this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(e);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),a&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),c&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),l&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i)),this}easeTo(e,i){this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||!e.essential&&t.exported.prefersReducedMotion)&&(e.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?+e.zoom:n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:r.padding,p=t.pointGeometry.convert(e.offset);let d,f,m;if("globe"===r.projection.name){const i=t.MercatorCoordinate.fromLngLat(r.center),n=p.rotate(-r.angle);i.x+=n.x/r.worldSize,i.y+=n.y/r.worldSize;const o=i.toLngLat(),s=t.LngLat.convert(e.center||o);this._normalizeCenter(s),d=r.centerPoint.add(n),f=new t.pointGeometry(i.x,i.y).mult(r.worldSize),m=new t.pointGeometry(t.mercatorXfromLng(s.lng),t.mercatorYfromLat(s.lat)).mult(r.worldSize).sub(f)}else{d=r.centerPoint.add(p);const i=r.pointLocation(d),n=t.LngLat.convert(e.center||i);this._normalizeCenter(n),f=r.project(i),m=r.project(n).sub(f)}const _=r.zoomScale(l-n);let g,y;e.around&&(g=t.LngLat.convert(e.around),y=r.locationPoint(g));const v=this._zooming||l!==n,x=this._rotating||o!==c,b=this._pitching||u!==s,w=!r.isPaddingEqual(h),T=r=>T=>{if(v&&(r.zoom=t.number(n,l,T)),x&&(r.bearing=t.number(o,c,T)),b&&(r.pitch=t.number(s,u,T)),w&&(r.interpolatePadding(a,h,T),d=r.centerPoint.add(p)),g)r.setLocationAtPoint(g,y);else{const t=r.zoomScale(r.zoom-n),e=l>n?Math.min(2,_):Math.max(.5,_),i=Math.pow(e,1-T),o=r.unproject(f.add(m.mult(T*i)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,d)}return e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(T,e.duration,r);return this._preloadTiles(t),this}const M={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,M),this._ease(T(r),(t=>{r.recenterOnTerrain(),this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:r.padding,p=r.zoomScale(l-n),d=t.pointGeometry.convert(e.offset);let f=r.centerPoint.add(d);const m=r.pointLocation(f),_=t.LngLat.convert(e.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let v=e.curve;const x=Math.max(r.width,r.height),b=x/p,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,n,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(i-n);v=Math.sqrt(o/w*2)}const T=v*v;function M(t){const e=(b*b-x*x+(t?-1:1)*T*T*w*w)/(2*(t?b:x)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function E(t){return(Math.exp(t)-Math.exp(-t))/2}function C(t){return(Math.exp(t)+Math.exp(-t))/2}const S=M(0);let k=function(t){return C(S)/C(S+v*t)},A=function(t){return x*((C(S)*(E(e=S+v*t)/C(e))-E(S))/T)/w;var e},I=(M(1)-S)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,i);const t=b<x?-1:1;I=Math.abs(Math.log(b/x))/v,A=function(){return 0},k=function(e){return Math.exp(t*v*e)}}e.duration="duration"in e?+e.duration:1e3*I/("screenSpeed"in e?+e.screenSpeed/v:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const P=o!==c,L=u!==s,z=!r.isPaddingEqual(h),D=r=>p=>{const m=p*I,v=1/k(m);r.zoom=1===p?l:n+r.scaleZoom(v),P&&(r.bearing=t.number(o,c,p)),L&&(r.pitch=t.number(s,u,p)),z&&(r.interpolatePadding(a,h,p),f=r.centerPoint.add(d));const x=1===p?_:r.unproject(g.add(y.mult(A(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,f),r._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(D,e.duration,r);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=P,this._pitching=L,this._padding=z,this._prepareEase(i,!1),this._ease(D(r),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)<r&&(e-=360),Math.abs(e+360-i)<r&&(e+=360),e}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.maxBounds)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}_emulate(t,e,i){const r=Math.ceil(15*e/1e3),n=[],o=t(i.clone());for(let t=0;t<=r;t++){const e=o(t/r);n.push(e.clone())}return n}}class Zn{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const r=i.reduce(((t,e,r)=>(e.value&&(t+=`${e.key}=${e.value}${r<i.length-1?"&":""}`),t)),"?");e.href=`${t.config.FEEDBACK_URL}/${r}${this._map._hash?this._map._hash.getHashString(!0):""}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style._sourceCaches;for(const i in e){const r=e[i];if(r.used){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Hn{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=o("div","mapboxgl-ctrl");const e=o("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class Wn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Xn(e,i,r){if(e=new t.LngLat(e.lng,e.lat),i){const n=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-r.center.lng)/360),a=r.locationPoint(e).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)<a&&(l||Math.abs(n.lng-r.center.lng)<s)?e=n:r.locationPoint(o).distSqr(i)<a&&(l||Math.abs(o.lng-r.center.lng)<s)&&(e=o)}for(;Math.abs(e.lng-r.center.lng)>180;){const t=r.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}const Qn={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%)"};class Yn extends t.Evented{constructor(e,i){if(super(),(e instanceof t.window.HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),e&&e.element)this._element=e.element,this._offset=t.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,r=27,n=s("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=t.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const r=this._element.classList;for(const t in Qn)r.remove(`mapboxgl-marker-anchor-${t}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,t._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map;if(!t)return!1;const e=t.unproject(this._pos),i=t.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(e)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const i=this._pos;if(!i||i.x<0||i.x>e.transform.width||i.y<0||i.y>e.transform.height)return void this._clearFadeTimer();const r=e.unproject(i);let n;e._usingGlobe()&&t.isLngLatBehindGlobe(e.transform,this._lngLat)?n=0:(n=1-e._queryFogOpacity(r),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(n*=.2)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t||!this._map)return;const e=this._calculateXYTransform()+this._calculateZTransform(),i=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${t.x}px,${t.y}px) ${Qn[this._anchor]}\n ${e}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const e=this._pos,i=this._map;if("map"!==this.getPitchAlignment()||!i||!e)return"";if(!i._usingGlobe()){const t=i.getPitch();return t?`rotateX(${t}deg)`:""}const r=t.radToDeg(t.globeTiltAtLngLat(i.transform,this._lngLat)),n=e.sub(t.globeCenterToScreenPoint(i.transform)),o=r/(Math.abs(n.x)+Math.abs(n.y)),s=n.x*o,a=-n.y*o;return a||s?`rotateX(${a}deg) rotateY(${s}deg)`:""}_calculateZTransform(){const t=this._calculateRotation();return t?`rotateZ(${t}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const e=this._map;if(this._pos&&e&&e._usingGlobe()){const i=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(i);return this._rotation+t.radToDeg(Math.atan2(r.y,r.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(e){t.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Xn(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._usingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=t.pointGeometry.convert(e),this._update(),this}_onMove(e){const i=this._map;if(i){if(!this._isDragging){const t=this._clickTolerance||i._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map;e&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Jn{constructor(t){this.jumpTo(t)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const i=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const Kn={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},to={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function eo(t){t.parentNode&&t.parentNode.removeChild(t)}const io={showCompass:!0,showZoom:!0,visualizePitch:!1};class ro{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new gn({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new yn({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),u()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),f(this.element,e)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,f(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=m(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const no={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},oo={maxWidth:100,unit:"metric"};function so(t,e,i,r,n,o){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i),a=s/i;o._requestDomTask((()=>{t.style.width=e*a+"px",t.innerHTML="nautical-mile"!==n?new Intl.NumberFormat(r,{style:"unit",unitDisplay:"narrow",unit:n}).format(s):`${s}&nbsp;nm`}))}const ao={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},lo=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function co(e=new t.pointGeometry(0,0),i="bottom"){if("number"==typeof e){const r=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(i){case"top":return new t.pointGeometry(0,e);case"top-left":return new t.pointGeometry(r,r);case"top-right":return new t.pointGeometry(-r,r);case"bottom":return new t.pointGeometry(0,-e);case"bottom-left":return new t.pointGeometry(r,-r);case"bottom-right":return new t.pointGeometry(-r,-r);case"left":return new t.pointGeometry(e,0);case"right":return new t.pointGeometry(-e,0)}return new t.pointGeometry(0,0)}return e instanceof t.pointGeometry||Array.isArray(e)?t.pointGeometry.convert(e):t.pointGeometry.convert(e[i]||[0,0])}const uo={version:t.version,supported:i,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends qn{constructor(e){if(null!=(e=t.extend({},to,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(e.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Zr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language="auto"===e.language?t.window.navigator.language:e.language,this._worldview=e.worldview,this._renderTaskQueue=new Wn,this._domRenderTaskQueue=new Wn,this._controls=[],this._markers=[],this._mapId=t.uniqueId(),this._locale=t.extend({},Kn,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Jn(0),this._explicitProjection=null,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&t.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new $n(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Wr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),e.attributionControl&&this.addControl(new Zn({customAttribution:e.customAttribution})),this._logoControl=new Hn,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)),this.fire(new t.Event("resize",e)),i&&this.fire(new t.Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&t.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getLanguage(){return this._language}setLanguage(e){if(this._language="auto"===e?t.window.navigator.language:e,this.style)for(const t in this.style._sourceCaches){const e=this.style._sourceCaches[t]._source;e._setLanguage&&e._setLanguage(this._language)}for(const t of this._controls)t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){if(this._worldview=t,this.style)for(const e in this.style._sourceCaches){const i=this.style._sourceCaches[e]._source;i._setWorldview&&i._setWorldview(t)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._updateProjection(t)}_updateProjection(e){const i=this.getProjection();null===e&&(this._explicitProjection=null);const r=e||this.getProjection();let n;if(r&&"globe"===r.name&&this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(n=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(n=this.transform.setProjection(r),this.transform.mercatorFromTransition=!1),e&&(this._explicitProjection="globe"===e.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),n){if("globe"===i.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles()}this._update(!0)}return this}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.pointGeometry.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new nn(t,this,n.originalEvent,{features:s}))):r=!1},o=()=>{r=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const o=e.filter((t=>this.getLayer(t)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new nn(t,this,n.originalEvent)))},o=e=>{r&&(r=!1,i.call(this,new nn(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),n=r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const r=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[t]:void 0;return n&&(t=>{for(let n=0;n<t.length;n++){const o=t[n];if(o.listener===i&&r(o.layers,e)){for(const t in o.delegates)this.off(t,o.delegates[t]);return t.splice(n,1),this}}})(n),this}queryRenderedFeatures(e,i){return this.style?(void 0!==i||void 0===e||e instanceof t.pointGeometry||Array.isArray(e)||(i=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],i=i||{},this.transform)):[]}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}queryTerrainElevation(e,i){const r=this.transform.elevation;return r?(i=t.extend({},{exaggerated:!0},i),r.getAtPoint(t.MercatorCoordinate.fromLngLat(e),null,i.exaggerated)):null}setStyle(e,i){return!1!==(i=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(e,i))}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t&&(this.style=new ti(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new ti(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.normalizeStyleURL(e),n=this._requestManager.transformRequest(r,t.ResourceType.Style);t.getJSON(n,((e,r)=>{e?this.fire(new t.ErrorEvent(e)):r&&this._updateDiff(r,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap){const{width:l,height:c,data:u}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},u),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new t.ErrorEvent(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`")));else{const{width:l,height:c}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return void this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap?t.exported.getImageData(i):i,{width:o,height:s}=n;void 0!==o&&void 0!==s?o===r.data.width&&s===r.data.height?(r.data.replace(n.data,!(i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new t.ErrorEvent(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`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,r)=>{i(e,r instanceof t.window.HTMLImageElement?t.exported.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,n,o,s=this._container;for(;s&&(!n||!o);){const e=t.window.getComputedStyle(s).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(n=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),s=s.parentElement}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=o("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=o("div","mapboxgl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=o("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,i){const r=t.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(e),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${i}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const e=t.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);r?(t.storeAuthState(r,!0),this.painter=new zr(r,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(e){let i;const r=this.painter.context.extTimerQuery,n=t.exported.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let o=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=this.transform.pitch,r=t.exported.now();this.style.zoomHistory.update(e,r);const n=new t.EvaluationParameters(e,{now:r,fadeDuration:s,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=n.crossFadingFactor();1===a&&a===this._crossFadingFactor||(o=!0,this._crossFadingFactor=a),this.style.update(n)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=t.exported.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:o})),t.window.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(e);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const t of this._markers)t._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),n=!1;this.transform.elevation&&(n=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const o=Math.abs(e-r);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,t,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof Hn&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(t),e.canvasCopies.map(n),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const n=t.length/4;for(let o=0;o<e.length;o++){const s=e[o];let a=0;for(let e=0;e<s.length;e+=4)s[e]===t[e]&&s[e+1]===t[e+1]&&s[e+2]===t[e+2]&&s[e+3]===t[e+3]&&(a+=1);r+=(i[o+2]-i[o+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==t.window&&(t.window.removeEventListener("resize",this._onWindowResize,!1),t.window.removeEventListener("orientationchange",this._onWindowResize,!1),t.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.removeEventListener("online",this._onWindowOnline,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),eo(this._canvasContainer),eo(this._controlContainer),eo(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),t.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new t.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=t.exported.frame((t=>{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(e){const i=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(i,((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},io,e),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),r=e===t.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ro(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=o("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},no,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Hr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>{this._supportsGeolocation="denied"!==t.state,e(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.geolocation,e(this._supportsGeolocation))}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,n=this._map.getBearing(),o=t.extend({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,i=t.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Yn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Yn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return t.warnOnce("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 t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==t.window.DeviceMotionEvent&&"function"==typeof t.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Zn,ScaleControl:class{constructor(e){this.options=t.extend({},oo,e),t.bindAll(["_update","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){!function(t,e,i,r){const n=r&&r.maxWidth||100,o=t._containerHeight/2,s=t._containerWidth/2-n/2,a=t.unproject([s,o]),l=t.unproject([s+n,o]),c=a.distanceTo(l);if(r&&"imperial"===r.unit){const r=3.2808*c;r>5280?so(e,n,r/5280,i,"mile",t):so(e,n,r,i,"foot",t)}else r&&"nautical"===r.unit?so(e,n,c/1852,i,"nautical-mile",t):c>=1e3?so(e,n,c/1e3,i,"kilometer",t):so(e,n,c,i,"meter",t)}(this._map,this._container,this._language,this.options)}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(ao),e),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const i=t.window.document.createDocumentFragment(),r=t.window.document.createElement("body");let n;for(r.innerHTML=e;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=o("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="&#215;",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,r=this._pos;if(!e||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.x<n/2,a=r.x>e.transform.width-n/2;if(r.y+t<o)return s?"top-left":a?"top-right":"top";if(r.y>e.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(e){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(r)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xn(this._lngLat,this._pos,i.transform)),!this._trackPointer||e){const t=this._pos=this._trackPointer&&e?e:i.project(this._lngLat),r=co(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=co(this.options.offset,n),s=t.add(o).round();i._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${Qn[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._usingGlobe()){const e=t.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(lo);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:Yn,Style:ti,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.pointGeometry,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:Br,Evented:t.Evented,config:t.config,prewarm:function(){Vt().acquire(Bt)},clearPrewarmedResources:function(){const t=Nt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Bt),Nt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return jt.workerCount},set workerCount(t){jt.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return uo}));return i}));!function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};e[s][0].call(u.exports,(function(t){return n(e[s][1][t]||t)}),u,u.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){"use strict";var r=t("@mapbox/mapbox-gl-sync-move"),n=t("events").EventEmitter;function o(t,e,i,o){if(this.options=o||{},this._mapA=t,this._mapB=e,this._horizontal="horizontal"===this.options.orientation,this._onDown=this._onDown.bind(this),this._onMove=this._onMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._ev=new n,this._swiper=document.createElement("div"),this._swiper.className=this._horizontal?"compare-swiper-horizontal":"compare-swiper-vertical",this._controlContainer=document.createElement("div"),this._controlContainer.className=this._horizontal?"mapboxgl-compare mapboxgl-compare-horizontal":"mapboxgl-compare",this._controlContainer.className=this._controlContainer.className,this._controlContainer.appendChild(this._swiper),"string"==typeof i&&document.body.querySelectorAll){var s=document.body.querySelectorAll(i)[0];if(!s)throw new Error("Cannot find element with specified container selector.");s.appendChild(this._controlContainer)}else{if(!(i instanceof Element&&i.appendChild))throw new Error("Invalid container specified. Must be CSS selector or HTML element.");i.appendChild(this._controlContainer)}this._bounds=e.getContainer().getBoundingClientRect();var a=(this._horizontal?this._bounds.height:this._bounds.width)/2;this._setPosition(a),this._clearSync=r(t,e),this._onResize=function(){this._bounds=e.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)}.bind(this),e.on("resize",this._onResize),this.options&&this.options.mousemove&&(t.getContainer().addEventListener("mousemove",this._onMove),e.getContainer().addEventListener("mousemove",this._onMove)),this._swiper.addEventListener("mousedown",this._onDown),this._swiper.addEventListener("touchstart",this._onDown)}o.prototype={_setPointerEvents:function(t){this._controlContainer.style.pointerEvents=t,this._swiper.style.pointerEvents=t},_onDown:function(t){t.touches?(document.addEventListener("touchmove",this._onMove),document.addEventListener("touchend",this._onTouchEnd)):(document.addEventListener("mousemove",this._onMove),document.addEventListener("mouseup",this._onMouseUp))},_setPosition:function(t){t=Math.min(t,this._horizontal?this._bounds.height:this._bounds.width);var e=this._horizontal?"translate(0, "+t+"px)":"translate("+t+"px, 0)";this._controlContainer.style.transform=e,this._controlContainer.style.WebkitTransform=e;var i=this._horizontal?"rect(0, 999em, "+t+"px, 0)":"rect(0, "+t+"px, "+this._bounds.height+"px, 0)",r=this._horizontal?"rect("+t+"px, 999em, "+this._bounds.height+"px,0)":"rect(0, 999em, "+this._bounds.height+"px,"+t+"px)";this._mapA.getContainer().style.clip=i,this._mapB.getContainer().style.clip=r,this.currentPosition=t},_onMove:function(t){this.options&&this.options.mousemove&&this._setPointerEvents(t.touches?"auto":"none"),this._horizontal?this._setPosition(this._getY(t)):this._setPosition(this._getX(t))},_onMouseUp:function(){document.removeEventListener("mousemove",this._onMove),document.removeEventListener("mouseup",this._onMouseUp),this.fire("slideend",{currentPosition:this.currentPosition})},_onTouchEnd:function(){document.removeEventListener("touchmove",this._onMove),document.removeEventListener("touchend",this._onTouchEnd)},_getX:function(t){var e=(t=t.touches?t.touches[0]:t).clientX-this._bounds.left;return e<0&&(e=0),e>this._bounds.width&&(e=this._bounds.width),e},_getY:function(t){var e=(t=t.touches?t.touches[0]:t).clientY-this._bounds.top;return e<0&&(e=0),e>this._bounds.height&&(e=this._bounds.height),e},setSlider:function(t){this._setPosition(t)},on:function(t,e){return this._ev.on(t,e),this},fire:function(t,e){return this._ev.emit(t,e),this},off:function(t,e){return this._ev.removeListener(t,e),this},remove:function(){this._clearSync(),this._mapB.off("resize",this._onResize);var t=this._mapA.getContainer();t&&(t.style.clip=null,t.removeEventListener("mousemove",this._onMove));var e=this._mapB.getContainer();e&&(e.style.clip=null,e.removeEventListener("mousemove",this._onMove)),this._swiper.removeEventListener("mousedown",this._onDown),this._swiper.removeEventListener("touchstart",this._onDown),this._controlContainer.remove()}},window.mapboxgl?mapboxgl.Compare=o:void 0!==e&&(e.exports=o)},{"@mapbox/mapbox-gl-sync-move":2,events:3}],2:[function(t,e,i){e.exports=function(){var t,e=arguments.length;if(1===e)t=arguments[0];else{t=[];for(var i=0;i<e;i++)t.push(arguments[i])}var r=[];function n(){t.forEach((function(t,e){t.on("move",r[e])}))}function o(){t.forEach((function(t,e){t.off("move",r[e])}))}return t.forEach((function(e,i){r[i]=function(t,e){o(),function(t,e){var i=t.getCenter(),r=t.getZoom(),n=t.getBearing(),o=t.getPitch();e.forEach((function(t){t.jumpTo({center:i,zoom:r,bearing:n,pitch:o})}))}(t,e),n()}.bind(null,e,t.filter((function(t,e){return e!==i})))})),n(),function(){o(),r=[]}}},{}],3:[function(t,e,i){var r=Object.create||function(t){function e(){}return e.prototype=t,new e},n=Object.keys||function(t){var e=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.push(i);return i},o=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((e.exports=s).EventEmitter=s).prototype._events=void 0,s.prototype._maxListeners=void 0;var a,l=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(t){a=!1}function u(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function h(t,e,i,n){var o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),s=t._events),a=s[e]):(s=t._events=r(null),t._eventsCount=0),a){if("function"==typeof a?a=s[e]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),!a.warned&&(o=u(t))&&0<o&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[e]=i,++t._eventsCount;return t}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=o.call(p,r);return n.listener=i,r.wrapFn=n}function f(t,e,i){var r=t._events;if(!r)return[];var n=r[e];return n?"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):_(n,n.length):[]}function m(t){var e=this._events;if(e){var i=e[t];if("function"==typeof i)return 1;if(i)return i.length}return 0}function _(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');l=t}}):s.defaultMaxListeners=l,s.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(t,e,i,r){var n,o,s,a,l,c,u="error"===t;if(c=this._events)u=u&&null==c.error;else if(!u)return!1;if(u){if(1<arguments.length&&(n=e),n instanceof Error)throw n;var h=new Error('Unhandled "error" event. ('+n+")");throw h.context=n,h}if(!(o=c[t]))return!1;var p="function"==typeof o;switch(s=arguments.length){case 1:!function(t,e,i){if(e)t.call(i);else for(var r=t.length,n=_(t,r),o=0;o<r;++o)n[o].call(i)}(o,p,this);break;case 2:!function(t,e,i,r){if(e)t.call(i,r);else for(var n=t.length,o=_(t,n),s=0;s<n;++s)o[s].call(i,r)}(o,p,this,e);break;case 3:!function(t,e,i,r,n){if(e)t.call(i,r,n);else for(var o=t.length,s=_(t,o),a=0;a<o;++a)s[a].call(i,r,n)}(o,p,this,e,i);break;case 4:!function(t,e,i,r,n,o){if(e)t.call(i,r,n,o);else for(var s=t.length,a=_(t,s),l=0;l<s;++l)a[l].call(i,r,n,o)}(o,p,this,e,i,r);break;default:for(a=new Array(s-1),l=1;l<s;l++)a[l-1]=arguments[l];!function(t,e,i,r){if(e)t.apply(i,r);else for(var n=t.length,o=_(t,n),s=0;s<n;++s)o[s].apply(i,r)}(o,p,this,a)}return!0},s.prototype.on=s.prototype.addListener=function(t,e){return h(this,t,e,!1)},s.prototype.prependListener=function(t,e){return h(this,t,e,!0)},s.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,d(this,t,e)),this},s.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,d(this,t,e)),this},s.prototype.removeListener=function(t,e){var i,n,o,s,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(i=n[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=r(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(o=-1,s=i.length-1;0<=s;s--)if(i[s]===e||i[s].listener===e){a=i[s].listener,o=s;break}if(o<0)return this;0===o?i.shift():function(t,e){for(var i=e,r=i+1,n=t.length;r<n;i+=1,r+=1)t[i]=t[r];t.pop()}(i,o),1===i.length&&(n[t]=i[0]),n.removeListener&&this.emit("removeListener",t,a||e)}return this},s.prototype.removeAllListeners=function(t){var e,i,o;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):i[t]&&(0==--this._eventsCount?this._events=r(null):delete i[t]),this;if(0===arguments.length){var s,a=n(i);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(e)for(o=e.length-1;0<=o;o--)this.removeListener(t,e[o]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}]},{},[1]);!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxDirections=t()}}((function(){return function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};e[s][0].call(u.exports,(function(t){return n(e[s][1][t]||t)}),u,u.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){"use strict";var r={};function n(t){return Math.floor(Math.abs(t)+.5)*(t>=0?1:-1)}function o(t,e,i){var r=(t=n(t*i))-(e=n(e*i));r<<=1;t-e<0&&(r=~r);for(var o="";r>=32;){o+=String.fromCharCode(63+(32|31&r));r>>=5}return o+=String.fromCharCode(r+63)}r.decode=function(t,e){for(var i,r=0,n=0,o=0,s=[],a=0,l=0,c=null,u=Math.pow(10,Number.isInteger(e)?e:5);r<t.length;){c=null;a=0;l=0;do{l|=(31&(c=t.charCodeAt(r++)-63))<<a;a+=5}while(c>=32);i=1&l?~(l>>1):l>>1;a=l=0;do{l|=(31&(c=t.charCodeAt(r++)-63))<<a;a+=5}while(c>=32);n+=i;o+=1&l?~(l>>1):l>>1;s.push([n/u,o/u])}return s};r.encode=function(t,e){if(!t.length)return"";for(var i=Math.pow(10,Number.isInteger(e)?e:5),r=o(t[0][0],0,i)+o(t[0][1],0,i),n=1;n<t.length;n++){var s=t[n],a=t[n-1];r+=o(s[0],a[0],i);r+=o(s[1],a[1],i)}return r};function s(t){for(var e=[],i=0;i<t.length;i++){var r=t[i].slice();e.push([r[1],r[0]])}return e}r.fromGeoJSON=function(t,e){t&&"Feature"===t.type&&(t=t.geometry);if(!t||"LineString"!==t.type)throw new Error("Input must be a GeoJSON LineString");return r.encode(s(t.coordinates),e)};r.toGeoJSON=function(t,e){return{type:"LineString",coordinates:s(r.decode(t,e))}};"object"==typeof e&&e.exports&&(e.exports=r)},{}],2:[function(t,e,i){"use strict";var r=t("is-obj"),n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function s(t,e,i){var o=e[i];if(null!=o){if(n.call(t,i)&&(void 0===t[i]||null===t[i]))throw new TypeError("Cannot convert undefined or null to object ("+i+")");n.call(t,i)&&r(o)?t[i]=a(Object(t[i]),e[i]):t[i]=o}}function a(t,e){if(t===e)return t;e=Object(e);for(var i in e)n.call(e,i)&&s(t,e,i);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(e),a=0;a<r.length;a++)o.call(e,r[a])&&s(t,e,r[a]);return t}e.exports=function(t){t=function(t){if(null==t)throw new TypeError("Sources cannot be null or undefined");return Object(t)}(t);for(var e=1;e<arguments.length;e++)a(t,arguments[e]);return t}},{"is-obj":5}],3:[function(t,e,i){function r(){this._events=this._events||{};this._maxListeners=this._maxListeners||void 0}e.exports=r;r.EventEmitter=r;r.prototype._events=void 0;r.prototype._maxListeners=void 0;r.defaultMaxListeners=10;r.prototype.setMaxListeners=function(t){if(!(e=t,"number"==typeof e)||t<0||isNaN(t))throw TypeError("n must be a positive number");var e;this._maxListeners=t;return this};r.prototype.emit=function(t){var e,i,r,a,l,c;this._events||(this._events={});if("error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");u.context=e;throw u}if(s(i=this._events[t]))return!1;if(n(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1);i.apply(this,a)}else if(o(i)){a=Array.prototype.slice.call(arguments,1);r=(c=i.slice()).length;for(l=0;l<r;l++)c[l].apply(this,a)}return!0};r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");this._events||(this._events={});this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e);this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e;if(o(this._events[t])&&!this._events[t].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[t].length>i){this._events[t].warned=!0;console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length);"function"==typeof console.trace&&console.trace()}return this};r.prototype.on=r.prototype.addListener;r.prototype.once=function(t,e){if(!n(e))throw TypeError("listener must be a function");var i=!1;function r(){this.removeListener(t,r);if(!i){i=!0;e.apply(this,arguments)}}r.listener=e;this.on(t,r);return this};r.prototype.removeListener=function(t,e){var i,r,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;s=(i=this._events[t]).length;r=-1;if(i===e||n(i.listener)&&i.listener===e){delete this._events[t];this._events.removeListener&&this.emit("removeListener",t,e)}else if(o(i)){for(a=s;a-- >0;)if(i[a]===e||i[a].listener&&i[a].listener===e){r=a;break}if(r<0)return this;if(1===i.length){i.length=0;delete this._events[t]}else i.splice(r,1);this._events.removeListener&&this.emit("removeListener",t,e)}return this};r.prototype.removeAllListeners=function(t){var e,i;if(!this._events)return this;if(!this._events.removeListener){0===arguments.length?this._events={}:this._events[t]&&delete this._events[t];return this}if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);this.removeAllListeners("removeListener");this._events={};return this}if(n(i=this._events[t]))this.removeListener(t,i);else if(i)for(;i.length;)this.removeListener(t,i[i.length-1]);delete this._events[t];return this};r.prototype.listeners=function(t){return this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]};r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0};r.listenerCount=function(t,e){return t.listenerCount(e)};function n(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}},{}],4:[function(t,e,i){!function(){var t={};void 0!==i?e.exports=t:this.fuzzy=t;t.simpleFilter=function(e,i){return i.filter((function(i){return t.test(e,i)}))};t.test=function(e,i){return null!==t.match(e,i)};t.match=function(t,e,i){i=i||{};var r,n=0,o=[],s=e.length,a=0,l=0,c=i.pre||"",u=i.post||"",h=i.caseSensitive&&e||e.toLowerCase();t=i.caseSensitive&&t||t.toLowerCase();for(var p=0;p<s;p++){r=e[p];if(h[p]===t[n]){r=c+r+u;n+=1;l+=1+l}else l=0;a+=l;o[o.length]=r}if(n===t.length){a=h===t?1/0:a;return{rendered:o.join(""),score:a}}return null};t.filter=function(e,i,r){if(!i||0===i.length)return[];if("string"!=typeof e)return i;r=r||{};return i.reduce((function(i,n,o,s){var a=n;r.extract&&(a=r.extract(n));var l=t.match(e,a,r);null!=l&&(i[i.length]={string:l.rendered,score:l.score,index:o,original:n});return i}),[]).sort((function(t,e){var i=e.score-t.score;return i||t.index-e.index}))}}()},{}],5:[function(t,e,i){"use strict";e.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}},{}],6:[function(t,e,i){e.exports=/<%=([\s\S]+?)%>/g},{}],7:[function(t,e,i){(function(t){var i=NaN,r="[object Symbol]",n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt,c="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,h=c||u||Function("return this")(),p=Object.prototype.toString,d=Math.max,f=Math.min,m=function(){return h.Date.now()};function _(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&p.call(t)==r}(t))return i;if(_(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=_(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(n,"");var c=s.test(t);return c||a.test(t)?l(t.slice(2),c?2:8):o.test(t)?i:+t}e.exports=function(t,e,i){var r,n,o,s,a,l,c=0,u=!1,h=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");e=g(e)||0;if(_(i)){u=!!i.leading;o=(h="maxWait"in i)?d(g(i.maxWait)||0,e):o;p="trailing"in i?!!i.trailing:p}function y(e){var i=r,o=n;r=n=void 0;c=e;return s=t.apply(o,i)}function v(t){var i=t-l;return void 0===l||i>=e||i<0||h&&t-c>=o}function x(){var t=m();if(v(t))return b(t);a=setTimeout(x,function(t){var i=e-(t-l);return h?f(i,o-(t-c)):i}(t))}function b(t){a=void 0;if(p&&r)return y(t);r=n=void 0;return s}function w(){var t=m(),i=v(t);r=arguments;n=this;l=t;if(i){if(void 0===a)return function(t){c=t;a=setTimeout(x,e);return u?y(t):s}(l);if(h){a=setTimeout(x,e);return y(l)}}void 0===a&&(a=setTimeout(x,e));return s}w.cancel=function(){void 0!==a&&clearTimeout(a);c=0;r=l=n=a=void 0};w.flush=function(){return void 0===a?s:b(m())};return w}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(t,e,i){(function(t){var r="__lodash_hash_undefined__",n=1,o=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",p="[object Error]",d="[object Function]",f="[object GeneratorFunction]",m="[object Map]",_="[object Number]",g="[object Null]",y="[object Object]",v="[object Promise]",x="[object Proxy]",b="[object RegExp]",w="[object Set]",T="[object String]",M="[object Symbol]",E="[object Undefined]",C="[object WeakMap]",S="[object ArrayBuffer]",k="[object DataView]",A=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0;P[a]=P[l]=P[S]=P[u]=P[k]=P[h]=P[p]=P[d]=P[m]=P[_]=P[y]=P[b]=P[w]=P[T]=P[C]=!1;var L="object"==typeof t&&t&&t.Object===Object&&t,z="object"==typeof self&&self&&self.Object===Object&&self,D=L||z||Function("return this")(),R="object"==typeof i&&i&&!i.nodeType&&i,O=R&&"object"==typeof e&&e&&!e.nodeType&&e,F=O&&O.exports===R,B=F&&L.process,j=function(){try{return B&&B.binding&&B.binding("util")}catch(t){}}(),N=j&&j.isTypedArray;function V(t,e){for(var i=-1,r=null==t?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}function U(t){var e=-1,i=Array(t.size);t.forEach((function(t,r){i[++e]=[r,t]}));return i}function $(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=t}));return i}var G,q,Z,H=Array.prototype,W=Function.prototype,X=Object.prototype,Q=D["__core-js_shared__"],Y=W.toString,J=X.hasOwnProperty,K=(G=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",tt=X.toString,et=RegExp("^"+Y.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),it=F?D.Buffer:void 0,rt=D.Symbol,nt=D.Uint8Array,ot=X.propertyIsEnumerable,st=H.splice,at=rt?rt.toStringTag:void 0,lt=Object.getOwnPropertySymbols,ct=it?it.isBuffer:void 0,ut=(q=Object.keys,Z=Object,function(t){return q(Z(t))}),ht=jt(D,"DataView"),pt=jt(D,"Map"),dt=jt(D,"Promise"),ft=jt(D,"Set"),mt=jt(D,"WeakMap"),_t=jt(Object,"create"),gt=$t(ht),yt=$t(pt),vt=$t(dt),xt=$t(ft),bt=$t(mt),wt=rt?rt.prototype:void 0,Tt=wt?wt.valueOf:void 0;function Mt(t){var e=-1,i=null==t?0:t.length;this.clear();for(;++e<i;){var r=t[e];this.set(r[0],r[1])}}Mt.prototype.clear=function(){this.__data__=_t?_t(null):{};this.size=0};Mt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];this.size-=e?1:0;return e};Mt.prototype.get=function(t){var e=this.__data__;if(_t){var i=e[t];return i===r?void 0:i}return J.call(e,t)?e[t]:void 0};Mt.prototype.has=function(t){var e=this.__data__;return _t?void 0!==e[t]:J.call(e,t)};Mt.prototype.set=function(t,e){var i=this.__data__;this.size+=this.has(t)?0:1;i[t]=_t&&void 0===e?r:e;return this};function Et(t){var e=-1,i=null==t?0:t.length;this.clear();for(;++e<i;){var r=t[e];this.set(r[0],r[1])}}Et.prototype.clear=function(){this.__data__=[];this.size=0};Et.prototype.delete=function(t){var e=this.__data__,i=It(e,t);if(i<0)return!1;i==e.length-1?e.pop():st.call(e,i,1);--this.size;return!0};Et.prototype.get=function(t){var e=this.__data__,i=It(e,t);return i<0?void 0:e[i][1]};Et.prototype.has=function(t){return It(this.__data__,t)>-1};Et.prototype.set=function(t,e){var i=this.__data__,r=It(i,t);if(r<0){++this.size;i.push([t,e])}else i[r][1]=e;return this};function Ct(t){var e=-1,i=null==t?0:t.length;this.clear();for(;++e<i;){var r=t[e];this.set(r[0],r[1])}}Ct.prototype.clear=function(){this.size=0;this.__data__={hash:new Mt,map:new(pt||Et),string:new Mt}};Ct.prototype.delete=function(t){var e=Bt(this,t).delete(t);this.size-=e?1:0;return e};Ct.prototype.get=function(t){return Bt(this,t).get(t)};Ct.prototype.has=function(t){return Bt(this,t).has(t)};Ct.prototype.set=function(t,e){var i=Bt(this,t),r=i.size;i.set(t,e);this.size+=i.size==r?0:1;return this};function St(t){var e=-1,i=null==t?0:t.length;this.__data__=new Ct;for(;++e<i;)this.add(t[e])}St.prototype.add=St.prototype.push=function(t){this.__data__.set(t,r);return this};St.prototype.has=function(t){return this.__data__.has(t)};function kt(t){var e=this.__data__=new Et(t);this.size=e.size}kt.prototype.clear=function(){this.__data__=new Et;this.size=0};kt.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);this.size=e.size;return i};kt.prototype.get=function(t){return this.__data__.get(t)};kt.prototype.has=function(t){return this.__data__.has(t)};kt.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Et){var r=i.__data__;if(!pt||r.length<199){r.push([t,e]);this.size=++i.size;return this}i=this.__data__=new Ct(r)}i.set(t,e);this.size=i.size;return this};function At(t,e){var i=Zt(t),r=!i&&qt(t),n=!i&&!r&&Ht(t),o=!i&&!r&&!n&&Jt(t),s=i||r||n||o,a=s?function(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}(t.length,String):[],l=a.length;for(var c in t)!e&&!J.call(t,c)||s&&("length"==c||n&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ut(c,l))||a.push(c);return a}function It(t,e){for(var i=t.length;i--;)if(Gt(t[i][0],e))return i;return-1}function Pt(t){return null==t?void 0===t?E:g:at&&at in Object(t)?function(t){var e=J.call(t,at),i=t[at];try{t[at]=void 0;var r=!0}catch(t){}var n=tt.call(t);r&&(e?t[at]=i:delete t[at]);return n}(t):function(t){return tt.call(t)}(t)}function Lt(t){return Yt(t)&&Pt(t)==a}function zt(t,e,i,r,s){return t===e||(null==t||null==e||!Yt(t)&&!Yt(e)?t!=t&&e!=e:function(t,e,i,r,s,c){var d=Zt(t),f=Zt(e),g=d?l:Vt(t),v=f?l:Vt(e),x=(g=g==a?y:g)==y,E=(v=v==a?y:v)==y,C=g==v;if(C&&Ht(t)){if(!Ht(e))return!1;d=!0;x=!1}if(C&&!x){c||(c=new kt);return d||Jt(t)?Ot(t,e,i,r,s,c):function(t,e,i,r,s,a,l){switch(i){case k:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer;e=e.buffer;case S:return!(t.byteLength!=e.byteLength||!a(new nt(t),new nt(e)));case u:case h:case _:return Gt(+t,+e);case p:return t.name==e.name&&t.message==e.message;case b:case T:return t==e+"";case m:var c=U;case w:var d=r&n;c||(c=$);if(t.size!=e.size&&!d)return!1;var f=l.get(t);if(f)return f==e;r|=o;l.set(t,e);var g=Ot(c(t),c(e),r,s,a,l);l.delete(t);return g;case M:if(Tt)return Tt.call(t)==Tt.call(e)}return!1}(t,e,g,i,r,s,c)}if(!(i&n)){var A=x&&J.call(t,"__wrapped__"),I=E&&J.call(e,"__wrapped__");if(A||I){var P=A?t.value():t,L=I?e.value():e;c||(c=new kt);return s(P,L,i,r,c)}}if(!C)return!1;c||(c=new kt);return function(t,e,i,r,o,s){var a=i&n,l=Ft(t),c=l.length,u=Ft(e),h=u.length;if(c!=h&&!a)return!1;var p=c;for(;p--;){var d=l[p];if(!(a?d in e:J.call(e,d)))return!1}var f=s.get(t);if(f&&s.get(e))return f==e;var m=!0;s.set(t,e);s.set(e,t);var _=a;for(;++p<c;){var g=t[d=l[p]],y=e[d];if(r)var v=a?r(y,g,d,e,t,s):r(g,y,d,t,e,s);if(!(void 0===v?g===y||o(g,y,i,r,s):v)){m=!1;break}_||(_="constructor"==d)}if(m&&!_){var x=t.constructor,b=e.constructor;x==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(m=!1)}s.delete(t);s.delete(e);return m}(t,e,i,r,s,c)}(t,e,i,r,zt,s))}function Dt(t){return!(!Qt(t)||function(t){return!!K&&K in t}(t))&&(Wt(t)?et:A).test($t(t))}function Rt(t){if(!(e=t,i=e&&e.constructor,r="function"==typeof i&&i.prototype||X,e===r))return ut(t);var e,i,r,n=[];for(var o in Object(t))J.call(t,o)&&"constructor"!=o&&n.push(o);return n}function Ot(t,e,i,r,s,a){var l=i&n,c=t.length,u=e.length;if(c!=u&&!(l&&u>c))return!1;var h=a.get(t);if(h&&a.get(e))return h==e;var p=-1,d=!0,f=i&o?new St:void 0;a.set(t,e);a.set(e,t);for(;++p<c;){var m=t[p],_=e[p];if(r)var g=l?r(_,m,p,e,t,a):r(m,_,p,t,e,a);if(void 0!==g){if(g)continue;d=!1;break}if(f){if(!V(e,(function(t,e){if(!(n=f,o=e,n.has(o))&&(m===t||s(m,t,i,r,a)))return f.push(e);var n,o}))){d=!1;break}}else if(m!==_&&!s(m,_,i,r,a)){d=!1;break}}a.delete(t);a.delete(e);return d}function Ft(t){return function(t,e,i){var r=e(t);return Zt(t)?r:function(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}(r,i(t))}(t,Kt,Nt)}function Bt(t,e){var i,r,n=t.__data__;return("string"==(r=typeof(i=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==i:null===i)?n["string"==typeof e?"string":"hash"]:n.map}function jt(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return Dt(i)?i:void 0}var Nt=lt?function(t){if(null==t)return[];t=Object(t);return function(t,e){for(var i=-1,r=null==t?0:t.length,n=0,o=[];++i<r;){var s=t[i];e(s,i,t)&&(o[n++]=s)}return o}(lt(t),(function(e){return ot.call(t,e)}))}:function(){return[]},Vt=Pt;(ht&&Vt(new ht(new ArrayBuffer(1)))!=k||pt&&Vt(new pt)!=m||dt&&Vt(dt.resolve())!=v||ft&&Vt(new ft)!=w||mt&&Vt(new mt)!=C)&&(Vt=function(t){var e=Pt(t),i=e==y?t.constructor:void 0,r=i?$t(i):"";if(r)switch(r){case gt:return k;case yt:return m;case vt:return v;case xt:return w;case bt:return C}return e});function Ut(t,e){return!!(e=null==e?s:e)&&("number"==typeof t||I.test(t))&&t>-1&&t%1==0&&t<e}function $t(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Gt(t,e){return t===e||t!=t&&e!=e}var qt=Lt(function(){return arguments}())?Lt:function(t){return Yt(t)&&J.call(t,"callee")&&!ot.call(t,"callee")},Zt=Array.isArray;var Ht=ct||function(){return!1};function Wt(t){if(!Qt(t))return!1;var e=Pt(t);return e==d||e==f||e==c||e==x}function Xt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=s}function Qt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Yt(t){return null!=t&&"object"==typeof t}var Jt=N?function(t){return function(e){return t(e)}}(N):function(t){return Yt(t)&&Xt(t.length)&&!!P[Pt(t)]};function Kt(t){return null!=(e=t)&&Xt(e.length)&&!Wt(e)?At(t):Rt(t);var e}e.exports=function(t,e){return zt(t,e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,e,i){(function(r){var n=t("lodash._reinterpolate"),o=t("lodash.templatesettings"),s=1/0,a=9007199254740991,l="[object Arguments]",c="[object AsyncFunction]",u="[object DOMException]",h="[object Error]",p="[object Function]",d="[object GeneratorFunction]",f="[object Null]",m="[object Object]",_="[object Proxy]",g="[object Symbol]",y="[object Undefined]",v=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,b=/(__e\(.*?\)|\b__t\)) \+\n'';/g,w=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,T=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,E=/($^)/,C=/['\n\r\u2028\u2029\\]/g,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0;S[l]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object Boolean]"]=S["[object DataView]"]=S["[object Date]"]=S[h]=S[p]=S["[object Map]"]=S["[object Number]"]=S[m]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object WeakMap]"]=!1;var k={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},A="object"==typeof r&&r&&r.Object===Object&&r,I="object"==typeof self&&self&&self.Object===Object&&self,P=A||I||Function("return this")(),L="object"==typeof i&&i&&!i.nodeType&&i,z=L&&"object"==typeof e&&e&&!e.nodeType&&e,D=z&&z.exports===L,R=D&&A.process,O=function(){try{var t=z&&z.require&&z.require("util").types;return t||R&&R.binding&&R.binding("util")}catch(t){}}(),F=O&&O.isTypedArray;function B(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function j(t,e){for(var i=-1,r=null==t?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}function N(t){return"\\"+k[t]}function V(t,e){return function(i){return t(e(i))}}var U,$=Function.prototype,G=Object.prototype,q=P["__core-js_shared__"],Z=$.toString,H=G.hasOwnProperty,W=(U=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+U:"",X=G.toString,Q=Z.call(Object),Y=RegExp("^"+Z.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),J=D?P.Buffer:void 0,K=P.Symbol,tt=V(Object.getPrototypeOf,Object),et=G.propertyIsEnumerable,it=K?K.toStringTag:void 0,rt=function(){try{var t=function(t){if(!Rt(t)||function(t){return!!W&&W in t}(t))return!1;var e=zt(t)?Y:T;return e.test(function(t){if(null!=t){try{return Z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(e=function(t,e){return null==t?void 0:t[e]}(Object,"defineProperty"))?e:void 0;t({},"",{});return t}catch(t){}var e}(),nt=J?J.isBuffer:void 0,ot=V(Object.keys,Object),st=Math.max,at=Date.now,lt=K?K.prototype:void 0,ct=lt?lt.toString:void 0;function ut(t,e){var i=At(t),r=!i&&kt(t),n=!i&&!r&&Pt(t),o=!i&&!r&&!n&&Ft(t),s=i||r||n||o,a=s?function(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}(t.length,String):[],l=a.length;for(var c in t)!e&&!H.call(t,c)||s&&("length"==c||n&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||xt(c,l))||a.push(c);return a}function ht(t,e,i){var r=t[e];H.call(t,e)&&St(r,i)&&(void 0!==i||e in t)||pt(t,e,i)}function pt(t,e,i){"__proto__"==e&&rt?rt(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function dt(t){return null==t?void 0===t?y:f:it&&it in Object(t)?function(t){var e=H.call(t,it),i=t[it];try{t[it]=void 0;var r=!0}catch(t){}var n=X.call(t);r&&(e?t[it]=i:delete t[it]);return n}(t):function(t){return X.call(t)}(t)}function ft(t){return Ot(t)&&dt(t)==l}function mt(t){if(!Rt(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=wt(t),i=[];for(var r in t)("constructor"!=r||!e&&H.call(t,r))&&i.push(r);return i}function _t(t,e){return Ct(function(t,e,i){e=st(void 0===e?t.length-1:e,0);return function(){for(var r=arguments,n=-1,o=st(r.length-e,0),s=Array(o);++n<o;)s[n]=r[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=r[n];a[e]=i(s);return B(t,this,a)}}(t,e,Ut),t+"")}var gt=rt?function(t,e){return rt(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:Ut;function yt(t){if("string"==typeof t)return t;if(At(t))return j(t,yt)+"";if(function(t){return"symbol"==typeof t||Ot(t)&&dt(t)==g}(t))return ct?ct.call(t):"";var e=t+"";return"0"==e&&1/t==-s?"-0":e}function vt(t,e,i,r){return void 0===t||St(t,G[i])&&!H.call(r,i)?e:t}function xt(t,e){var i=typeof t;return!!(e=null==e?a:e)&&("number"==i||"symbol"!=i&&M.test(t))&&t>-1&&t%1==0&&t<e}function bt(t,e,i){if(!Rt(i))return!1;var r=typeof e;return!!("number"==r?It(i)&&xt(e,i.length):"string"==r&&e in i)&&St(i[e],t)}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||G)}var Tt,Mt,Et,Ct=(Tt=gt,Mt=0,Et=0,function(){var t=at(),e=16-(t-Et);Et=t;if(e>0){if(++Mt>=800)return arguments[0]}else Mt=0;return Tt.apply(void 0,arguments)});function St(t,e){return t===e||t!=t&&e!=e}var kt=ft(function(){return arguments}())?ft:function(t){return Ot(t)&&H.call(t,"callee")&&!et.call(t,"callee")},At=Array.isArray;function It(t){return null!=t&&Dt(t.length)&&!zt(t)}var Pt=nt||function(){return!1};function Lt(t){if(!Ot(t))return!1;var e=dt(t);return e==h||e==u||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!Ot(t)||dt(t)!=m)return!1;var e=tt(t);if(null===e)return!0;var i=H.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Z.call(i)==Q}(t)}function zt(t){if(!Rt(t))return!1;var e=dt(t);return e==p||e==d||e==c||e==_}function Dt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Rt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ot(t){return null!=t&&"object"==typeof t}var Ft=F?function(t){return function(e){return t(e)}}(F):function(t){return Ot(t)&&Dt(t.length)&&!!S[dt(t)]};var Bt,jt=(Bt=function(t,e,i,r){!function(t,e,i,r){var n=!i;i||(i={});for(var o=-1,s=e.length;++o<s;){var a=e[o],l=r?r(i[a],t[a],a,i,t):void 0;void 0===l&&(l=t[a]);n?pt(i,a,l):ht(i,a,l)}}(e,function(t){return It(t)?ut(t,!0):mt(t)}(e),t,r)},_t((function(t,e){var i=-1,r=e.length,n=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;n=Bt.length>3&&"function"==typeof n?(r--,n):void 0;if(o&&bt(e[0],e[1],o)){n=r<3?void 0:n;r=1}t=Object(t);for(;++i<r;){var s=e[i];s&&Bt(t,s,i,n)}return t})));function Nt(t){return It(t)?ut(t):function(t){if(!wt(t))return ot(t);var e=[];for(var i in Object(t))H.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var Vt=_t((function(t,e){try{return B(t,void 0,e)}catch(t){return Lt(t)?t:new Error(t)}}));function Ut(t){return t}e.exports=function(t,e,i){var r,s=o.imports._.templateSettings||o;i&&bt(t,e,i)&&(e=void 0);t=null==(r=t)?"":yt(r);e=jt({},e,s,vt);var a,l,c,u=jt({},e.imports,s.imports,vt),h=Nt(u),p=(a=u,j(h,(function(t){return a[t]}))),d=0,f=e.interpolate||E,m="__p += '",_=RegExp((e.escape||E).source+"|"+f.source+"|"+(f===n?w:E).source+"|"+(e.evaluate||E).source+"|$","g"),g=H.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/[\r\n]/g," ")+"\n":"";t.replace(_,(function(e,i,r,n,o,s){r||(r=n);m+=t.slice(d,s).replace(C,N);if(i){l=!0;m+="' +\n__e("+i+") +\n'"}if(o){c=!0;m+="';\n"+o+";\n__p += '"}r&&(m+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'");d=s+e.length;return e}));m+="';\n";var y=H.call(e,"variable")&&e.variable;y||(m="with (obj) {\n"+m+"\n}\n");m=(c?m.replace(v,""):m).replace(x,"$1").replace(b,"$1;");m="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(l?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var T=Vt((function(){return Function(h,g+"return "+m).apply(void 0,p)}));T.source=m;if(Lt(T))throw T;return T}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._reinterpolate":6,"lodash.templatesettings":10}],10:[function(t,e,i){(function(i){var r=t("lodash._reinterpolate"),n=1/0,o="[object Null]",s="[object Symbol]",a="[object Undefined]",l=/[&<>"']/g,c=RegExp(l.source),u="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=u||h||Function("return this")();var d,f=(d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},function(t){return null==d?void 0:d[t]}),m=Object.prototype,_=m.hasOwnProperty,g=m.toString,y=p.Symbol,v=y?y.toStringTag:void 0,x=y?y.prototype:void 0,b=x?x.toString:void 0,w={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:r,variable:"",imports:{_:{escape:function(t){return(t=(e=t,null==e?"":M(e)))&&c.test(t)?t.replace(l,f):t;var e}}}};function T(t){return null==t?void 0===t?a:o:v&&v in Object(t)?function(t){var e=_.call(t,v),i=t[v];try{t[v]=void 0;var r=!0}catch(t){}var n=g.call(t);r&&(e?t[v]=i:delete t[v]);return n}(t):function(t){return g.call(t)}(t)}function M(t){if("string"==typeof t)return t;if(E(t))return function(t,e){for(var i=-1,r=null==t?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}(t,M)+"";if(function(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&T(t)==s}(t))return b?b.call(t):"";var e=t+"";return"0"==e&&1/t==-n?"-0":e}var E=Array.isArray;e.exports=w}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._reinterpolate":6}],11:[function(t,e,i){var r=t("./_root").Symbol;e.exports=r},{"./_root":18}],12:[function(t,e,i){var r=t("./_Symbol"),n=t("./_getRawTag"),o=t("./_objectToString"),s=r?r.toStringTag:void 0;e.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?n(t):o(t)}},{"./_Symbol":11,"./_getRawTag":15,"./_objectToString":16}],13:[function(t,e,i){(function(t){var i="object"==typeof t&&t&&t.Object===Object&&t;e.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],14:[function(t,e,i){var r=t("./_overArg")(Object.getPrototypeOf,Object);e.exports=r},{"./_overArg":17}],15:[function(t,e,i){var r=t("./_Symbol"),n=Object.prototype,o=n.hasOwnProperty,s=n.toString,a=r?r.toStringTag:void 0;e.exports=function(t){var e=o.call(t,a),i=t[a];try{t[a]=void 0;var r=!0}catch(t){}var n=s.call(t);r&&(e?t[a]=i:delete t[a]);return n}},{"./_Symbol":11}],16:[function(t,e,i){var r=Object.prototype.toString;e.exports=function(t){return r.call(t)}},{}],17:[function(t,e,i){e.exports=function(t,e){return function(i){return t(e(i))}}},{}],18:[function(t,e,i){var r=t("./_freeGlobal"),n="object"==typeof self&&self&&self.Object===Object&&self,o=r||n||Function("return this")();e.exports=o},{"./_freeGlobal":13}],19:[function(t,e,i){e.exports=function(t){return null!=t&&"object"==typeof t}},{}],20:[function(t,e,i){var r=t("./_baseGetTag"),n=t("./_getPrototype"),o=t("./isObjectLike"),s=Function.prototype,a=Object.prototype,l=s.toString,c=a.hasOwnProperty,u=l.call(Object);e.exports=function(t){if(!o(t)||"[object Object]"!=r(t))return!1;var e=n(t);if(null===e)return!0;var i=c.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==u}},{"./_baseGetTag":12,"./_getPrototype":14,"./isObjectLike":19}],21:[function(t,e,i){var r,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();function l(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout){r=setTimeout;return setTimeout(t,0)}try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}var c,u=[],h=!1,p=-1;function d(){if(h&&c){h=!1;c.length?u=c.concat(u):p=-1;u.length&&f()}}function f(){if(!h){var t=l(d);h=!0;for(var e=u.length;e;){c=u;u=[];for(;++p<e;)c&&c[p].run();p=-1;e=u.length}c=null;h=!1;!function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout){n=clearTimeout;return clearTimeout(t)}try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];u.push(new m(t,e));1!==u.length||h||l(f)};function m(t,e){this.fun=t;this.array=e}m.prototype.run=function(){this.fun.apply(null,this.array)};o.title="browser";o.browser=!0;o.env={};o.argv=[];o.version="";o.versions={};function _(){}o.on=_;o.addListener=_;o.once=_;o.off=_;o.removeListener=_;o.removeAllListeners=_;o.emit=_;o.prependListener=_;o.prependOnceListener=_;o.listeners=function(t){return[]};o.binding=function(t){throw new Error("process.binding is not supported")};o.cwd=function(){return"/"};o.chdir=function(t){throw new Error("process.chdir is not supported")};o.umask=function(){return 0}},{}],22:[function(t,e,i){"use strict";i.__esModule=!0;function r(t){return function(e){var i=e.dispatch,r=e.getState;return function(e){return function(n){return"function"==typeof n?n(i,r,t):e(n)}}}}var n=r();n.withExtraArgument=r;i.default=n},{}],23:[function(t,e,i){"use strict";i.__esModule=!0;var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t};i.default=function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t){return function(i,n,o){var a,l=t(i,n,o),c=l.dispatch,u={getState:l.getState,dispatch:function(t){return c(t)}};a=e.map((function(t){return t(u)}));c=s.default.apply(void 0,a)(l.dispatch);return r({},l,{dispatch:c})}}};var n,o=t("./compose"),s=(n=o)&&n.__esModule?n:{default:n}},{"./compose":26}],24:[function(t,e,i){"use strict";i.__esModule=!0;i.default=function(t,e){if("function"==typeof t)return r(t,e);if("object"!=typeof t||null===t)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var i=Object.keys(t),n={},o=0;o<i.length;o++){var s=i[o],a=t[s];"function"==typeof a&&(n[s]=r(a,e))}return n};function r(t,e){return function(){return e(t.apply(void 0,arguments))}}},{}],25:[function(t,e,i){(function(e){"use strict";i.__esModule=!0;i.default=function(t){for(var i=Object.keys(t),s={},l=0;l<i.length;l++){var c=i[l];"production"!==e.env.NODE_ENV&&void 0===t[c]&&(0,o.default)('No reducer provided for key "'+c+'"');"function"==typeof t[c]&&(s[c]=t[c])}var u=Object.keys(s),h=void 0;"production"!==e.env.NODE_ENV&&(h={});var p=void 0;try{!function(t){Object.keys(t).forEach((function(e){var i=t[e];if(void 0===i(void 0,{type:r.ActionTypes.INIT}))throw new Error('Reducer "'+e+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===i(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw new Error('Reducer "'+e+"\" returned undefined when probed with a random type. Don't try to handle "+r.ActionTypes.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(s)}catch(t){p=t}return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments[1];if(p)throw p;if("production"!==e.env.NODE_ENV){var l=function(t,e,i,o){var s=Object.keys(e),a=i&&i.type===r.ActionTypes.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===s.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!(0,n.default)(t))return"The "+a+' has unexpected type of "'+{}.toString.call(t).match(/\s([a-z|A-Z]+)/)[1]+'". Expected argument to be an object with the following keys: "'+s.join('", "')+'"';var l=Object.keys(t).filter((function(t){return!e.hasOwnProperty(t)&&!o[t]}));l.forEach((function(t){o[t]=!0}));if(l.length>0)return"Unexpected "+(l.length>1?"keys":"key")+' "'+l.join('", "')+'" found in '+a+'. Expected to find one of the known reducer keys instead: "'+s.join('", "')+'". Unexpected keys will be ignored.'}(t,s,i,h);l&&(0,o.default)(l)}for(var c=!1,d={},f=0;f<u.length;f++){var m=u[f],_=s[m],g=t[m],y=_(g,i);if(void 0===y){var v=a(m,i);throw new Error(v)}d[m]=y;c=c||y!==g}return c?d:t}};var r=t("./createStore"),n=s(t("lodash/isPlainObject")),o=s(t("./utils/warning"));function s(t){return t&&t.__esModule?t:{default:t}}function a(t,e){var i=e&&e.type;return"Given action "+(i&&'"'+i.toString()+'"'||"an action")+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}}).call(this,t("_process"))},{"./createStore":27,"./utils/warning":29,_process:21,"lodash/isPlainObject":20}],26:[function(t,e,i){"use strict";i.__esModule=!0;i.default=function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];if(0===e.length)return function(t){return t};if(1===e.length)return e[0];return e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}},{}],27:[function(t,e,i){"use strict";i.__esModule=!0;i.ActionTypes=void 0;i.default=function t(e,i,o){var a;if("function"==typeof i&&void 0===o){o=i;i=void 0}if(void 0!==o){if("function"!=typeof o)throw new Error("Expected the enhancer to be a function.");return o(t)(e,i)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var l=e,c=i,u=[],h=u,p=!1;function d(){h===u&&(h=u.slice())}function f(){return c}function m(t){if("function"!=typeof t)throw new Error("Expected listener to be a function.");var e=!0;d();h.push(t);return function(){if(e){e=!1;d();var i=h.indexOf(t);h.splice(i,1)}}}function _(t){if(!(0,r.default)(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===t.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(p)throw new Error("Reducers may not dispatch actions.");try{p=!0;c=l(c,t)}finally{p=!1}for(var e=u=h,i=0;i<e.length;i++){(0,e[i])()}return t}_({type:s.INIT});return(a={dispatch:_,subscribe:m,getState:f,replaceReducer:function(t){if("function"!=typeof t)throw new Error("Expected the nextReducer to be a function.");l=t;_({type:s.INIT})}})[n.default]=function(){var t,e=m;return(t={subscribe:function(t){if("object"!=typeof t)throw new TypeError("Expected the observer to be an object.");function i(){t.next&&t.next(f())}i();return{unsubscribe:e(i)}}})[n.default]=function(){return this},t},a};var r=o(t("lodash/isPlainObject")),n=o(t("symbol-observable"));function o(t){return t&&t.__esModule?t:{default:t}}var s=i.ActionTypes={INIT:"@@redux/INIT"}},{"lodash/isPlainObject":20,"symbol-observable":33}],28:[function(t,e,i){(function(e){"use strict";i.__esModule=!0;i.compose=i.applyMiddleware=i.bindActionCreators=i.combineReducers=i.createStore=void 0;var r=l(t("./createStore")),n=l(t("./combineReducers")),o=l(t("./bindActionCreators")),s=l(t("./applyMiddleware")),a=l(t("./compose"));l(t("./utils/warning"));function l(t){return t&&t.__esModule?t:{default:t}}function c(){}"production"!==e.env.NODE_ENV&&"string"==typeof c.name&&c.name;i.createStore=r.default;i.combineReducers=n.default;i.bindActionCreators=o.default;i.applyMiddleware=s.default;i.compose=a.default}).call(this,t("_process"))},{"./applyMiddleware":23,"./bindActionCreators":24,"./combineReducers":25,"./compose":26,"./createStore":27,"./utils/warning":29,_process:21}],29:[function(t,e,i){"use strict";i.__esModule=!0;i.default=function(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw new Error(t)}catch(t){}}},{}],30:[function(t,e,i){"use strict";var r=t("./src/suggestions");window.Suggestions=e.exports=r},{"./src/suggestions":32}],31:[function(t,e,i){var r=function(t){this.component=t;this.items=[];this.active=0;this.element=document.createElement("ul");this.element.className="suggestions";this.selectingListItem=!1;t.el.parentNode.insertBefore(this.element,t.el.nextSibling);return this};r.prototype.show=function(){this.element.style.display="block"};r.prototype.hide=function(){this.element.style.display="none"};r.prototype.add=function(t){this.items.push(t)};r.prototype.clear=function(){this.items=[];this.active=0};r.prototype.isEmpty=function(){return!this.items.length};r.prototype.draw=function(){this.element.innerHTML="";if(0!==this.items.length){for(var t=0;t<this.items.length;t++)this.drawItem(this.items[t],this.active===t);this.show()}else this.hide()};r.prototype.drawItem=function(t,e){var i=document.createElement("li"),r=document.createElement("a");e&&(i.className+=" active");r.innerHTML=t.string;i.appendChild(r);this.element.appendChild(i);i.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this));i.addEventListener("mouseup",function(){this.handleMouseUp.call(this,t)}.bind(this))};r.prototype.handleMouseUp=function(t){this.selectingListItem=!1;this.component.value(t.original);this.clear();this.draw()};r.prototype.move=function(t){this.active=t;this.draw()};r.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)};r.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)};e.exports=r},{}],32:[function(t,e,i){"use strict";var r=t("xtend"),n=t("fuzzy"),o=t("./list"),s=function(t,e,i){i=i||{};this.options=r({minLength:2,limit:5,filter:!0},i);this.el=t;this.data=e||[];this.list=new o(this);this.query="";this.selected=null;this.list.draw();this.el.addEventListener("keyup",function(t){this.handleKeyUp(t.keyCode)}.bind(this),!1);this.el.addEventListener("keydown",function(t){this.handleKeyDown(t)}.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(t){this.handlePaste(t)}.bind(this));return this};s.prototype.handleKeyUp=function(t){40!==t&&38!==t&&27!==t&&13!==t&&9!==t&&this.handleInputChange(this.el.value)};s.prototype.handleKeyDown=function(t){switch(t.keyCode){case 13:case 9:t.preventDefault();if(!this.list.isEmpty()){this.value(this.list.items[this.list.active].original);this.list.hide()}break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}};s.prototype.handleBlur=function(){this.list.selectingListItem||this.list.hide()};s.prototype.handlePaste=function(t){if(t.clipboardData)this.handleInputChange(t.clipboardData.getData("Text"));else{var e=this;setTimeout((function(){e.handleInputChange(t.target.value)}),100)}};s.prototype.handleInputChange=function(t){this.query=this.normalize(t);this.list.clear();this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(t){for(var e=0;e<t.length;e++){this.list.add(t[e]);if(e===this.options.limit-1)break}this.list.draw()}.bind(this))};s.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show();this.list.selectingListItem=!1};s.prototype.update=function(t){this.data=t;this.handleKeyUp()};s.prototype.clear=function(){this.data=[];this.list.clear()};s.prototype.normalize=function(t){return t=t.toLowerCase()};s.prototype.match=function(t,e){return t.indexOf(e)>-1};s.prototype.value=function(t){this.selected=t;this.el.value=this.getItemValue(t);if(document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1);this.el.dispatchEvent(e)}else this.el.fireEvent("onchange")};s.prototype.getCandidates=function(t){var e={pre:"<strong>",post:"</strong>",extract:function(t){return this.getItemValue(t)}.bind(this)};t(this.options.filter?n.filter(this.query,this.data,e):this.data.map(function(t){for(var e=this.getItemValue(t),i=this.normalize(e),r=i.lastIndexOf(this.query);r>-1;){var n=r+this.query.length;e=e.slice(0,r)+"<strong>"+e.slice(r,n)+"</strong>"+e.slice(n);r=i.slice(0,r).lastIndexOf(this.query)}return{original:t,string:e}}.bind(this)))};s.prototype.getItemValue=function(t){return t};e.exports=s},{"./list":31,fuzzy:4,xtend:37}],33:[function(t,e,i){(function(r){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n,o,s=t("./ponyfill.js"),a=(n=s)&&n.__esModule?n:{default:n};o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r?r:void 0!==e?e:Function("return this")();var l=(0,a.default)(o);i.default=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./ponyfill.js":34}],34:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.default=function(t){var e,i=t.Symbol;if("function"==typeof i)if(i.observable)e=i.observable;else{e=i("observable");i.observable=e}else e="@@observable";return e}},{}],35:[function(t,e,i){var r=t("turf-meta").coordEach;e.exports=function(t){var e=[1/0,1/0,-1/0,-1/0];r(t,(function(t){e[0]>t[0]&&(e[0]=t[0]);e[1]>t[1]&&(e[1]=t[1]);e[2]<t[0]&&(e[2]=t[0]);e[3]<t[1]&&(e[3]=t[1])}));return e}},{"turf-meta":36}],36:[function(t,e,i){function r(t,e,i){var r,n,o,s,a,c,u,h,p,d=0,f="FeatureCollection"===t.type,m="Feature"===t.type,_=f?t.features.length:1;for(r=0;r<_;r++){c=(p="GeometryCollection"===(h=f?t.features[r].geometry:m?t.geometry:t).type)?h.geometries.length:1;for(s=0;s<c;s++){u=(a=p?h.geometries[s]:h).coordinates;d=!i||"Polygon"!==a.type&&"MultiPolygon"!==a.type?0:1;if("Point"===a.type)e(u);else if("LineString"===a.type||"MultiPoint"===a.type)for(n=0;n<u.length;n++)e(u[n]);else if("Polygon"===a.type||"MultiLineString"===a.type)for(n=0;n<u.length;n++)for(o=0;o<u[n].length-d;o++)e(u[n][o]);else{if("MultiPolygon"!==a.type)throw new Error("Unknown Geometry Type");for(n=0;n<u.length;n++)for(o=0;o<u[n].length;o++)for(l=0;l<u[n][o].length-d;l++)e(u[n][o][l])}}}}e.exports.coordEach=r;e.exports.coordReduce=function(t,e,i,n){r(t,(function(t){i=e(i,t)}),n);return i};function n(t,e){var i;switch(t.type){case"FeatureCollection":features=t.features;for(i=0;i<t.features.length;i++)e(t.features[i].properties);break;case"Feature":e(t.properties)}}e.exports.propEach=n;e.exports.propReduce=function(t,e,i){n(t,(function(t){i=e(i,t)}));return i}},{}],37:[function(t,e,i){e.exports=function(){for(var t={},e=0;e<arguments.length;e++){var i=arguments[e];for(var n in i)r.call(i,n)&&(t[n]=i[n])}return t};var r=Object.prototype.hasOwnProperty},{}],38:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.queryOrigin=function(t){return{type:n.ORIGIN_QUERY,query:t}};i.queryDestination=function(t){return{type:n.DESTINATION_QUERY,query:t}};i.queryOriginCoordinates=m;i.queryDestinationCoordinates=_;i.clearOrigin=function(){return function(t){t({type:n.ORIGIN_CLEAR});t(x("clear",{type:"origin"}));t(f(null))}};i.clearDestination=function(){return function(t){t({type:n.DESTINATION_CLEAR});t(x("clear",{type:"destination"}));t(f(null))}};i.setOptions=function(t){return{type:n.SET_OPTIONS,options:t}};i.hoverMarker=function(t){return function(e){e(function(t){return{type:n.HOVER_MARKER,hoverMarker:t}}(t?s.default.createPoint(t,{id:"hover"}):{}))}};i.setRouteIndex=g;i.createOrigin=y;i.createDestination=v;i.setProfile=function(t){return function(e,i){var r=i(),o=r.origin,s=r.destination;e({type:n.DIRECTIONS_PROFILE,profile:t});e(x("profile",{profile:t}));o.geometry&&s.geometry&&e(p())}};i.reverse=function(){return function(t,e){var i=e();i.destination.geometry&&t(l(i.destination.geometry.coordinates));i.origin.geometry&&t(c(i.origin.geometry.coordinates));i.origin.geometry&&i.destination.geometry&&t(p());for(var r=document.getElementsByClassName("suggestions"),n=0;n<r.length;n++)r[n].style.visibility="hidden"}};i.setOriginFromCoordinates=function(t){return function(e){s.default.validCoords(t)||(t=[s.default.wrap(t[0]),s.default.wrap(t[1])]);if(isNaN(t[0])&&isNaN(t[1]))return e(f(new Error("Coordinates are not valid")));e(m(t));e(y(t))}};i.setDestinationFromCoordinates=function(t){return function(e){s.default.validCoords(t)||(t=[s.default.wrap(t[0]),s.default.wrap(t[1])]);if(isNaN(t[0])&&isNaN(t[1]))return e(f(new Error("Coordinates are not valid")));e(v(t));e(_(t))}};i.addWaypoint=function(t,e){return function(i,r){var n=r(),o=n.destination,s=n.waypoints;s.splice(t,0,d(e));i(h(s));o.geometry&&i(p())}};i.setWaypoint=function(t,e){return function(i,r){var n=r(),o=n.destination,s=n.waypoints;s[t]=d(e);i(h(s));o.geometry&&i(p())}};i.removeWaypoint=function(t){return function(e,i){var r=i(),n=r.destination,o=r.waypoints;e(h(o=o.filter((function(e){return!s.default.coordinateMatch(e,t)}))));n.geometry&&e(p())}};i.eventSubscribe=function(t,e){return function(i,r){var o=r().events;o[t]=o[t]||[];o[t].push(e);return{type:n.EVENTS,events:o}}};i.eventEmit=x;var r,n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e}(t("../constants/action_types")),o=t("../utils"),s=(r=o)&&r.__esModule?r:{default:r};var a=new XMLHttpRequest;function l(t){return function(e){var i=s.default.createPoint(t,{id:"origin","marker-symbol":"A"});e({type:n.ORIGIN,origin:i});e(x("origin",{feature:i}))}}function c(t){return function(e){var i=s.default.createPoint(t,{id:"destination","marker-symbol":"B"});e({type:n.DESTINATION,destination:i});e(x("destination",{feature:i}))}}function u(t){return function(e){e({type:n.DIRECTIONS,directions:t});e(x("route",{route:t}))}}function h(t){return{type:n.WAYPOINTS,waypoints:t}}function p(){return function(t,e){var i=e(),r=i.api,n=i.accessToken,o=i.routeIndex,s=i.profile,h=i.alternatives,p=i.congestion,d=i.destination,m=i.language,_=i.exclude;if(d&&d.geometry){var y=function(t){var e=t(),i=e.origin,r=e.destination,n=e.waypoints,o=[];o.push(i.geometry.coordinates.join(","));o.push(";");n.length&&n.forEach((function(t){o.push(t.geometry.coordinates.join(","));o.push(";")}));o.push(r.geometry.coordinates.join(","));return encodeURIComponent(o.join(""))}(e),v=[];v.push("geometries=polyline");h&&v.push("alternatives=true");p&&v.push("annotations=congestion");v.push("steps=true");v.push("overview=full");m&&v.push("language="+m);_&&v.push("exclude="+_);n&&v.push("access_token="+n);a.abort();a.open("GET",""+r+s+"/"+y+".json?"+v.join("&"),!0);a.onload=function(){if(!(a.status>=200&&a.status<400)){t(u([]));return t(f(JSON.parse(a.responseText).message))}var e=JSON.parse(a.responseText);if(e.error){t(u([]));return t(f(e.error))}t(f(null));e.routes[o]||t(g(0));t(u(e.routes));t(l(e.waypoints[0].location));t(c(e.waypoints[e.waypoints.length-1].location))};a.onerror=function(){t(u([]));return t(f(JSON.parse(a.responseText).message))};a.send()}}}function d(t){var e={id:"waypoint"};return Object.assign(t,{properties:t.properties?Object.assign(t.properties,e):e})}function f(t){return function(e){e({type:"ERROR",error:t});t&&e(x("error",{error:t}))}}function m(t){return{type:n.ORIGIN_FROM_COORDINATES,coordinates:t}}function _(t){return{type:n.DESTINATION_FROM_COORDINATES,coordinates:t}}function g(t){return{type:n.ROUTE_INDEX,routeIndex:t}}function y(t){return function(e,i){var r=i().destination;e(l(t));r.geometry&&e(p())}}function v(t){return function(e,i){var r=i().origin;e(c(t));r.geometry&&e(p())}}function x(t,e){var i=this;return function(r,o){var s=o().events;if(!s[t])return{type:n.EVENTS,events:s};for(var a=s[t].slice(),l=0;l<a.length;l++)a[l].call(i,e)}}},{"../constants/action_types":39,"../utils":47}],39:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.DESTINATION="DESTINATION",i.DESTINATION_CLEAR="DESTINATION_CLEAR",i.DESTINATION_QUERY="DESTINATION_QUERY",i.DESTINATION_FROM_COORDINATES="DESTINATION_FROM_COORDINATES",i.DIRECTIONS="DIRECTIONS",i.DIRECTIONS_PROFILE="DIRECTIONS_PROFILE",i.EVENTS="EVENTS",i.ERROR="ERROR",i.HOVER_MARKER="HOVER_MARKER",i.ORIGIN="ORIGIN",i.ORIGIN_CLEAR="ORIGIN_CLEAR",i.ORIGIN_QUERY="ORIGIN_QUERY",i.ORIGIN_FROM_COORDINATES="ORIGIN_FROM_COORDINATES",i.ROUTE_INDEX="ROUTE_INDEX",i.SET_OPTIONS="SET_OPTIONS",i.WAYPOINTS="WAYPOINTS"},{}],40:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1;r.configurable=!0;"value"in r&&(r.writable=!0);Object.defineProperty(t,r.key,r)}}return function(e,i,r){i&&t(e.prototype,i);r&&t(e,r);return e}}(),o=c(t("suggestions")),s=c(t("lodash.debounce")),a=t("events"),l=c(t("../utils"));function c(t){return t&&t.__esModule?t:{default:t}}var u=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this._ev=new a.EventEmitter;this.options=e;this.api=e&&e.api||"https://api.mapbox.com/geocoding/v5/mapbox.places/"}n(t,[{key:"onAdd",value:function(t){this._map=t;this.request=new XMLHttpRequest;var e=document.createElement("div");e.className="mapboxgl-ctrl-geocoder";var i=document.createElement("span");i.className="geocoder-icon geocoder-icon-search";var r=this._inputEl=document.createElement("input");r.type="text";r.placeholder=this.options.placeholder;r.addEventListener("keydown",(0,s.default)(function(t){if(!t.target.value)return this._clearEl.classList.remove("active");t.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(t.keyCode)||this._queryFromInput(t.target.value)}.bind(this)),200);r.addEventListener("change",function(e){e.target.value&&this._clearEl.classList.add("active");var i=this._typeahead.selected;if(i){if(this.options.flyTo)if(i.bbox&&i.context&&i.context.length<=3||i.bbox&&!i.context){var r=i.bbox;t.fitBounds([[r[0],r[1]],[r[2],r[3]]])}else t.flyTo({center:i.center,zoom:this.options.zoom});this._input=i;this.fire("result",{result:i})}}.bind(this));var n=document.createElement("div");n.classList.add("geocoder-pin-right");var a=this._clearEl=document.createElement("button");a.className="geocoder-icon geocoder-icon-close";a.addEventListener("click",this._clear.bind(this));var l=this._loadingEl=document.createElement("span");l.className="geocoder-icon geocoder-icon-loading";n.appendChild(a);n.appendChild(l);e.appendChild(i);e.appendChild(r);e.appendChild(n);this.options.container&&(this.options.position=!1);this._typeahead=new o.default(r,[],{filter:!1});this._typeahead.getItemValue=function(t){return t.place_name};return e}},{key:"_geocode",value:function(t,e){this._loadingEl.classList.add("active");this.fire("loading");var i=this.options,r=["placeholder","zoom","flyTo","accessToken"],n=Object.keys(this.options).filter((function(t){return-1===r.indexOf(t)})).map((function(t){return t+"="+i[t]})),o=this.options.accessToken?this.options.accessToken:mapboxgl.accessToken;n.push("access_token="+o);this.request.abort();this.request.open("GET",this.api+encodeURIComponent(t.trim())+".json?"+n.join("&"),!0);this.request.onload=function(){this._loadingEl.classList.remove("active");if(this.request.status>=200&&this.request.status<400){var t=JSON.parse(this.request.responseText);if(t.features.length)this._clearEl.classList.add("active");else{this._clearEl.classList.remove("active");this._typeahead.selected=null}this.fire("results",{results:t.features});this._typeahead.update(t.features);return e(t.features)}this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.onerror=function(){this._loadingEl.classList.remove("active");this.fire("error",{error:JSON.parse(this.request.responseText).message})}.bind(this);this.request.send()}},{key:"_queryFromInput",value:function(t){(t=t.trim())||this._clear();t.length>2&&this._geocode(t,function(t){this._results=t}.bind(this))}},{key:"_change",value:function(){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1);this._inputEl.dispatchEvent(t)}},{key:"_query",value:function(t){if(t){"object"===(void 0===t?"undefined":r(t))&&t.length&&(t=[l.default.wrap(t[0]),l.default.wrap(t[1])].join());this._geocode(t,function(t){if(t.length){var e=t[0];this._results=t;this._typeahead.selected=e;this._inputEl.value=e.place_name;this._change()}}.bind(this))}}},{key:"_setInput",value:function(t){if(t){"object"===(void 0===t?"undefined":r(t))&&t.length&&(t=[l.default.roundWithOriginalPrecision(l.default.wrap(t[0]),t[0]),l.default.roundWithOriginalPrecision(l.default.wrap(t[1]),t[1])].join());this._inputEl.value=t;this._input=null;this._typeahead.selected=null;this._typeahead.clear();this._change()}}},{key:"_clear",value:function(){this._input=null;this._inputEl.value="";this._typeahead.selected=null;this._typeahead.clear();this._change();this._inputEl.focus();this._clearEl.classList.remove("active");this.fire("clear")}},{key:"getResult",value:function(){return this._input}},{key:"query",value:function(t){this._query(t);return this}},{key:"setInput",value:function(t){this._setInput(t);return this}},{key:"on",value:function(t,e){this._ev.on(t,e);this._ev.on("error",(function(t){console.log(t)}));return this}},{key:"fire",value:function(t,e){this._ev.emit(t,e);return this}},{key:"off",value:function(t,e){this._ev.removeListener(t,e);return this}}]);return t}();i.default=u},{"../utils":47,events:3,"lodash.debounce":7,suggestions:30}],41:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1;r.configurable=!0;"value"in r&&(r.writable=!0);Object.defineProperty(t,r.key,r)}}return function(e,i,r){i&&t(e.prototype,i);r&&t(e,r);return e}}(),n=l(t("./geocoder")),o=l(t("lodash.template")),s=l(t("lodash.isequal")),a=l(t("turf-extent"));function l(t){return t&&t.__esModule?t:{default:t}}var c=(0,o.default)("<div class='mapbox-directions-component mapbox-directions-inputs'>\n <div class='mapbox-directions-component-keyline'>\n <div class='mapbox-directions-origin'>\n <label class='mapbox-form-label'>\n <span class='directions-icon directions-icon-depart'></span>\n </label>\n <div id='mapbox-directions-origin-input'></div>\n </div>\n\n <button\n class='directions-icon directions-icon-reverse directions-reverse js-reverse-inputs'\n title='Reverse origin &amp; destination'>\n </button>\n\n <div class='mapbox-directions-destination'>\n <label class='mapbox-form-label'>\n <span class='directions-icon directions-icon-arrive'></span>\n </label>\n <div id='mapbox-directions-destination-input'></div>\n </div>\n </div>\n\n <% if (controls.profileSwitcher) { %>\n <div class='mapbox-directions-profile mapbox-directions-component-keyline mapbox-directions-clearfix'><input\n id='mapbox-directions-profile-driving-traffic'\n type='radio'\n name='profile'\n value='mapbox/driving-traffic'\n <% if (profile === 'mapbox/driving-traffic') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-driving-traffic'>Traffic</label>\n <input\n id='mapbox-directions-profile-driving'\n type='radio'\n name='profile'\n value='mapbox/driving'\n <% if (profile === 'mapbox/driving') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-driving'>Driving</label>\n <input\n id='mapbox-directions-profile-walking'\n type='radio'\n name='profile'\n value='mapbox/walking'\n <% if (profile === 'mapbox/walking') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-walking'>Walking</label>\n <input\n id='mapbox-directions-profile-cycling'\n type='radio'\n name='profile'\n value='mapbox/cycling'\n <% if (profile === 'mapbox/cycling') { %>checked<% } %>\n />\n <label for='mapbox-directions-profile-cycling'>Cycling</label>\n </div>\n <% } %>\n</div>\n"),u=function(){function t(e,i,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var o=i.getState(),s=o.originQuery,a=o.destinationQuery,l=o.profile,u=o.controls;e.innerHTML=c({originQuery:s,destinationQuery:a,profile:l,controls:u});this.container=e;this.actions=r;this.store=i;this._map=n;this.onAdd();this.render()}r(t,[{key:"animateToCoordinates",value:function(t,e){var i=this.store.getState(),r=i.origin,n=i.destination,o=i.routePadding;if(r.geometry&&n.geometry&&!(0,s.default)(r.geometry,n.geometry)){var l=(0,a.default)({type:"FeatureCollection",features:[r,n]});this._map.fitBounds([[l[0],l[1]],[l[2],l[3]]],{padding:o})}else this._map.flyTo({center:e})}},{key:"onAdd",value:function(){var t=this,e=this.actions,i=e.clearOrigin,r=e.clearDestination,o=e.createOrigin,s=e.createDestination,a=e.setProfile,l=e.reverse,c=this.store.getState(),u=c.geocoder,h=c.accessToken,p=c.flyTo,d=c.placeholderOrigin,f=c.placeholderDestination,m=c.zoom;this.originInput=new n.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:d,zoom:m}));var _=this.originInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-origin-input").appendChild(_);this.destinationInput=new n.default(Object.assign({},{accessToken:h},u,{flyTo:p,placeholder:f,zoom:m}));var g=this.destinationInput.onAdd(this._map);this.container.querySelector("#mapbox-directions-destination-input").appendChild(g);this.originInput.on("result",(function(e){var i=e.result.center;o(i);t.animateToCoordinates("origin",i)}));this.originInput.on("clear",i);this.destinationInput.on("result",(function(e){var i=e.result.center;s(i);t.animateToCoordinates("destination",i)}));this.destinationInput.on("clear",r);var y=this.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(y,(function(t){t.addEventListener("change",(function(){a(t.value)}))}));this.container.querySelector(".js-reverse-inputs").addEventListener("click",(function(){var e=t.store.getState(),i=e.origin,r=e.destination;i&&t.actions.queryDestination(i.geometry.coordinates);r&&t.actions.queryOrigin(r.geometry.coordinates);l()}))}},{key:"render",value:function(){var t=this;this.store.subscribe((function(){var e=t.store.getState(),i=e.originQuery,r=e.destinationQuery,n=e.originQueryCoordinates,o=e.destinationQueryCoordinates;if(i){t.originInput.query(i);t.actions.queryOrigin(null)}if(r){t.destinationInput.query(r);t.actions.queryDestination(null)}if(n){t.originInput.setInput(n);t.animateToCoordinates("origin",n);t.actions.queryOriginCoordinates(null)}if(o){t.destinationInput.setInput(o);t.animateToCoordinates("destination",o);t.actions.queryDestinationCoordinates(null)}}))}}]);return t}();i.default=u},{"./geocoder":40,"lodash.isequal":8,"lodash.template":9,"turf-extent":35}],42:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1;r.configurable=!0;"value"in r&&(r.writable=!0);Object.defineProperty(t,r.key,r)}}return function(e,i,r){i&&t(e.prototype,i);r&&t(e,r);return e}}(),n=a(t("../utils")),o=a(t("lodash.template")),s=a(t("lodash.isequal"));function a(t){return t&&t.__esModule?t:{default:t}}var l=(0,o.default)("<div class='directions-control directions-control-directions'>\n <div class='mapbox-directions-component mapbox-directions-route-summary<% if (routes > 1) { %> mapbox-directions-multiple<% } %>'>\n <% if (routes > 1) { %>\n <div class='mapbox-directions-routes mapbox-directions-clearfix'>\n <% for (var i = 0; i < routes; i++) { %>\n <input type='radio' name='routes' id='<%= i %>' <% if (i === routeIndex) { %>checked<% } %>>\n <label for='<%= i %>' class='mapbox-directions-route'><%= i + 1 %></label>\n <% } %>\n </div>\n <% } %>\n <h1><%- duration %></h1>\n <span><%- distance %></span>\n </div>\n\n <div class='mapbox-directions-instructions'>\n <div class='mapbox-directions-instructions-wrapper'>\n <ol class='mapbox-directions-steps'>\n <% steps.forEach(function(step) { %>\n <%\n var distance = step.distance ? format(step.distance) : false;\n var icon = step.maneuver.modifier ? step.maneuver.modifier.replace(/\\s+/g, '-').toLowerCase() : step.maneuver.type.replace(/\\s+/g, '-').toLowerCase();\n\n if (step.maneuver.type === 'arrive' || step.maneuver.type === 'depart') {\n icon = step.maneuver.type;\n }\n\n if (step.maneuver.type === 'roundabout' || step.maneuver.type === 'rotary') {\n icon= 'roundabout';\n }\n\n var lng = step.maneuver.location[0];\n var lat = step.maneuver.location[1];\n %>\n <li\n data-lat='<%= lat %>'\n data-lng='<%= lng %>'\n class='mapbox-directions-step'>\n <span class='directions-icon directions-icon-<%= icon %>'></span>\n <div class='mapbox-directions-step-maneuver'>\n <%= step.maneuver.instruction %>\n </div>\n <% if (distance) { %>\n <div class='mapbox-directions-step-distance'>\n <%= distance %>\n </div>\n <% } %>\n </li>\n <% }); %>\n </ol>\n </div>\n </div>\n</div>\n"),c=(0,o.default)("<div class='directions-control directions-control-directions'>\n <div class='mapbox-directions-error'>\n <%= error %>\n </div>\n</div>\n"),u=function(){function t(e,i,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.container=e;this.actions=r;this.store=i;this._map=n;this.directions={};this.render()}r(t,[{key:"render",value:function(){var t=this;this.store.subscribe((function(){var e=t.actions,i=e.hoverMarker,r=e.setRouteIndex,o=t.store.getState(),a=o.routeIndex,u=o.unit,h=o.directions,p=o.error,d=o.compile,f=!(0,s.default)(h[a],t.directions);if(p)t.container.innerHTML=c({error:p});else if(h.length&&f){var m=t.directions=h[a];d&&m.legs.forEach((function(t){t.steps.forEach((function(t){t.maneuver.instruction=d("en",t)}))}));t.container.innerHTML=l({routeIndex:a,routes:h.length,steps:m.legs[0].steps,format:n.default.format[u],duration:n.default.format[u](m.distance),distance:n.default.format.duration(m.duration)});var _=t.container.querySelectorAll(".mapbox-directions-step");Array.prototype.forEach.call(_,(function(e){var r=e.getAttribute("data-lng"),n=e.getAttribute("data-lat");e.addEventListener("mouseover",(function(){i([r,n])}));e.addEventListener("mouseout",(function(){i(null)}));e.addEventListener("click",(function(){t._map.flyTo({center:[r,n],zoom:16})}))}));var g=t.container.querySelectorAll('input[type="radio"]');Array.prototype.forEach.call(g,(function(t){t.addEventListener("change",(function(t){r(parseInt(t.target.id,10))}))}))}else t.container.innerHTML&&f&&(t.container.innerHTML="")}))}}]);return t}();i.default=u},{"../utils":47,"lodash.isequal":8,"lodash.template":9}],43:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1;r.configurable=!0;"value"in r&&(r.writable=!0);Object.defineProperty(t,r.key,r)}}return function(e,i,r){i&&t(e.prototype,i);r&&t(e,r);return e}}(),n=t("redux"),o=d(t("redux-thunk")),s=t("@mapbox/polyline"),a=d(t("./utils")),l=d(t("./reducers")),c=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e}(t("./actions")),u=d(t("./directions_style")),h=d(t("./controls/inputs")),p=d(t("./controls/instructions"));function d(t){return t&&t.__esModule?t:{default:t}}var f=(0,n.applyMiddleware)(o.default)(n.createStore)(l.default),m=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.actions=(0,n.bindActionCreators)(c,f.dispatch);this.actions.setOptions(e||{});this.options=e||{};this.onDragDown=this._onDragDown.bind(this);this.onDragMove=this._onDragMove.bind(this);this.onDragUp=this._onDragUp.bind(this);this.move=this._move.bind(this);this.onClick=this._clickHandler().bind(this)}r(t,[{key:"onAdd",value:function(t){var e=this;this._map=t;var i=f.getState().controls,r=this.container=document.createElement("div");r.className="mapboxgl-ctrl-directions mapboxgl-ctrl";var n=document.createElement("div");n.className="directions-control directions-control-inputs";new h.default(n,f,this.actions,this._map);var o=document.createElement("div");o.className="directions-control directions-control-instructions";new p.default(o,f,{hoverMarker:this.actions.hoverMarker,setRouteIndex:this.actions.setRouteIndex},this._map);i.inputs&&r.appendChild(n);i.instructions&&r.appendChild(o);this.subscribedActions();this._map.loaded()?this.mapState():this._map.on("load",(function(){return e.mapState()}));return r}},{key:"onRemove",value:function(t){this.container.parentNode.removeChild(this.container);this.removeRoutes();t.off("mousedown",this.onDragDown);t.off("mousemove",this.move);t.off("touchstart",this.onDragDown);t.off("touchstart",this.move);t.off("click",this.onClick);if(this.storeUnsubscribe){this.storeUnsubscribe();delete this.storeUnsubscribe}u.default.forEach((function(e){t.getLayer(e.id)&&t.removeLayer(e.id)}));t.getSource("directions")&&t.removeSource("directions");this._map=null;return this}},{key:"mapState",value:function(){var t=this,e=f.getState(),i=e.profile,r=(e.alternatives,e.congestion,e.styles),n=e.interactive;e.compile;this.actions.eventEmit("profile",{profile:i});this._map.addSource("directions",{type:"geojson",data:{type:"FeatureCollection",features:[]}});r&&r.length&&r.forEach((function(e){return t._map.addLayer(e)}));u.default.forEach((function(e){t._map.getLayer(e.id)||t._map.addLayer(e)}));if(n){this._map.on("mousedown",this.onDragDown);this._map.on("mousemove",this.move);this._map.on("click",this.onClick);this._map.on("touchstart",this.move);this._map.on("touchstart",this.onDragDown)}}},{key:"subscribedActions",value:function(){var t=this;this.storeUnsubscribe=f.subscribe((function(){var e=f.getState(),i=e.origin,r=e.destination,n=e.hoverMarker,o=e.directions,a=e.routeIndex,l={type:"FeatureCollection",features:[i,r,n].filter((function(t){return t.geometry}))};o.length&&o.forEach((function(t,e){var i=[];(0,s.decode)(t.geometry,5).map((function(t){return t.reverse()})).forEach((function(r,n){var o=i[i.length-1],s=t.legs[0].annotation&&t.legs[0].annotation.congestion&&t.legs[0].annotation.congestion[n-1];if(!o||s&&o.properties.congestion!==s){var l={geometry:{type:"LineString",coordinates:[]},properties:{"route-index":e,route:e===a?"selected":"alternate"}};o&&l.geometry.coordinates.push(o.geometry.coordinates[o.geometry.coordinates.length-1]);l.geometry.coordinates.push(r);s&&(l.properties.congestion=t.legs[0].annotation.congestion[n-1]);i.push(l)}else o.geometry.coordinates.push(r)}));l.features=l.features.concat(i);e===a&&t.legs[0].steps.forEach((function(t){"waypoint"===t.maneuver.type&&l.features.push({type:"Feature",geometry:t.maneuver.location,properties:{id:"waypoint"}})}))}));t._map.style&&t._map.getSource("directions")&&t._map.getSource("directions").setData(l)}))}},{key:"_clickHandler",value:function(){var t=null;return function(e){if(t){clearTimeout(t);t=null;this._map.zoomIn()}else{var i=this._onSingleClick.bind(this);t=setTimeout((function(){i(e);t=null}),250)}}}},{key:"_onSingleClick",value:function(t){var e=this,i=f.getState().origin,r=[t.lngLat.lng,t.lngLat.lat];if(i.geometry){var n=this._map.queryRenderedFeatures(t.point,{layers:["directions-origin-point","directions-destination-point","directions-waypoint-point","directions-route-line-alt"]});if(n.length){n.forEach((function(t){"directions-waypoint-point"===t.layer.id&&e.actions.removeWaypoint(t)}));if("alternate"===n[0].properties.route){var o=n[0].properties["route-index"];this.actions.setRouteIndex(o)}}else{this.actions.setDestinationFromCoordinates(r);this._map.flyTo({center:r})}}else this.actions.setOriginFromCoordinates(r)}},{key:"_move",value:function(t){var e=this,i=f.getState().hoverMarker,r=this._map.queryRenderedFeatures(t.point,{layers:["directions-route-line-alt","directions-route-line","directions-origin-point","directions-destination-point","directions-hover-point"]});this._map.getCanvas().style.cursor=r.length?"pointer":"";if(r.length){this.isCursorOverPoint=r[0];this._map.dragPan.disable();r.forEach((function(r){"directions-route-line"===r.layer.id?e.actions.hoverMarker([t.lngLat.lng,t.lngLat.lat]):i.geometry&&e.actions.hoverMarker(null)}))}else if(this.isCursorOverPoint){this.isCursorOverPoint=!1;this._map.dragPan.enable()}}},{key:"_onDragDown",value:function(){if(this.isCursorOverPoint){this.isDragging=this.isCursorOverPoint;this._map.getCanvas().style.cursor="grab";this._map.on("mousemove",this.onDragMove);this._map.on("mouseup",this.onDragUp);this._map.on("touchmove",this.onDragMove);this._map.on("touchend",this.onDragUp)}}},{key:"_onDragMove",value:function(t){if(this.isDragging){var e=[t.lngLat.lng,t.lngLat.lat];switch(this.isDragging.layer.id){case"directions-origin-point":this.actions.createOrigin(e);break;case"directions-destination-point":this.actions.createDestination(e);break;case"directions-hover-point":this.actions.hoverMarker(e)}}}},{key:"_onDragUp",value:function(){if(this.isDragging){var t=f.getState(),e=t.hoverMarker,i=t.origin,r=t.destination;switch(this.isDragging.layer.id){case"directions-origin-point":this.actions.setOriginFromCoordinates(i.geometry.coordinates);break;case"directions-destination-point":this.actions.setDestinationFromCoordinates(r.geometry.coordinates);break;case"directions-hover-point":e.geometry&&!a.default.coordinateMatch(this.isDragging,e)&&this.actions.addWaypoint(0,e)}this.isDragging=!1;this._map.getCanvas().style.cursor="";this._map.off("touchmove",this.onDragMove);this._map.off("touchend",this.onDragUp);this._map.off("mousemove",this.onDragMove);this._map.off("mouseup",this.onDragUp)}}},{key:"interactive",value:function(t){if(t){this._map.on("touchstart",this.move);this._map.on("touchstart",this.onDragDown);this._map.on("mousedown",this.onDragDown);this._map.on("mousemove",this.move);this._map.on("click",this.onClick)}else{this._map.off("touchstart",this.move);this._map.off("touchstart",this.onDragDown);this._map.off("mousedown",this.onDragDown);this._map.off("mousemove",this.move);this._map.off("click",this.onClick)}return this}},{key:"getOrigin",value:function(){return f.getState().origin}},{key:"setOrigin",value:function(t){"string"==typeof t?this.actions.queryOrigin(t):this.actions.setOriginFromCoordinates(t);return this}},{key:"getDestination",value:function(){return f.getState().destination}},{key:"setDestination",value:function(t){"string"==typeof t?this.actions.queryDestination(t):this.actions.setDestinationFromCoordinates(t);return this}},{key:"reverse",value:function(){this.actions.reverse();return this}},{key:"addWaypoint",value:function(t,e){e.type||(e=a.default.createPoint(e,{id:"waypoint"}));this.actions.addWaypoint(t,e);return this}},{key:"setWaypoint",value:function(t,e){e.type||(e=a.default.createPoint(e,{id:"waypoint"}));this.actions.setWaypoint(t,e);return this}},{key:"removeWaypoint",value:function(t){var e=f.getState().waypoints;this.actions.removeWaypoint(e[t]);return this}},{key:"getWaypoints",value:function(){return f.getState().waypoints}},{key:"removeRoutes",value:function(){this.actions.clearOrigin();this.actions.clearDestination();return this}},{key:"on",value:function(t,e){this.actions.eventSubscribe(t,e);return this}}]);return t}();i.default=m},{"./actions":38,"./controls/inputs":41,"./controls/instructions":42,"./directions_style":44,"./reducers":46,"./utils":47,"@mapbox/polyline":1,redux:28,"redux-thunk":22}],44:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.default=[{id:"directions-route-line-alt",type:"line",source:"directions",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#bbb","line-width":4},filter:["all",["in","$type","LineString"],["in","route","alternate"]]},{id:"directions-route-line-casing",type:"line",source:"directions",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2d5f99","line-width":12},filter:["all",["in","$type","LineString"],["in","route","selected"]]},{id:"directions-route-line",type:"line",source:"directions",layout:{"line-cap":"butt","line-join":"round"},paint:{"line-color":{property:"congestion",type:"categorical",default:"#4882c5",stops:[["unknown","#4882c5"],["low","#4882c5"],["moderate","#f09a46"],["heavy","#e34341"],["severe","#8b2342"]]},"line-width":7},filter:["all",["in","$type","LineString"],["in","route","selected"]]},{id:"directions-hover-point-casing",type:"circle",source:"directions",paint:{"circle-radius":8,"circle-color":"#fff"},filter:["all",["in","$type","Point"],["in","id","hover"]]},{id:"directions-hover-point",type:"circle",source:"directions",paint:{"circle-radius":6,"circle-color":"#3bb2d0"},filter:["all",["in","$type","Point"],["in","id","hover"]]},{id:"directions-waypoint-point-casing",type:"circle",source:"directions",paint:{"circle-radius":8,"circle-color":"#fff"},filter:["all",["in","$type","Point"],["in","id","waypoint"]]},{id:"directions-waypoint-point",type:"circle",source:"directions",paint:{"circle-radius":6,"circle-color":"#8a8bc9"},filter:["all",["in","$type","Point"],["in","id","waypoint"]]},{id:"directions-origin-point",type:"circle",source:"directions",paint:{"circle-radius":18,"circle-color":"#3bb2d0"},filter:["all",["in","$type","Point"],["in","marker-symbol","A"]]},{id:"directions-origin-label",type:"symbol",source:"directions",layout:{"text-field":"A","text-font":["Open Sans Bold","Arial Unicode MS Bold"],"text-size":12},paint:{"text-color":"#fff"},filter:["all",["in","$type","Point"],["in","marker-symbol","A"]]},{id:"directions-destination-point",type:"circle",source:"directions",paint:{"circle-radius":18,"circle-color":"#8a8bc9"},filter:["all",["in","$type","Point"],["in","marker-symbol","B"]]},{id:"directions-destination-label",type:"symbol",source:"directions",layout:{"text-field":"B","text-font":["Open Sans Bold","Arial Unicode MS Bold"],"text-size":12},paint:{"text-color":"#fff"},filter:["all",["in","$type","Point"],["in","marker-symbol","B"]]}]},{}],45:[function(t,e,i){"use strict";var r,n=t("./directions"),o=(r=n)&&r.__esModule?r:{default:r};e.exports=o.default},{"./directions":43}],46:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r,n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e}(t("../constants/action_types.js")),o=t("deep-assign"),s=(r=o)&&r.__esModule?r:{default:r};var a={api:"https://api.mapbox.com/directions/v5/",profile:"mapbox/driving-traffic",alternatives:!1,congestion:!1,unit:"imperial",flyTo:!0,placeholderOrigin:"Choose a starting place",placeholderDestination:"Choose destination",zoom:16,language:"en",compile:null,proximity:!1,styles:[],controls:{profileSwitcher:!0,inputs:!0,instructions:!0},geocoder:{},interactive:!0,events:{},origin:{},destination:{},hoverMarker:{},waypoints:[],originQuery:null,destinationQuery:null,originQueryCoordinates:null,destinationQueryCoordinates:null,directions:[],routeIndex:0,routePadding:80};i.default=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,e=arguments[1];switch(e.type){case n.SET_OPTIONS:return(0,s.default)({},t,e.options);case n.DIRECTIONS_PROFILE:return Object.assign({},t,{profile:e.profile});case n.ORIGIN:return Object.assign({},t,{origin:e.origin,hoverMarker:{}});case n.DESTINATION:return Object.assign({},t,{destination:e.destination,hoverMarker:{}});case n.HOVER_MARKER:return Object.assign({},t,{hoverMarker:e.hoverMarker});case n.WAYPOINTS:return Object.assign({},t,{waypoints:e.waypoints});case n.ORIGIN_QUERY:return Object.assign({},t,{originQuery:e.query});case n.DESTINATION_QUERY:return Object.assign({},t,{destinationQuery:e.query});case n.ORIGIN_FROM_COORDINATES:return Object.assign({},t,{originQueryCoordinates:e.coordinates});case n.DESTINATION_FROM_COORDINATES:return Object.assign({},t,{destinationQueryCoordinates:e.coordinates});case n.ORIGIN_CLEAR:return Object.assign({},t,{origin:{},originQuery:"",waypoints:[],directions:[]});case n.DESTINATION_CLEAR:return Object.assign({},t,{destination:{},destinationQuery:"",waypoints:[],directions:[]});case n.DIRECTIONS:return Object.assign({},t,{directions:e.directions});case n.ROUTE_INDEX:return Object.assign({},t,{routeIndex:e.routeIndex});case n.ERROR:return Object.assign({},t,{error:e.error});default:return t}}},{"../constants/action_types.js":39,"deep-assign":2}],47:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r={duration:function(t){var e=Math.floor(t/60),i=Math.floor(e/60);t%=60;e%=60;return 0===i&&0===e?t+"s":0===i?e+"min":i+"h "+e+"min"},imperial:function(t){var e=t/1609.344;return e>=100?e.toFixed(0)+"mi":e>=10?e.toFixed(1)+"mi":e>=.1?e.toFixed(2)+"mi":(5280*e).toFixed(0)+"ft"},metric:function(t){return t>=1e5?(t/1e3).toFixed(0)+"km":t>=1e4?(t/1e3).toFixed(1)+"km":t>=100?(t/1e3).toFixed(2)+"km":t.toFixed(0)+"m"}};i.default={format:r,coordinateMatch:function(t,e){t=t.geometry.coordinates;e=e.geometry.coordinates;return t.join()===e.join()||t[0].toFixed(3)===e[0].toFixed(3)&&t[1].toFixed(3)===e[1].toFixed(3)},createPoint:function(t,e){return{type:"Feature",geometry:{type:"Point",coordinates:t},properties:e||{}}},validCoords:function(t){return t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90},wrap:function(t){var e=((t- -180)%360+360)%360-180;return-180===e?180:e},roundWithOriginalPrecision:function(t,e){var i=0;Math.floor(e)!==e&&(i=e.toString().split(".")[1].length);return t.toFixed(Math.min(i,5))}}},{}]},{},[45])(45)}));!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MapboxGeocoder=t()}}((function(){return function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};e[s][0].call(u.exports,(function(t){return n(e[s][1][t]||t)}),u,u.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){"use strict";function r(t){this.origin=t.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=t.accessToken,this.version="0.2.0",this.sessionID=this.generateSessionID(),this.userAgent=this.getUserAgent(),this.options=t,this.send=this.send.bind(this),this.countries=t.countries?t.countries.split(","):null,this.types=t.types?t.types.split(","):null,this.bbox=t.bbox?t.bbox:null,this.language=t.language?t.language.split(","):null,this.limit=t.limit?+t.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(t),this.eventQueue=new Array,this.flushInterval=t.flushInterval||1e3,this.maxQueueSize=t.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}var n=t("nanoid");r.prototype={select:function(t,e){var i=this.getSelectedIndex(t,e),r=this.getEventPayload("search.select",e);if(r.resultIndex=i,r.resultPlaceName=t.place_name,r.resultId=t.id,(i!==this.lastSentIndex||r.queryString!==this.lastSentInput)&&-1!=i&&(this.lastSentIndex=i,this.lastSentInput=r.queryString,r.queryString))return this.push(r)},start:function(t){var e=this.getEventPayload("search.start",t);if(e.queryString)return this.push(e)},keyevent:function(t,e){if(t.key&&!t.metaKey&&-1===[9,27,37,39,13,38,40].indexOf(t.keyCode)){var i=this.getEventPayload("search.keystroke",e);if(i.lastAction=t.key,i.queryString)return this.push(i)}},send:function(t,e){if(this.enableEventLogging){var i=this.getRequestOptions(t);this.request(i,function(t){return t?this.handleError(t,e):e?e():void 0}.bind(this))}else if(e)return e()},getRequestOptions:function(t){return Array.isArray(t)||(t=[t]),{method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}},getEventPayload:function(t,e){var i;i=e.options.proximity?[e.options.proximity.longitude,e.options.proximity.latitude]:null;var r=e._map?e._map.getZoom():void 0,n={event:t,created:+new Date,sessionIdentifier:this.sessionID,country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",proximity:i,limit:e.options.limit,mapZoom:r,keyboardLocale:this.locale};return"search.select"===t?n.queryString=e.inputString:"search.select"!=t&&e._inputEl?n.queryString=e._inputEl.value:n.queryString=e.inputString,n},request:function(t,e){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(4==this.readyState)return e(204==this.status?null:this.statusText)},i.open(t.method,t.host+"/"+t.path,!0);for(var r in t.headers){var n=t.headers[r];i.setRequestHeader(r,n)}i.send(t.body)},handleError:function(t,e){if(e)return e(t)},generateSessionID:function(){return n()},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(t,e){if(e._typeahead){var i=e._typeahead.data,r=t.id;return i.map((function(t){return t.id})).indexOf(r)}},shouldEnableLogging:function(t){return!(!1===t.enableEventLogging||t.origin&&-1==t.origin.indexOf("api.mapbox.com")||t.localGeocoder||t.filter)},flush:function(){this.eventQueue.length>0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(t,e){this.eventQueue.push(t),(this.eventQueue.length>=this.maxQueueSize||e)&&this.flush()},remove:function(){this.flush()}},e.exports=r},{nanoid:30}],2:[function(t,e,i){e.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]]}}},{}],3:[function(t,e,i){"use strict";function r(t){this._eventEmitter=new a,this.options=s({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null}var n=t("suggestions"),o=t("lodash.debounce"),s=t("xtend"),a=t("events").EventEmitter,l=t("./exceptions"),c=t("@mapbox/mapbox-sdk"),u=t("@mapbox/mapbox-sdk/services/geocoding"),h=t("./events"),p=t("./localization"),d=t("subtag");const f=0,m=1,_=2;r.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(t){return t.place_name},render:function(t){var e=t.place_name.split(",");return'<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">'+e[0]+'</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">'+e.splice(1,e.length).join(",")+"</div></div>"}},addTo:function(t){function e(t,e){if(!document.body.contains(e))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const i=t.onAdd();e.appendChild(i)}if(t._controlContainer)t.addControl(this);else if(t instanceof HTMLElement)e(this,t);else{if("string"!=typeof t)throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element");const i=document.querySelectorAll(t);if(0===i.length)throw new Error("Element ",t,"not found.");if(i.length>1)throw new Error("Geocoder can only be added to a single html element");e(this,i[0])}},onAdd:function(t){if(t&&"string"!=typeof t&&(this._map=t),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new h(this.options),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 e=this.container=document.createElement("div");e.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var i=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-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",o(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(t){this.eventManager.keyevent(t,this)}.bind(this));var r=document.createElement("div");r.classList.add("mapboxgl-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";var s=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');return this._clearEl.appendChild(s),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),e.appendChild(i),e.appendChild(this._inputEl),e.appendChild(r),this._typeahead=new n(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),e},createIcon:function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+t),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=e;else{var r=document.createElement("div");r.innerHTML="<svg>"+e.valueOf().toString()+"</svg>";var n=r.firstChild.firstChild;i.appendChild(n)}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(t){var e=(t.clipboardData||window.clipboardData).getData("text");e.length>=this.options.minLength&&this._geocode(e)},_onKeyDown:function(t){if(27===t.keyCode&&this.options.clearAndBlurOnEsc)return this._clear(t),this._inputEl.blur();var e=t.target&&t.target.shadowRoot?t.target.shadowRoot.activeElement:t.target;if(!e||!e.value)return this.fresh=!0,9!==t.keyCode&&this.clear(t),this._clearEl.style.display="none";t.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(t.keyCode)||e.value.length>=this.options.minLength&&this._geocode(e.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(t){this.options.clearOnBlur&&this._clearOnBlur(t),this.options.collapsed&&this._collapse()},_onChange:function(){var t=this._typeahead.selected;if(t&&JSON.stringify(t)!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var e;if(t.properties&&l[t.properties.short_code])e=s({},this.options.flyTo),this._map&&this._map.fitBounds(l[t.properties.short_code].bbox,e);else if(t.bbox){var i=t.bbox;e=s({},this.options.flyTo),this._map&&this._map.fitBounds([[i[0],i[1]],[i[2],i[3]]],e)}else{var r={zoom:this.options.zoom};e=s({},r,this.options.flyTo),t.center?e.center=t.center:t.geometry&&t.geometry.type&&"Point"===t.geometry.type&&t.geometry.coordinates&&(e.center=t.geometry.coordinates),this._map&&this._map.flyTo(e)}}this.options.marker&&this._mapboxgl&&this._handleMarker(t),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(t),this._eventEmitter.emit("result",{result:t}),this.eventManager.select(t,this)}},_requestType:function(t,e){return t.localGeocoderOnly?m:t.reverseGeocode&&/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(e)?_:f},_setupConfig:function(t,e){const i=/[\s,]+/;var r=this,n=["bbox","limit","proximity","countries","types","language","reverseMode","mode"].reduce((function(t,e){if(!r.options[e])return t;["countries","types","language"].indexOf(e)>-1?t[e]=r.options[e].split(i):t[e]=r.options[e];const n="number"==typeof r.options[e].longitude&&"number"==typeof r.options[e].latitude;if("proximity"===e&&n){const i=r.options[e].longitude,n=r.options[e].latitude;t[e]=[i,n]}return t}),{});switch(t){case _:var o=e.split(i).map((function(t){return parseFloat(t,10)})).reverse();n.types&&n.types[0],"proximity"in(n=s(n,{query:o,limit:1}))&&delete n.proximity;break;case f:/^[ ]*(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)*[ ]*$/.test(e)&&(e=e.replace(/,/g," ")),n=s(n,{query:e})}return n},_geocode:function(t){this.inputString=t,this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:t});const e=this._requestType(this.options,t),i=this._setupConfig(e,t);var r;switch(e){case m:r=Promise.resolve();break;case f:r=this.geocoderService.forwardGeocode(i).send();break;case _:r=this.geocoderService.reverseGeocode(i).send()}var n=this.options.localGeocoder&&this.options.localGeocoder(t)||[],o=[],s=null;return r.catch(function(t){s=t}.bind(this)).then(function(e){this._loadingEl.style.display="none";var r={};return e?"200"==e.statusCode&&((r=e.body).request=e.request,r.headers=e.headers):r={type:"FeatureCollection",features:[]},r.config=i,this.fresh&&(this.eventManager.start(this),this.fresh=!1),r.features=r.features?n.concat(r.features):n,this.options.externalGeocoder?(o=this.options.externalGeocoder(t,r.features)||[]).then((function(t){return r.features=r.features?t.concat(r.features):t,r}),(function(){return r})):r}.bind(this)).then(function(t){if(s)throw s;this.options.filter&&t.features.length&&(t.features=t.features.filter(this.options.filter)),t.features.length?(this._clearEl.style.display="block",this._eventEmitter.emit("results",t),this._typeahead.update(t.features)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",t))}.bind(this)).catch(function(t){this._loadingEl.style.display="none",n.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._clearEl.style.display="block",this._typeahead.update(n)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:n}),this._eventEmitter.emit("error",{error:t})}.bind(this)),r},_clear:function(t){t&&t.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(t){this._clear(t),this._inputEl.focus()},_clearOnBlur:function(t){t.relatedTarget&&this._clear(t)},_onQueryResult:function(t){var e=t.body;if(e.features.length){var i=e.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 t=this._map.getCenter().wrap();this.setProximity({longitude:t.lng,latitude:t.lat})}else this.setProximity(null)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(t){return this._geocode(t).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error'>There was an error reaching the server</div>")},_renderNoResults:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error mapbox-gl-geocoder--no-results'>No results found</div>")},_renderMessage:function(t){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(t)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var t=this.options.language.split(",")[0],e=d.language(t),i=p.placeholder[e];if(i)return i}return"Search"},setInput:function(t){return this._inputEl.value=t,this._typeahead.selected=null,this._typeahead.clear(),t.length>=this.options.minLength&&this._geocode(t),this},setProximity:function(t){return this.options.proximity=t,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(t){return t&&"function"==typeof t&&(this._typeahead.render=t),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(t){var e=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=t||this.options.language||e,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(t){return this.options.zoom=t,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(t){return this.options.flyTo=t,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(t){return this.placeholder=t||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(t){return this.options.bbox=t,this},getCountries:function(){return this.options.countries},setCountries:function(t){return this.options.countries=t,this},getTypes:function(){return this.options.types},setTypes:function(t){return this.options.types=t,this},getMinLength:function(){return this.options.minLength},setMinLength:function(t){return this.options.minLength=t,this._typeahead&&(this._typeahead.options.minLength=t),this},getLimit:function(){return this.options.limit},setLimit:function(t){return this.options.limit=t,this._typeahead&&(this._typeahead.options.limit=t),this},getFilter:function(){return this.options.filter},setFilter:function(t){return this.options.filter=t,this},setOrigin:function(t){return this.options.origin=t,this.geocoderService=u(c({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},_handleMarker:function(t){if(this._map){this._removeMarker();var e=s({},{color:"#4668F2"},this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(e),t.center?this.mapMarker.setLngLat(t.center).addTo(this._map):t.geometry&&t.geometry.type&&"Point"===t.geometry.type&&t.geometry.coordinates&&this.mapMarker.setLngLat(t.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(t,e){return this._eventEmitter.on(t,e),this},off:function(t,e){return this._eventEmitter.removeListener(t,e),this.eventManager.remove(),this}},e.exports=r},{"./events":1,"./exceptions":2,"./localization":4,"@mapbox/mapbox-sdk":6,"@mapbox/mapbox-sdk/services/geocoding":17,events:25,"lodash.debounce":29,subtag:32,suggestions:33,xtend:36}],4:[function(t,e,i){"use strict";e.exports={placeholder:{de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje",fa:"جستجو",ru:"Поиск"}}},{}],5:[function(t,e,i){"use strict";function r(t){var e=Array.isArray(t),i=function(i){return e?t[i]:t};return function(r){var o=n(h.plainArray,r);if(o)return o;if(e&&r.length!==t.length)return"an array with "+t.length+" items";for(var s=0;s<r.length;s++)if(o=n(i(s),r[s]))return[s].concat(o)}}function n(t,e){if(null!=e||t.hasOwnProperty("__required")){var i=t(e);return i?Array.isArray(i)?i:[i]:void 0}}function o(t,e){var i=t.length,r=t[i-1],n=t.slice(0,i-1);return 0===n.length&&(n=[u]),e=c(e,{path:n}),"function"==typeof r?r(e):s(e,function(t){return"must be "+function(t){return/^an? /.test(t)?t:/^[aeiou]/i.test(t)?"an "+t:/^[a-z]/i.test(t)?"a "+t:t}(t)+"."}(r))}function s(t,e){return(a(t.path)?"Item at position ":"")+(t.path.join(".")+" "+e)}function a(t){return"number"==typeof t[t.length-1]||"number"==typeof t[0]}var l=t("is-plain-obj"),c=t("xtend"),u="value",h={assert:function(t,e){return e=e||{},function(i){var r=n(t,i);if(r){var s=o(r,e);throw e.apiName&&(s=e.apiName+": "+s),new Error(s)}}}};h.shape=function(t){var e=function(t){return Object.keys(t||{}).map((function(e){return{key:e,value:t[e]}}))}(t);return function(t){var i=n(h.plainObject,t);if(i)return i;for(var r,s=[],a=0;a<e.length;a++)r=e[a].key,(i=n(e[a].value,t[r]))&&s.push([r].concat(i));return s.length<2?s[0]:function(t){s=s.map((function(e){return"- "+e[0]+": "+o(e,t).split("\n").join("\n ")}));var e=t.path.join(".");return"The following properties"+(e===u?"":" of "+e)+" have invalid values:\n "+s.join("\n ")}}},h.strictShape=function(t){var e=h.shape(t);return function(i){var r=e(i);if(r)return r;var n=Object.keys(i).reduce((function(e,i){return void 0===t[i]&&e.push(i),e}),[]);return 0!==n.length?function(){return"The following keys are invalid: "+n.join(", ")}:void 0}},h.arrayOf=function(t){return r(t)},h.tuple=function(){return r(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments))},h.required=function(t){function e(e){return null==e?function(t){return s(t,a(t.path)?"cannot be undefined/null.":"is required.")}:t.apply(this,arguments)}return e.__required=!0,e},h.oneOfType=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(e){var i=t.map((function(t){return n(t,e)})).filter(Boolean);if(i.length===t.length)return i.every((function(t){return 1===t.length&&"string"==typeof t[0]}))?function(t){return t.length<2?t[0]:2===t.length?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t.slice(-1)}(i.map((function(t){return t[0]}))):i.reduce((function(t,e){return e.length>t.length?e:t}))}},h.equal=function(t){return function(e){if(e!==t)return JSON.stringify(t)}},h.oneOf=function(){var t=(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments)).map((function(t){return h.equal(t)}));return h.oneOfType.apply(this,t)},h.range=function(t){var e=t[0],i=t[1];return function(t){if(n(h.number,t)||t<e||t>i)return"number between "+e+" & "+i+" (inclusive)"}},h.any=function(){},h.boolean=function(t){if("boolean"!=typeof t)return"boolean"},h.number=function(t){if("number"!=typeof t)return"number"},h.plainArray=function(t){if(!Array.isArray(t))return"array"},h.plainObject=function(t){if(!l(t))return"object"},h.string=function(t){if("string"!=typeof t)return"string"},h.func=function(t){if("function"!=typeof t)return"function"},h.validate=n,h.processMessage=o,e.exports=h},{"is-plain-obj":28,xtend:36}],6:[function(t,e,i){"use strict";var r=t("./lib/client");e.exports=r},{"./lib/client":7}],7:[function(t,e,i){"use strict";function r(t){o.call(this,t)}var n=t("./browser-layer"),o=t("../classes/mapi-client");r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.sendRequest=n.browserSend,r.prototype.abortRequest=n.browserAbort,e.exports=function(t){return new r(t)}},{"../classes/mapi-client":9,"./browser-layer":8}],8:[function(t,e,i){"use strict";function r(t){var e=t.total,i=t.loaded;return{total:e,transferred:i,percent:100*i/e}}function n(t,e){return new Promise((function(i,n){e.onprogress=function(e){t.emitter.emit(l.EVENT_PROGRESS_DOWNLOAD,r(e))};var o=t.file;o&&(e.upload.onprogress=function(e){t.emitter.emit(l.EVENT_PROGRESS_UPLOAD,r(e))}),e.onerror=function(t){n(t)},e.onabort=function(){var e=new a({request:t,type:l.ERROR_REQUEST_ABORTED});n(e)},e.onload=function(){if(delete u[t.id],e.status<200||e.status>=400){var r=new a({request:t,body:e.response,statusCode:e.status});n(r)}else i(e)};var s=t.body;"string"==typeof s?e.send(s):s?e.send(JSON.stringify(s)):o?e.send(o):e.send(),u[t.id]=e})).then((function(e){return function(t,e){return new s(t,{body:e.response,headers:c(e.getAllResponseHeaders()),statusCode:e.status})}(t,e)}))}function o(t,e){var i=t.url(e),r=new window.XMLHttpRequest;return r.open(t.method,i),Object.keys(t.headers).forEach((function(e){r.setRequestHeader(e,t.headers[e])})),r}var s=t("../classes/mapi-response"),a=t("../classes/mapi-error"),l=t("../constants"),c=t("../helpers/parse-headers"),u={};e.exports={browserAbort:function(t){var e=u[t.id];e&&(e.abort(),delete u[t.id])},sendRequestXhr:n,browserSend:function(t){return Promise.resolve().then((function(){var e=o(t,t.client.accessToken);return n(t,e)}))},createRequestXhr:o}},{"../classes/mapi-error":10,"../classes/mapi-response":12,"../constants":13,"../helpers/parse-headers":14}],9:[function(t,e,i){"use strict";function r(t){if(!t||!t.accessToken)throw new Error("Cannot create a client without an access token");n(t.accessToken),this.accessToken=t.accessToken,this.origin=t.origin||s.API_ORIGIN}var n=t("@mapbox/parse-mapbox-token"),o=t("./mapi-request"),s=t("../constants");r.prototype.createRequest=function(t){return new o(this,t)},e.exports=r},{"../constants":13,"./mapi-request":11,"@mapbox/parse-mapbox-token":23}],10:[function(t,e,i){"use strict";var r=t("../constants");e.exports=function(t){var e,i=t.type||r.ERROR_HTTP;if(t.body)try{e=JSON.parse(t.body)}catch(i){e=t.body}else e=null;var n=t.message||null;n||("string"==typeof e?n=e:e&&"string"==typeof e.message?n=e.message:i===r.ERROR_REQUEST_ABORTED&&(n="Request aborted")),this.message=n,this.type=i,this.statusCode=t.statusCode||null,this.request=t.request,this.body=e}},{"../constants":13}],11:[function(t,e,i){"use strict";function r(t,e){if(!t)throw new Error("MapiRequest requires a client");if(!e||!e.path||!e.method)throw new Error("MapiRequest requires an options object with path and method properties");var i={};e.body&&(i["content-type"]="application/json");var r=o(i,e.headers),n=Object.keys(r).reduce((function(t,e){return t[e.toLowerCase()]=r[e],t}),{});this.id=c++,this._options=e,this.emitter=new s,this.client=t,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=e.path,this.method=e.method,this.origin=e.origin||t.origin,this.query=e.query||{},this.params=e.params||{},this.body=e.body||null,this.file=e.file||null,this.encoding=e.encoding||"utf8",this.sendFileAs=e.sendFileAs||null,this.headers=n}var n=t("@mapbox/parse-mapbox-token"),o=t("xtend"),s=t("eventemitter3"),a=t("../helpers/url-utils"),l=t("../constants"),c=1;r.prototype.url=function(t){var e=a.prependOrigin(this.path,this.origin);e=a.appendQueryObject(e,this.query);var i=this.params,r=null==t?this.client.accessToken:t;if(r){e=a.appendQueryParam(e,"access_token",r);var s=n(r).user;i=o({ownerId:s},i)}return e=a.interpolateRouteParams(e,i)},r.prototype.send=function(){var t=this;if(t.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return t.sent=!0,t.client.sendRequest(t).then((function(e){return t.response=e,t.emitter.emit(l.EVENT_RESPONSE,e),e}),(function(e){throw t.error=e,t.emitter.emit(l.EVENT_ERROR,e),e}))},r.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},r.prototype.eachPage=function(t){function e(e){t(null,e,(function(){delete n._nextPageRequest;var t=e.nextPage();t&&(n._nextPageRequest=t,r(t))}))}function i(e){t(e,null,(function(){}))}function r(t){t.send().then(e,i)}var n=this;r(this)},r.prototype.clone=function(){return this._extend()},r.prototype._extend=function(t){var e=o(this._options,t);return new r(this.client,e)},e.exports=r},{"../constants":13,"../helpers/url-utils":16,"@mapbox/parse-mapbox-token":23,eventemitter3:26,xtend:36}],12:[function(t,e,i){"use strict";function r(t,e){this.request=t,this.headers=e.headers,this.rawBody=e.body,this.statusCode=e.statusCode;try{this.body=JSON.parse(e.body||"{}")}catch(t){this.body=e.body}this.links=n(this.headers.link)}var n=t("../helpers/parse-link-header");r.prototype.hasNextPage=function(){return!!this.links.next},r.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},e.exports=r},{"../helpers/parse-link-header":15}],13:[function(t,e,i){"use strict";e.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},{}],14:[function(t,e,i){"use strict";e.exports=function(t){var e={};return t?(t.trim().split(/[\r|\n]+/).forEach((function(t){var i=function(t){var e=t.indexOf(":");return{name:t.substring(0,e).trim().toLowerCase(),value:t.substring(e+1).trim()}}(t);e[i.name]=i.value})),e):e}},{}],15:[function(t,e,i){"use strict";e.exports=function(t){return t?t.split(/,\s*</).reduce((function(t,e){var i=function(t){var e=t.match(/<?([^>]*)>(.*)/);if(!e)return null;var i=e[1],r=e[2].split(";"),n=null,o=r.reduce((function(t,e){var i=function(t){var e=t.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return e?{key:e[1],value:e[2]}:null}(e);return i?"rel"===i.key?(n||(n=i.value),t):(t[i.key]=i.value,t):t}),{});return n?{url:i,rel:n,params:o}:null}(e);return i?(i.rel.split(/\s+/).forEach((function(e){t[e]||(t[e]={url:i.url,params:i.params})})),t):t}),{}):{}}},{}],16:[function(t,e,i){"use strict";function r(t){return Array.isArray(t)?function(t){return t.map(encodeURIComponent).join(",")}(t):encodeURIComponent(String(t))}function n(t,e,i){if(!1===i||null===i)return t;var n=/\?/.test(t)?"&":"?",o=encodeURIComponent(e);return void 0!==i&&""!==i&&!0!==i&&(o+="="+r(i)),""+t+n+o}e.exports={appendQueryObject:function(t,e){if(!e)return t;var i=t;return Object.keys(e).forEach((function(t){var r=e[t];void 0!==r&&(Array.isArray(r)&&(r=r.filter((function(t){return null!=t})).join(",")),i=n(i,t,r))})),i},appendQueryParam:n,prependOrigin:function(t,e){if(!e)return t;if("http"===t.slice(0,4))return t;var i="/"===t[0]?"":"/";return""+e.replace(/\/$/,"")+i+t},interpolateRouteParams:function(t,e){return e?t.replace(/\/:([a-zA-Z0-9]+)/g,(function(t,i){var n=e[i];if(void 0===n)throw new Error("Unspecified route parameter "+i);return"/"+r(n)})):t}}},{}],17:[function(t,e,i){"use strict";var r=t("xtend"),n=t("./service-helpers/validator"),o=t("./service-helpers/pick"),s=t("./service-helpers/stringify-booleans"),a=t("./service-helpers/create-service-factory"),l={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];l.forwardGeocode=function(t){n.assertShape({query:n.required(n.string),mode:n.oneOf("mapbox.places","mapbox.places-permanent"),countries:n.arrayOf(n.string),proximity:n.coordinates,types:n.arrayOf(n.oneOf(c)),autocomplete:n.boolean,bbox:n.arrayOf(n.number),limit:n.number,language:n.arrayOf(n.string),routing:n.boolean})(t),t.mode=t.mode||"mapbox.places";var e=s(r({country:t.countries},o(t,["proximity","types","autocomplete","bbox","limit","language","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(t,["mode","query"]),query:e})},l.reverseGeocode=function(t){n.assertShape({query:n.required(n.coordinates),mode:n.oneOf("mapbox.places","mapbox.places-permanent"),countries:n.arrayOf(n.string),types:n.arrayOf(n.oneOf(c)),bbox:n.arrayOf(n.number),limit:n.number,language:n.arrayOf(n.string),reverseMode:n.oneOf("distance","score"),routing:n.boolean})(t),t.mode=t.mode||"mapbox.places";var e=s(r({country:t.countries},o(t,["country","types","bbox","limit","language","reverseMode","routing"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(t,["mode","query"]),query:e})},e.exports=a(l)},{"./service-helpers/create-service-factory":18,"./service-helpers/pick":20,"./service-helpers/stringify-booleans":21,"./service-helpers/validator":22,xtend:36}],18:[function(t,e,i){"use strict";var r=t("../../lib/classes/mapi-client"),n=t("../../lib/client");e.exports=function(t){return function(e){var i;i=r.prototype.isPrototypeOf(e)?e:n(e);var o=Object.create(t);return o.client=i,o}}},{"../../lib/classes/mapi-client":9,"../../lib/client":7}],19:[function(t,e,i){"use strict";e.exports=function(t,e){return Object.keys(t).reduce((function(i,r){return i[r]=e(r,t[r]),i}),{})}},{}],20:[function(t,e,i){"use strict";e.exports=function(t,e){var i=function(t,i){return-1!==e.indexOf(t)&&void 0!==i};return"function"==typeof e&&(i=e),Object.keys(t).filter((function(e){return i(e,t[e])})).reduce((function(e,i){return e[i]=t[i],e}),{})}},{}],21:[function(t,e,i){"use strict";var r=t("./object-map");e.exports=function(t){return r(t,(function(t,e){return"boolean"==typeof e?JSON.stringify(e):e}))}},{"./object-map":19}],22:[function(t,e,i){(function(i){"use strict";var r=t("xtend"),n=t("@mapbox/fusspot");e.exports=r(n,{file:function(t){if("undefined"!=typeof window){if(t instanceof i.Blob||t instanceof i.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof t&&void 0===t.pipe)return"Filename or Readable stream"},date:function(t){if("boolean"==typeof t)return"date";try{var e=new Date(t);if(e.getTime&&isNaN(e.getTime()))return"date"}catch(t){return"date"}},coordinates:function(t){return n.tuple(n.number,n.number)(t)},assertShape:function(t,e){return n.assert(n.strictShape(t),e)}})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@mapbox/fusspot":5,xtend:36}],23:[function(t,e,i){"use strict";function r(t){try{return JSON.parse(o.decode(t))}catch(t){throw new Error("Invalid token")}}function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var o=t("base-64"),s={};e.exports=function(t){if(s[t])return s[t];var e=t.split("."),i=e[0],o=e[1];if(!o)throw new Error("Invalid token");var a=r(o),l={usage:i,user:a.u};return n(a,"a")&&(l.authorization=a.a),n(a,"exp")&&(l.expires=1e3*a.exp),n(a,"iat")&&(l.created=1e3*a.iat),n(a,"scopes")&&(l.scopes=a.scopes),n(a,"client")&&(l.client=a.client),n(a,"ll")&&(l.lastLogin=a.ll),n(a,"iu")&&(l.impersonator=a.iu),s[t]=l,l}},{"base-64":24}],24:[function(t,e,i){(function(t){!function(r){var n="object"==typeof i&&i,o="object"==typeof e&&e&&e.exports==n&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s||(r=s);var a=function(t){this.message=t};(a.prototype=new Error).name="InvalidCharacterError";var l=function(t){throw new a(t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,h={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var e,i,r,n,o=t.length%3,s="",a=-1,u=t.length-o;++a<u;)e=t.charCodeAt(a)<<16,i=t.charCodeAt(++a)<<8,r=t.charCodeAt(++a),s+=c.charAt((n=e+i+r)>>18&63)+c.charAt(n>>12&63)+c.charAt(n>>6&63)+c.charAt(63&n);return 2==o?(e=t.charCodeAt(a)<<8,i=t.charCodeAt(++a),s+=c.charAt((n=e+i)>>10)+c.charAt(n>>4&63)+c.charAt(n<<2&63)+"="):1==o&&(n=t.charCodeAt(a),s+=c.charAt(n>>2)+c.charAt(n<<4&63)+"=="),s},decode:function(t){var e=(t=String(t).replace(u,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var i,r,n=0,o="",s=-1;++s<e;)r=c.indexOf(t.charAt(s)),i=n%4?64*i+r:r,n++%4&&(o+=String.fromCharCode(255&i>>(-2*n&6)));return o},version:"0.1.0"};if(n&&!n.nodeType)if(o)o.exports=h;else for(var p in h)h.hasOwnProperty(p)&&(n[p]=h[p]);else r.base64=h}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(t,e,i){function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=h(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function n(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function o(t,e,i,r){var o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),s=t._events),a=s[e]):(s=t._events=h(null),t._eventsCount=0),a){if("function"==typeof a?a=s[e]=r?[i,a]:[a,i]:r?a.unshift(i):a.push(i),!a.warned&&(o=n(t))&&o>0&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[e]=i,++t._eventsCount;return t}function s(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function a(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=d.call(s,r);return n.listener=i,r.wrapFn=n,n}function l(t,e,i){var r=t._events;if(!r)return[];var n=r[e];return n?"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):u(n,n.length):[]}function c(t){var e=this._events;if(e){var i=e[t];if("function"==typeof i)return 1;if(i)return i.length}return 0}function u(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}var h=Object.create||function(t){var e=function(){};return e.prototype=t,new e},p=Object.keys||function(t){var e=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.push(i);return i},d=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0;var f,m=10;try{var _={};Object.defineProperty&&Object.defineProperty(_,"x",{value:0}),f=0===_.x}catch(t){f=!1}f?Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return m},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');m=t}}):r.defaultMaxListeners=m,r.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},r.prototype.getMaxListeners=function(){return n(this)},r.prototype.emit=function(t){var e,i,r,n,o,s,a="error"===t;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(i=s[t]))return!1;var c="function"==typeof i;switch(r=arguments.length){case 1:!function(t,e,i){if(e)t.call(i);else for(var r=t.length,n=u(t,r),o=0;o<r;++o)n[o].call(i)}(i,c,this);break;case 2:!function(t,e,i,r){if(e)t.call(i,r);else for(var n=t.length,o=u(t,n),s=0;s<n;++s)o[s].call(i,r)}(i,c,this,arguments[1]);break;case 3:!function(t,e,i,r,n){if(e)t.call(i,r,n);else for(var o=t.length,s=u(t,o),a=0;a<o;++a)s[a].call(i,r,n)}(i,c,this,arguments[1],arguments[2]);break;case 4:!function(t,e,i,r,n,o){if(e)t.call(i,r,n,o);else for(var s=t.length,a=u(t,s),l=0;l<s;++l)a[l].call(i,r,n,o)}(i,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(r-1),o=1;o<r;o++)n[o-1]=arguments[o];!function(t,e,i,r){if(e)t.apply(i,r);else for(var n=t.length,o=u(t,n),s=0;s<n;++s)o[s].apply(i,r)}(i,c,this,n)}return!0},r.prototype.addListener=function(t,e){return o(this,t,e,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(t,e){return o(this,t,e,!0)},r.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,a(this,t,e)),this},r.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,a(this,t,e)),this},r.prototype.removeListener=function(t,e){var i,r,n,o,s;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(i=r[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=h(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(var i=e,r=i+1,n=t.length;r<n;i+=1,r+=1)t[i]=t[r];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),r.removeListener&&this.emit("removeListener",t,s||e)}return this},r.prototype.removeAllListeners=function(t){var e,i,r;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=h(null),this._eventsCount=0):i[t]&&(0==--this._eventsCount?this._events=h(null):delete i[t]),this;if(0===arguments.length){var n,o=p(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=h(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},r.prototype.listeners=function(t){return l(this,t,!0)},r.prototype.rawListeners=function(t){return l(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):c.call(t,e)},r.prototype.listenerCount=c,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],26:[function(t,e,i){"use strict";function r(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function o(t,e,i,r,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new n(i,r||t,o),a=c?c+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],s]:t._events[a].push(s):(t._events[a]=s,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}var l=Object.prototype.hasOwnProperty,c="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(c=!1)),a.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)l.call(t,e)&&i.push(c?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=c?c+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,o=new Array(n);r<n;r++)o[r]=i[r].fn;return o},a.prototype.listenerCount=function(t){var e=c?c+t:t,i=this._events[e];return i?i.fn?1:i.length:0},a.prototype.emit=function(t,e,i,r,n,o){var s=c?c+t:t;if(!this._events[s])return!1;var a,l,u=this._events[s],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,i),!0;case 4:return u.fn.call(u.context,e,i,r),!0;case 5:return u.fn.call(u.context,e,i,r,n),!0;case 6:return u.fn.call(u.context,e,i,r,n,o),!0}for(l=1,a=new Array(h-1);l<h;l++)a[l-1]=arguments[l];u.fn.apply(u.context,a)}else{var p,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(t,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,e);break;case 3:u[l].fn.call(u[l].context,e,i);break;case 4:u[l].fn.call(u[l].context,e,i,r);break;default:if(!a)for(p=1,a=new Array(h-1);p<h;p++)a[p-1]=arguments[p];u[l].fn.apply(u[l].context,a)}}return!0},a.prototype.on=function(t,e,i){return o(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return o(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,i,r){var n=c?c+t:t;if(!this._events[n])return this;if(!e)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||r&&!o.once||i&&o.context!==i||s(this,n);else{for(var a=0,l=[],u=o.length;a<u;a++)(o[a].fn!==e||r&&!o[a].once||i&&o[a].context!==i)&&l.push(o[a]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=c?c+t:t,this._events[e]&&s(this,e)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=c,a.EventEmitter=a,void 0!==e&&(e.exports=a)},{}],27:[function(t,e,i){!function(){var t={};void 0!==i?e.exports=t:this.fuzzy=t,t.simpleFilter=function(e,i){return i.filter((function(i){return t.test(e,i)}))},t.test=function(e,i){return null!==t.match(e,i)},t.match=function(t,e,i){i=i||{};var r,n=0,o=[],s=e.length,a=0,l=0,c=i.pre||"",u=i.post||"",h=i.caseSensitive&&e||e.toLowerCase();t=i.caseSensitive&&t||t.toLowerCase();for(var p=0;p<s;p++)r=e[p],h[p]===t[n]?(r=c+r+u,n+=1,l+=1+l):l=0,a+=l,o[o.length]=r;return n===t.length?(a=h===t?1/0:a,{rendered:o.join(""),score:a}):null},t.filter=function(e,i,r){return i&&0!==i.length?"string"!=typeof e?i:(r=r||{},i.reduce((function(i,n,o,s){var a=n;r.extract&&(a=r.extract(n));var l=t.match(e,a,r);return null!=l&&(i[i.length]={string:l.rendered,score:l.score,index:o,original:n}),i}),[]).sort((function(t,e){return e.score-t.score||t.index-e.index}))):[]}}()},{}],28:[function(t,e,i){"use strict";var r=Object.prototype.toString;e.exports=function(t){var e;return"[object Object]"===r.call(t)&&(null===(e=Object.getPrototypeOf(t))||e===Object.getPrototypeOf({}))}},{}],29:[function(t,e,i){(function(t){function i(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function r(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&m.call(t)==s}(t))return o;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(a,"");var r=c.test(t);return r||u.test(t)?h(t.slice(2),r?2:8):l.test(t)?o:+t}var n="Expected a function",o=NaN,s="[object Symbol]",a=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,h=parseInt,p="object"==typeof t&&t&&t.Object===Object&&t,d="object"==typeof self&&self&&self.Object===Object&&self,f=p||d||Function("return this")(),m=Object.prototype.toString,_=Math.max,g=Math.min,y=function(){return f.Date.now()};e.exports=function(t,e,o){function s(e){var i=h,r=p;return h=p=void 0,x=e,f=t.apply(r,i)}function a(t){var i=t-v;return void 0===v||i>=e||i<0||w&&t-x>=d}function l(){var t=y();if(a(t))return c(t);m=setTimeout(l,function(t){var i=e-(t-v);return w?g(i,d-(t-x)):i}(t))}function c(t){return m=void 0,T&&h?s(t):(h=p=void 0,f)}function u(){var t=y(),i=a(t);if(h=arguments,p=this,v=t,i){if(void 0===m)return function(t){return x=t,m=setTimeout(l,e),b?s(t):f}(v);if(w)return m=setTimeout(l,e),s(v)}return void 0===m&&(m=setTimeout(l,e)),f}var h,p,d,f,m,v,x=0,b=!1,w=!1,T=!0;if("function"!=typeof t)throw new TypeError(n);return e=r(e)||0,i(o)&&(b=!!o.leading,d=(w="maxWait"in o)?_(r(o.maxWait)||0,e):d,T="trailing"in o?!!o.trailing:T),u.cancel=function(){void 0!==m&&clearTimeout(m),x=0,h=v=p=m=void 0},u.flush=function(){return void 0===m?f:c(y())},u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(t,e,i){(function(t){if("production"!==t.env.NODE_ENV&&("undefined"==typeof self||!self.crypto&&!self.msCrypto))throw new Error("Your browser does not have secure random generator. If you dont need unpredictable IDs, you can use nanoid/non-secure.");var i=self.crypto||self.msCrypto;e.exports=function(t){t=t||21;for(var e="",r=i.getRandomValues(new Uint8Array(t));0<t--;)e+="Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-"[63&r[t]];return e}}).call(this,t("_process"))},{_process:31}],31:[function(t,e,i){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(t){if(u===setTimeout)return setTimeout(t,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function s(){m&&d&&(m=!1,d.length?f=d.concat(f):_=-1,f.length&&a())}function a(){if(!m){var t=o(s);m=!0;for(var e=f.length;e;){for(d=f,f=[];++_<e;)d&&d[_].run();_=-1,e=f.length}d=null,m=!1,function(t){if(h===clearTimeout)return clearTimeout(t);if((h===n||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(t);try{return h(t)}catch(e){try{return h.call(null,t)}catch(e){return h.call(this,t)}}}(t)}}function l(t,e){this.fun=t,this.array=e}function c(){}var u,h,p=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:r}catch(t){u=r}try{h="function"==typeof clearTimeout?clearTimeout:n}catch(t){h=n}}();var d,f=[],m=!1,_=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];f.push(new l(t,e)),1!==f.length||m||o(a)},l.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=c,p.addListener=c,p.once=c,p.off=c,p.removeListener=c,p.removeAllListeners=c,p.emit=c,p.prependListener=c,p.prependOnceListener=c,p.listeners=function(t){return[]},p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},{}],32:[function(t,e,i){!function(t,i,r){void 0!==e&&e.exports?e.exports=r():t.subtag=r()}(this,0,(function(){function t(t){return t.match(o)||[]}function e(e){return{language:(e=t(e))[1]||n,extlang:e[2]||n,script:e[3]||n,region:e[4]||n}}function i(t,e,i){Object.defineProperty(t,e,{value:i,enumerable:!0})}function r(r,o,s){function a(e){return t(e)[r]||n}i(a,"pattern",o),i(e,s,a)}var n="",o=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;return r(1,/^[a-zA-Z]{2,3}$/,"language"),r(2,/^[a-zA-Z]{3}$/,"extlang"),r(3,/^[a-zA-Z]{4}$/,"script"),r(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),i(e,"split",(function(e){return t(e).filter((function(t,e){return t&&e}))})),e}))},{}],33:[function(t,e,i){"use strict";var r=t("./src/suggestions");window.Suggestions=e.exports=r},{"./src/suggestions":35}],34:[function(t,e,i){var r=function(t){return this.component=t,this.items=[],this.active=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,t.el.parentNode.insertBefore(this.wrapper,t.el.nextSibling),this};r.prototype.show=function(){this.element.style.display="block"},r.prototype.hide=function(){this.element.style.display="none"},r.prototype.add=function(t){this.items.push(t)},r.prototype.clear=function(){this.items=[],this.active=0},r.prototype.isEmpty=function(){return!this.items.length},r.prototype.isVisible=function(){return"block"===this.element.style.display},r.prototype.draw=function(){if(this.element.innerHTML="",0!==this.items.length){for(var t=0;t<this.items.length;t++)this.drawItem(this.items[t],this.active===t);this.show()}else this.hide()},r.prototype.drawItem=function(t,e){var i=document.createElement("li"),r=document.createElement("a");e&&(i.className+=" active"),r.innerHTML=t.string,i.appendChild(r),this.element.appendChild(i),i.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),i.addEventListener("mouseup",function(){this.handleMouseUp.call(this,t)}.bind(this))},r.prototype.handleMouseUp=function(t){this.selectingListItem=!1,this.component.value(t.original),this.clear(),this.draw()},r.prototype.move=function(t){this.active=t,this.draw()},r.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)},r.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)},r.prototype.drawError=function(t){var e=document.createElement("li");e.innerHTML=t,this.element.appendChild(e),this.show()},e.exports=r},{}],35:[function(t,e,i){"use strict";var r=t("xtend"),n=t("fuzzy"),o=t("./list"),s=function(t,e,i){return i=i||{},this.options=r({minLength:2,limit:5,filter:!0},i),this.el=t,this.data=e||[],this.list=new o(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(t){this.handleKeyUp(t.keyCode)}.bind(this),!1),this.el.addEventListener("keydown",function(t){this.handleKeyDown(t)}.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(t){this.handlePaste(t)}.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};s.prototype.handleKeyUp=function(t){40!==t&&38!==t&&27!==t&&13!==t&&9!==t&&this.handleInputChange(this.el.value)},s.prototype.handleKeyDown=function(t){switch(t.keyCode){case 13:case 9:this.list.isEmpty()||(this.list.isVisible()&&t.preventDefault(),this.value(this.list.items[this.list.active].original),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}},s.prototype.handleBlur=function(){this.list.selectingListItem||this.list.hide()},s.prototype.handlePaste=function(t){if(t.clipboardData)this.handleInputChange(t.clipboardData.getData("Text"));else{var e=this;setTimeout((function(){e.handleInputChange(t.target.value)}),100)}},s.prototype.handleInputChange=function(t){this.query=this.normalize(t),this.list.clear(),this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(t){for(var e=0;e<t.length&&(this.list.add(t[e]),e!==this.options.limit-1);e++);this.list.draw()}.bind(this))},s.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show(),this.list.selectingListItem=!1},s.prototype.update=function(t){this.data=t,this.handleKeyUp()},s.prototype.clear=function(){this.data=[],this.list.clear()},s.prototype.normalize=function(t){return t.toLowerCase()},s.prototype.match=function(t,e){return t.indexOf(e)>-1},s.prototype.value=function(t){if(this.selected=t,this.el.value=this.getItemValue(t),document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.el.dispatchEvent(e)}else this.el.fireEvent("onchange")},s.prototype.getCandidates=function(t){var e,i={pre:"<strong>",post:"</strong>",extract:function(t){return this.getItemValue(t)}.bind(this)};this.options.filter?e=(e=n.filter(this.query,this.data,i)).map(function(t){return{original:t.original,string:this.render(t.original,t.string)}}.bind(this)):e=this.data.map(function(t){return{original:t,string:this.render(t)}}.bind(this)),t(e)},s.prototype.getItemValue=function(t){return t},s.prototype.render=function(t,e){if(e)return e;for(var i=t.original?this.getItemValue(t.original):this.getItemValue(t),r=this.normalize(i),n=r.lastIndexOf(this.query);n>-1;){var o=n+this.query.length;i=i.slice(0,n)+"<strong>"+i.slice(n,o)+"</strong>"+i.slice(o),n=r.slice(0,n).lastIndexOf(this.query)}return i},s.prototype.renderError=function(t){this.list.drawError(t)},e.exports=s},{"./list":34,fuzzy:27,xtend:36}],36:[function(t,e,i){e.exports=function(){for(var t={},e=0;e<arguments.length;e++){var i=arguments[e];for(var n in i)r.call(i,n)&&(t[n]=i[n])}return t};var r=Object.prototype.hasOwnProperty},{}]},{},[3])(3)}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";var t=Object.freeze({__proto__:null,get Colors(){return ko},get Decimation(){return Po},get Filler(){return Wo},get Legend(){return Jo},get SubTitle(){return is},get Title(){return ts},get Tooltip(){return gs}});function e(){}const i=(()=>{let t=0;return()=>t++})();function r(t){return null==t}function n(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function o(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function s(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function a(t,e){return s(t)?t:e}function l(t,e){return void 0===t?e:t}const c=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,u=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function h(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function p(t,e,i,r){let s,a,l;if(n(t))if(a=t.length,r)for(s=a-1;s>=0;s--)e.call(i,t[s],s);else for(s=0;s<a;s++)e.call(i,t[s],s);else if(o(t))for(l=Object.keys(t),a=l.length,s=0;s<a;s++)e.call(i,t[l[s]],l[s])}function d(t,e){let i,r,n,o;if(!t||!e||t.length!==e.length)return!1;for(i=0,r=t.length;i<r;++i)if(n=t[i],o=e[i],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function f(t){if(n(t))return t.map(f);if(o(t)){const e=Object.create(null),i=Object.keys(t),r=i.length;let n=0;for(;n<r;++n)e[i[n]]=f(t[i[n]]);return e}return t}function m(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function _(t,e,i,r){if(!m(t))return;const n=e[t],s=i[t];o(n)&&o(s)?g(n,s,r):e[t]=f(s)}function g(t,e,i){const r=n(e)?e:[e],s=r.length;if(!o(t))return t;const a=(i=i||{}).merger||_;let l;for(let e=0;e<s;++e){if(l=r[e],!o(l))continue;const n=Object.keys(l);for(let e=0,r=n.length;e<r;++e)a(n[e],t,l,i)}return t}function y(t,e){return g(t,e,{merger:v})}function v(t,e,i){if(!m(t))return;const r=e[t],n=i[t];o(r)&&o(n)?y(r,n):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=f(n))}const x={"":t=>t,x:t=>t.x,y:t=>t.y};function b(t){const e=t.split("."),i=[];let r="";for(const t of e)r+=t,r.endsWith("\\")?r=r.slice(0,-1)+".":(i.push(r),r="");return i}function w(t,e){const i=x[e]||(x[e]=function(t){const e=b(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}(e));return i(t)}function T(t){return t.charAt(0).toUpperCase()+t.slice(1)}const M=t=>void 0!==t,E=t=>"function"==typeof t,C=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function S(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const k=Math.PI,A=2*k,I=A+k,P=Number.POSITIVE_INFINITY,L=k/180,z=k/2,D=k/4,R=2*k/3,O=Math.log10,F=Math.sign;function B(t,e,i){return Math.abs(t-e)<i}function j(t){const e=Math.round(t);t=B(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(O(t))),r=t/i;return(r<=1?1:r<=2?2:r<=5?5:10)*i}function N(t){const e=[],i=Math.sqrt(t);let r;for(r=1;r<i;r++)t%r==0&&(e.push(r),e.push(t/r));return i===(0|i)&&e.push(i),e.sort(((t,e)=>t-e)).pop(),e}function V(t){return!isNaN(parseFloat(t))&&isFinite(t)}function U(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function $(t,e,i){let r,n,o;for(r=0,n=t.length;r<n;r++)o=t[r][i],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function G(t){return t*(k/180)}function q(t){return t*(180/k)}function Z(t){if(!s(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function H(t,e){const i=e.x-t.x,r=e.y-t.y,n=Math.sqrt(i*i+r*r);let o=Math.atan2(r,i);return o<-.5*k&&(o+=A),{angle:o,distance:n}}function W(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function X(t,e){return(t-e+I)%A-k}function Q(t){return(t%A+A)%A}function Y(t,e,i,r){const n=Q(t),o=Q(e),s=Q(i),a=Q(o-n),l=Q(s-n),c=Q(n-o),u=Q(n-s);return n===o||n===s||r&&o===s||a>l&&c<u}function J(t,e,i){return Math.max(e,Math.min(i,t))}function K(t){return J(t,-32768,32767)}function tt(t,e,i,r=1e-6){return t>=Math.min(e,i)-r&&t<=Math.max(e,i)+r}function et(t,e,i){i=i||(i=>t[i]<e);let r,n=t.length-1,o=0;for(;n-o>1;)r=o+n>>1,i(r)?o=r:n=r;return{lo:o,hi:n}}const it=(t,e,i,r)=>et(t,i,r?r=>{const n=t[r][e];return n<i||n===i&&t[r+1][e]===i}:r=>t[r][e]<i),rt=(t,e,i)=>et(t,i,(r=>t[r][e]>=i));function nt(t,e,i){let r=0,n=t.length;for(;r<n&&t[r]<e;)r++;for(;n>r&&t[n-1]>i;)n--;return r>0||n<t.length?t.slice(r,n):t}const ot=["push","pop","shift","splice","unshift"];function st(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),ot.forEach((e=>{const i="_onData"+T(e),r=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=r.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function at(t,e){const i=t._chartjs;if(!i)return;const r=i.listeners,n=r.indexOf(e);-1!==n&&r.splice(n,1),r.length>0||(ot.forEach((e=>{delete t[e]})),delete t._chartjs)}function lt(t){const e=new Set;let i,r;for(i=0,r=t.length;i<r;++i)e.add(t[i]);return e.size===r?t:Array.from(e)}const ct="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function ut(t,e){let i=[],r=!1;return function(...n){i=n,r||(r=!0,ct.call(window,(()=>{r=!1,t.apply(e,i)})))}}function ht(t,e){let i;return function(...r){return e?(clearTimeout(i),i=setTimeout(t,e,r)):t.apply(this,r),e}}const pt=t=>"start"===t?"left":"end"===t?"right":"center",dt=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,ft=(t,e,i,r)=>t===(r?"left":"right")?i:"center"===t?(e+i)/2:e;function mt(t,e,i){const r=e.length;let n=0,o=r;if(t._sorted){const{iScale:s,_parsed:a}=t,l=s.axis,{min:c,max:u,minDefined:h,maxDefined:p}=s.getUserBounds();h&&(n=J(Math.min(it(a,s.axis,c).lo,i?r:it(e,l,s.getPixelForValue(c)).lo),0,r-1)),o=p?J(Math.max(it(a,s.axis,u,!0).hi+1,i?0:it(e,l,s.getPixelForValue(u),!0).hi+1),n,r)-n:r-n}return{start:n,count:o}}function _t(t){const{xScale:e,yScale:i,_scaleRanges:r}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!r)return t._scaleRanges=n,!0;const o=r.xmin!==e.min||r.xmax!==e.max||r.ymin!==i.min||r.ymax!==i.max;return Object.assign(r,n),o}var gt=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,r){const n=e.listeners[r],o=e.duration;n.forEach((r=>r({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=ct.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((i,r)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,s=n.length-1,a=!1;for(;s>=0;--s)o=n[s],o._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),a=!0):(n[s]=n[n.length-1],n.pop());a&&(r.draw(),this._notify(r,i,t,"progress")),n.length||(i.running=!1,this._notify(r,i,t,"complete"),i.initial=!1),e+=n.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let r=i.length-1;for(;r>=0;--r)i[r].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};function yt(t){return t+.5|0}const vt=(t,e,i)=>Math.max(Math.min(t,i),e);function xt(t){return vt(yt(2.55*t),0,255)}function bt(t){return vt(yt(255*t),0,255)}function wt(t){return vt(yt(t/2.55)/100,0,1)}function Tt(t){return vt(yt(100*t),0,100)}const Mt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Et=[..."0123456789ABCDEF"],Ct=t=>Et[15&t],St=t=>Et[(240&t)>>4]+Et[15&t],kt=t=>(240&t)>>4==(15&t);const At=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function It(t,e,i){const r=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-r*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function Pt(t,e,i){const r=(r,n=(r+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[r(5),r(3),r(1)]}function Lt(t,e,i){const r=It(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)r[n]*=1-e-i,r[n]+=e;return r}function zt(t){const e=t.r/255,i=t.g/255,r=t.b/255,n=Math.max(e,i,r),o=Math.min(e,i,r),s=(n+o)/2;let a,l,c;return n!==o&&(c=n-o,l=s>.5?c/(2-n-o):c/(n+o),a=function(t,e,i,r,n){return t===n?(e-i)/r+(e<i?6:0):e===n?(i-t)/r+2:(t-e)/r+4}(e,i,r,c,n),a=60*a+.5),[0|a,l||0,s]}function Dt(t,e,i,r){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,i,r)).map(bt)}function Rt(t,e,i){return Dt(It,t,e,i)}function Ot(t){return(t%360+360)%360}const Ft={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Bt={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};let jt;const Nt=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,Vt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,Ut=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function $t(t,e,i){if(t){let r=zt(t);r[e]=Math.max(0,Math.min(r[e]+r[e]*i,0===e?360:1)),r=Rt(r),t.r=r[0],t.g=r[1],t.b=r[2]}}function Gt(t,e){return t?Object.assign(e||{},t):t}function qt(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=bt(t[3]))):(e=Gt(t,{r:0,g:0,b:0,a:1})).a=bt(e.a),e}function Zt(t){return"r"===t.charAt(0)?function(t){const e=Nt.exec(t);let i,r,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=e[8]?xt(t):vt(255*t,0,255)}return i=+e[1],r=+e[3],n=+e[5],i=255&(e[2]?xt(i):vt(i,0,255)),r=255&(e[4]?xt(r):vt(r,0,255)),n=255&(e[6]?xt(n):vt(n,0,255)),{r:i,g:r,b:n,a:o}}}(t):function(t){const e=At.exec(t);let i,r=255;if(!e)return;e[5]!==i&&(r=e[6]?xt(+e[5]):bt(+e[5]));const n=Ot(+e[2]),o=+e[3]/100,s=+e[4]/100;return i="hwb"===e[1]?function(t,e,i){return Dt(Lt,t,e,i)}(n,o,s):"hsv"===e[1]?function(t,e,i){return Dt(Pt,t,e,i)}(n,o,s):Rt(n,o,s),{r:i[0],g:i[1],b:i[2],a:r}}(t)}class Ht{constructor(t){if(t instanceof Ht)return t;const e=typeof t;let i;var r,n,o;"object"===e?i=qt(t):"string"===e&&(o=(r=t).length,"#"===r[0]&&(4===o||5===o?n={r:255&17*Mt[r[1]],g:255&17*Mt[r[2]],b:255&17*Mt[r[3]],a:5===o?17*Mt[r[4]]:255}:7!==o&&9!==o||(n={r:Mt[r[1]]<<4|Mt[r[2]],g:Mt[r[3]]<<4|Mt[r[4]],b:Mt[r[5]]<<4|Mt[r[6]],a:9===o?Mt[r[7]]<<4|Mt[r[8]]:255})),i=n||function(t){jt||(jt=function(){const t={},e=Object.keys(Bt),i=Object.keys(Ft);let r,n,o,s,a;for(r=0;r<e.length;r++){for(s=a=e[r],n=0;n<i.length;n++)o=i[n],a=a.replace(o,Ft[o]);o=parseInt(Bt[s],16),t[a]=[o>>16&255,o>>8&255,255&o]}return t}(),jt.transparent=[0,0,0,0]);const e=jt[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}(t)||Zt(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Gt(this._rgb);return t&&(t.a=wt(t.a)),t}set rgb(t){this._rgb=qt(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${wt(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?function(t){var e=(t=>kt(t.r)&&kt(t.g)&&kt(t.b)&&kt(t.a))(t)?Ct:St;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;const e=zt(t),i=e[0],r=Tt(e[1]),n=Tt(e[2]);return t.a<255?`hsla(${i}, ${r}%, ${n}%, ${wt(t.a)})`:`hsl(${i}, ${r}%, ${n}%)`}(this._rgb):void 0}mix(t,e){if(t){const i=this.rgb,r=t.rgb;let n;const o=e===n?.5:e,s=2*o-1,a=i.a-r.a,l=((s*a==-1?s:(s+a)/(1+s*a))+1)/2;n=1-l,i.r=255&l*i.r+n*r.r+.5,i.g=255&l*i.g+n*r.g+.5,i.b=255&l*i.b+n*r.b+.5,i.a=o*i.a+(1-o)*r.a,this.rgb=i}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,i){const r=Ut(wt(t.r)),n=Ut(wt(t.g)),o=Ut(wt(t.b));return{r:bt(Vt(r+i*(Ut(wt(e.r))-r))),g:bt(Vt(n+i*(Ut(wt(e.g))-n))),b:bt(Vt(o+i*(Ut(wt(e.b))-o))),a:t.a+i*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new Ht(this.rgb)}alpha(t){return this._rgb.a=bt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=yt(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return $t(this._rgb,2,t),this}darken(t){return $t(this._rgb,2,-t),this}saturate(t){return $t(this._rgb,1,t),this}desaturate(t){return $t(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=zt(t);i[0]=Ot(i[0]+e),i=Rt(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function Wt(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Xt(t){return Wt(t)?t:new Ht(t)}function Qt(t){return Wt(t)?t:new Ht(t).saturate(.5).darken(.1).hexString()}const Yt=["x","y","borderWidth","radius","tension"],Jt=["color","borderColor","backgroundColor"],Kt=new Map;function te(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let r=Kt.get(i);return r||(r=new Intl.NumberFormat(t,e),Kt.set(i,r)),r}(e,i).format(t)}const ee={values:t=>n(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const r=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const s=O(Math.abs(o)),a=Math.max(Math.min(-1*Math.floor(s),20),0),l={notation:n,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),te(t,r,l)},logarithmic(t,e,i){if(0===t)return"0";const r=i[e].significand||t/Math.pow(10,Math.floor(O(t)));return[1,2,3,5,10,15].includes(r)||e>.8*i.length?ee.numeric.call(this,t,e,i):""}};var ie={formatters:ee};const re=Object.create(null),ne=Object.create(null);function oe(t,e){if(!e)return t;const i=e.split(".");for(let e=0,r=i.length;e<r;++e){const r=i[e];t=t[r]||(t[r]=Object.create(null))}return t}function se(t,e,i){return"string"==typeof e?g(oe(t,e),i):g(oe(t,""),e)}var ae=new class{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=t=>t.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>Qt(e.backgroundColor),this.hoverBorderColor=(t,e)=>Qt(e.borderColor),this.hoverColor=(t,e)=>Qt(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return se(this,t,e)}get(t){return oe(this,t)}describe(t,e){return se(ne,t,e)}override(t,e){return se(re,t,e)}route(t,e,i,r){const n=oe(this,t),s=oe(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=s[r];return o(t)?Object.assign({},e,t):l(t,e)},set(t){this[a]=t}}})}apply(t){t.forEach((t=>t(this)))}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:Jt},numbers:{type:"number",properties:Yt}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:ie.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}]);function le(){return"undefined"!=typeof window&&"undefined"!=typeof document}function ce(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function ue(t,e,i){let r;return"string"==typeof t?(r=parseInt(t,10),-1!==t.indexOf("%")&&(r=r/100*e.parentNode[i])):r=t,r}const he=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);function pe(t,e){return he(t).getPropertyValue(e)}const de=["top","right","bottom","left"];function fe(t,e,i){const r={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=de[n];r[o]=parseFloat(t[e+"-"+o+i])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}function me(t,e){if("native"in t)return t;const{canvas:i,currentDevicePixelRatio:r}=e,n=he(i),o="border-box"===n.boxSizing,s=fe(n,"padding"),a=fe(n,"border","width"),{x:l,y:c,box:u}=function(t,e){const i=t.touches,r=i&&i.length?i[0]:t,{offsetX:n,offsetY:o}=r;let s,a,l=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(n,o,t.target))s=n,a=o;else{const t=e.getBoundingClientRect();s=r.clientX-t.left,a=r.clientY-t.top,l=!0}return{x:s,y:a,box:l}}(t,i),h=s.left+(u&&a.left),p=s.top+(u&&a.top);let{width:d,height:f}=e;return o&&(d-=s.width+a.width,f-=s.height+a.height),{x:Math.round((l-h)/d*i.width/r),y:Math.round((c-p)/f*i.height/r)}}const _e=t=>Math.round(10*t)/10;function ge(t,e,i,r){const n=he(t),o=fe(n,"margin"),s=ue(n.maxWidth,t,"clientWidth")||P,a=ue(n.maxHeight,t,"clientHeight")||P,l=function(t,e,i){let r,n;if(void 0===e||void 0===i){const o=ce(t);if(o){const t=o.getBoundingClientRect(),s=he(o),a=fe(s,"border","width"),l=fe(s,"padding");e=t.width-l.width-a.width,i=t.height-l.height-a.height,r=ue(s.maxWidth,o,"clientWidth"),n=ue(s.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:r||P,maxHeight:n||P}}(t,e,i);let{width:c,height:u}=l;if("content-box"===n.boxSizing){const t=fe(n,"border","width"),e=fe(n,"padding");c-=e.width+t.width,u-=e.height+t.height}c=Math.max(0,c-o.width),u=Math.max(0,r?c/r:u-o.height),c=_e(Math.min(c,s,l.maxWidth)),u=_e(Math.min(u,a,l.maxHeight)),c&&!u&&(u=_e(c/2));return(void 0!==e||void 0!==i)&&r&&l.height&&u>l.height&&(u=l.height,c=_e(Math.floor(u*r))),{width:c,height:u}}function ye(t,e,i){const r=e||1,n=Math.floor(t.height*r),o=Math.floor(t.width*r);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const s=t.canvas;return s.style&&(i||!s.style.height&&!s.style.width)&&(s.style.height=`${t.height}px`,s.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==r||s.height!==n||s.width!==o)&&(t.currentDevicePixelRatio=r,s.height=n,s.width=o,t.ctx.setTransform(r,0,0,r,0,0),!0)}const ve=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function xe(t,e){const i=pe(t,e),r=i&&i.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function be(t){return!t||r(t.size)||r(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function we(t,e,i,r,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>r&&(r=o),r}function Te(t,e,i,r){let o=(r=r||{}).data=r.data||{},s=r.garbageCollect=r.garbageCollect||[];r.font!==e&&(o=r.data={},s=r.garbageCollect=[],r.font=e),t.save(),t.font=e;let a=0;const l=i.length;let c,u,h,p,d;for(c=0;c<l;c++)if(p=i[c],null!=p&&!0!==n(p))a=we(t,o,s,a,p);else if(n(p))for(u=0,h=p.length;u<h;u++)d=p[u],null==d||n(d)||(a=we(t,o,s,a,d));t.restore();const f=s.length/2;if(f>i.length){for(c=0;c<f;c++)delete o[s[c]];s.splice(0,f)}return a}function Me(t,e,i){const r=t.currentDevicePixelRatio,n=0!==i?Math.max(i/2,.5):0;return Math.round((e-n)*r)/r+n}function Ee(t,e){(e=e||t.getContext("2d")).save(),e.resetTransform(),e.clearRect(0,0,t.width,t.height),e.restore()}function Ce(t,e,i,r){Se(t,e,i,r,null)}function Se(t,e,i,r,n){let o,s,a,l,c,u,h,p;const d=e.pointStyle,f=e.rotation,m=e.radius;let _=(f||0)*L;if(d&&"object"==typeof d&&(o=d.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return t.save(),t.translate(i,r),t.rotate(_),t.drawImage(d,-d.width/2,-d.height/2,d.width,d.height),void t.restore();if(!(isNaN(m)||m<=0)){switch(t.beginPath(),d){default:n?t.ellipse(i,r,n/2,m,0,0,A):t.arc(i,r,m,0,A),t.closePath();break;case"triangle":u=n?n/2:m,t.moveTo(i+Math.sin(_)*u,r-Math.cos(_)*m),_+=R,t.lineTo(i+Math.sin(_)*u,r-Math.cos(_)*m),_+=R,t.lineTo(i+Math.sin(_)*u,r-Math.cos(_)*m),t.closePath();break;case"rectRounded":c=.516*m,l=m-c,s=Math.cos(_+D)*l,h=Math.cos(_+D)*(n?n/2-c:l),a=Math.sin(_+D)*l,p=Math.sin(_+D)*(n?n/2-c:l),t.arc(i-h,r-a,c,_-k,_-z),t.arc(i+p,r-s,c,_-z,_),t.arc(i+h,r+a,c,_,_+z),t.arc(i-p,r+s,c,_+z,_+k),t.closePath();break;case"rect":if(!f){l=Math.SQRT1_2*m,u=n?n/2:l,t.rect(i-u,r-l,2*u,2*l);break}_+=D;case"rectRot":h=Math.cos(_)*(n?n/2:m),s=Math.cos(_)*m,a=Math.sin(_)*m,p=Math.sin(_)*(n?n/2:m),t.moveTo(i-h,r-a),t.lineTo(i+p,r-s),t.lineTo(i+h,r+a),t.lineTo(i-p,r+s),t.closePath();break;case"crossRot":_+=D;case"cross":h=Math.cos(_)*(n?n/2:m),s=Math.cos(_)*m,a=Math.sin(_)*m,p=Math.sin(_)*(n?n/2:m),t.moveTo(i-h,r-a),t.lineTo(i+h,r+a),t.moveTo(i+p,r-s),t.lineTo(i-p,r+s);break;case"star":h=Math.cos(_)*(n?n/2:m),s=Math.cos(_)*m,a=Math.sin(_)*m,p=Math.sin(_)*(n?n/2:m),t.moveTo(i-h,r-a),t.lineTo(i+h,r+a),t.moveTo(i+p,r-s),t.lineTo(i-p,r+s),_+=D,h=Math.cos(_)*(n?n/2:m),s=Math.cos(_)*m,a=Math.sin(_)*m,p=Math.sin(_)*(n?n/2:m),t.moveTo(i-h,r-a),t.lineTo(i+h,r+a),t.moveTo(i+p,r-s),t.lineTo(i-p,r+s);break;case"line":s=n?n/2:Math.cos(_)*m,a=Math.sin(_)*m,t.moveTo(i-s,r-a),t.lineTo(i+s,r+a);break;case"dash":t.moveTo(i,r),t.lineTo(i+Math.cos(_)*(n?n/2:m),r+Math.sin(_)*m);break;case!1:t.closePath()}t.fill(),e.borderWidth>0&&t.stroke()}}function ke(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.x<e.right+i&&t.y>e.top-i&&t.y<e.bottom+i}function Ae(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()}function Ie(t){t.restore()}function Pe(t,e,i,r,n){if(!e)return t.lineTo(i.x,i.y);if("middle"===n){const r=(e.x+i.x)/2;t.lineTo(r,e.y),t.lineTo(r,i.y)}else"after"===n!=!!r?t.lineTo(e.x,i.y):t.lineTo(i.x,e.y);t.lineTo(i.x,i.y)}function Le(t,e,i,r){if(!e)return t.lineTo(i.x,i.y);t.bezierCurveTo(r?e.cp1x:e.cp2x,r?e.cp1y:e.cp2y,r?i.cp2x:i.cp1x,r?i.cp2y:i.cp1y,i.x,i.y)}function ze(t,e,i,o,s,a={}){const l=n(e)?e:[e],c=a.strokeWidth>0&&""!==a.strokeColor;let u,h;for(t.save(),t.font=s.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);r(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,a),u=0;u<l.length;++u)h=l[u],a.backdrop&&Re(t,a.backdrop),c&&(a.strokeColor&&(t.strokeStyle=a.strokeColor),r(a.strokeWidth)||(t.lineWidth=a.strokeWidth),t.strokeText(h,i,o,a.maxWidth)),t.fillText(h,i,o,a.maxWidth),De(t,i,o,h,a),o+=s.lineHeight;t.restore()}function De(t,e,i,r,n){if(n.strikethrough||n.underline){const o=t.measureText(r),s=e-o.actualBoundingBoxLeft,a=e+o.actualBoundingBoxRight,l=i-o.actualBoundingBoxAscent,c=i+o.actualBoundingBoxDescent,u=n.strikethrough?(l+c)/2:c;t.strokeStyle=t.fillStyle,t.beginPath(),t.lineWidth=n.decorationWidth||2,t.moveTo(s,u),t.lineTo(a,u),t.stroke()}}function Re(t,e){const i=t.fillStyle;t.fillStyle=e.color,t.fillRect(e.left,e.top,e.width,e.height),t.fillStyle=i}function Oe(t,e){const{x:i,y:r,w:n,h:o,radius:s}=e;t.arc(i+s.topLeft,r+s.topLeft,s.topLeft,-z,k,!0),t.lineTo(i,r+o-s.bottomLeft),t.arc(i+s.bottomLeft,r+o-s.bottomLeft,s.bottomLeft,k,z,!0),t.lineTo(i+n-s.bottomRight,r+o),t.arc(i+n-s.bottomRight,r+o-s.bottomRight,s.bottomRight,z,0,!0),t.lineTo(i+n,r+s.topRight),t.arc(i+n-s.topRight,r+s.topRight,s.topRight,0,-z,!0),t.lineTo(i+s.topLeft,r)}function Fe(t,e=[""],i=t,r,n=(()=>t[0])){M(r)||(r=We("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:r,_getTarget:n,override:n=>Fe([n,...t],e,i,r)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,r)=>Ue(i,r,(()=>function(t,e,i,r){let n;for(const o of e)if(n=We(Ne(o,t),i),M(n))return Ve(t,n)?Ze(i,r,t,n):n}(r,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>Xe(t).includes(e),ownKeys:t=>Xe(t),set(t,e,i){const r=t._storage||(t._storage=n());return t[e]=r[e]=i,delete t._keys,!0}})}function Be(t,e,i,r){const s={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:je(t,r),setContext:e=>Be(t,e,i,r),override:n=>Be(t.override(n),e,i,r)};return new Proxy(s,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>Ue(t,e,(()=>function(t,e,i){const{_proxy:r,_context:s,_subProxy:a,_descriptors:l}=t;let c=r[e];E(c)&&l.isScriptable(e)&&(c=function(t,e,i,r){const{_proxy:n,_context:o,_subProxy:s,_stack:a}=i;if(a.has(t))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+t);a.add(t),e=e(o,s||r),a.delete(t),Ve(t,e)&&(e=Ze(n._scopes,n,t,e));return e}(e,c,t,i));n(c)&&c.length&&(c=function(t,e,i,r){const{_proxy:n,_context:s,_subProxy:a,_descriptors:l}=i;if(M(s.index)&&r(t))e=e[s.index%e.length];else if(o(e[0])){const i=e,r=n._scopes.filter((t=>t!==i));e=[];for(const o of i){const i=Ze(r,n,t,o);e.push(Be(i,s,a&&a[t],l))}}return e}(e,c,t,l.isIndexable));Ve(e,c)&&(c=Be(c,s,a&&a[e],l));return c}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,r)=>(t[i]=r,delete e[i],!0)})}function je(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:r=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:r,isScriptable:E(i)?i:()=>i,isIndexable:E(r)?r:()=>r}}const Ne=(t,e)=>t?t+T(e):e,Ve=(t,e)=>o(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function Ue(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const r=i();return t[e]=r,r}function $e(t,e,i){return E(t)?t(e,i):t}const Ge=(t,e)=>!0===t?e:"string"==typeof t?w(e,t):void 0;function qe(t,e,i,r,n){for(const o of e){const e=Ge(i,o);if(e){t.add(e);const o=$e(e._fallback,i,n);if(M(o)&&o!==i&&o!==r)return o}else if(!1===e&&M(r)&&i!==r)return null}return!1}function Ze(t,e,i,r){const s=e._rootScopes,a=$e(e._fallback,i,r),l=[...t,...s],c=new Set;c.add(r);let u=He(c,l,i,a||i,r);return null!==u&&(!M(a)||a===i||(u=He(c,l,a,u,r),null!==u))&&Fe(Array.from(c),[""],s,a,(()=>function(t,e,i){const r=t._getTarget();e in r||(r[e]={});const s=r[e];return n(s)&&o(i)?i:s||{}}(e,i,r)))}function He(t,e,i,r,n){for(;i;)i=qe(t,e,i,r,n);return i}function We(t,e){for(const i of e){if(!i)continue;const e=i[t];if(M(e))return e}}function Xe(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function Qe(t,e,i,r){const{iScale:n}=t,{key:o="r"}=this._parsing,s=new Array(r);let a,l,c,u;for(a=0,l=r;a<l;++a)c=a+i,u=e[c],s[a]={r:n.parse(w(u,o),c)};return s}const Ye=Number.EPSILON||1e-14,Je=(t,e)=>e<t.length&&!t[e].skip&&t[e],Ke=t=>"x"===t?"y":"x";function ti(t,e,i,r){const n=t.skip?e:t,o=e,s=i.skip?e:i,a=W(o,n),l=W(s,o);let c=a/(a+l),u=l/(a+l);c=isNaN(c)?0:c,u=isNaN(u)?0:u;const h=r*c,p=r*u;return{previous:{x:o.x-h*(s.x-n.x),y:o.y-h*(s.y-n.y)},next:{x:o.x+p*(s.x-n.x),y:o.y+p*(s.y-n.y)}}}function ei(t,e="x"){const i=Ke(e),r=t.length,n=Array(r).fill(0),o=Array(r);let s,a,l,c=Je(t,0);for(s=0;s<r;++s)if(a=l,l=c,c=Je(t,s+1),l){if(c){const t=c[e]-l[e];n[s]=0!==t?(c[i]-l[i])/t:0}o[s]=a?c?F(n[s-1])!==F(n[s])?0:(n[s-1]+n[s])/2:n[s-1]:n[s]}!function(t,e,i){const r=t.length;let n,o,s,a,l,c=Je(t,0);for(let u=0;u<r-1;++u)l=c,c=Je(t,u+1),l&&c&&(B(e[u],0,Ye)?i[u]=i[u+1]=0:(n=i[u]/e[u],o=i[u+1]/e[u],a=Math.pow(n,2)+Math.pow(o,2),a<=9||(s=3/Math.sqrt(a),i[u]=n*s*e[u],i[u+1]=o*s*e[u])))}(t,n,o),function(t,e,i="x"){const r=Ke(i),n=t.length;let o,s,a,l=Je(t,0);for(let c=0;c<n;++c){if(s=a,a=l,l=Je(t,c+1),!a)continue;const n=a[i],u=a[r];s&&(o=(n-s[i])/3,a[`cp1${i}`]=n-o,a[`cp1${r}`]=u-o*e[c]),l&&(o=(l[i]-n)/3,a[`cp2${i}`]=n+o,a[`cp2${r}`]=u+o*e[c])}}(t,o,e)}function ii(t,e,i){return Math.max(Math.min(t,i),e)}function ri(t,e,i,r,n){let o,s,a,l;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)ei(t,n);else{let i=r?t[t.length-1]:t[0];for(o=0,s=t.length;o<s;++o)a=t[o],l=ti(i,a,t[Math.min(o+1,s-(r?0:1))%s],e.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,i=a}e.capBezierPoints&&function(t,e){let i,r,n,o,s,a=ke(t[0],e);for(i=0,r=t.length;i<r;++i)s=o,o=a,a=i<r-1&&ke(t[i+1],e),o&&(n=t[i],s&&(n.cp1x=ii(n.cp1x,e.left,e.right),n.cp1y=ii(n.cp1y,e.top,e.bottom)),a&&(n.cp2x=ii(n.cp2x,e.left,e.right),n.cp2y=ii(n.cp2y,e.top,e.bottom)))}(t,i)}const ni=t=>0===t||1===t,oi=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*A/i),si=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*A/i)+1,ai={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*z),easeOutSine:t=>Math.sin(t*z),easeInOutSine:t=>-.5*(Math.cos(k*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>ni(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>ni(t)?t:oi(t,.075,.3),easeOutElastic:t=>ni(t)?t:si(t,.075,.3),easeInOutElastic(t){const e=.1125;return ni(t)?t:t<.5?.5*oi(2*t,e,.45):.5+.5*si(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-ai.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*ai.easeInBounce(2*t):.5*ai.easeOutBounce(2*t-1)+.5};function li(t,e,i,r){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function ci(t,e,i,r){return{x:t.x+i*(e.x-t.x),y:"middle"===r?i<.5?t.y:e.y:"after"===r?i<1?t.y:e.y:i>0?e.y:t.y}}function ui(t,e,i,r){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},s=li(t,n,i),a=li(n,o,i),l=li(o,e,i),c=li(s,a,i),u=li(a,l,i);return li(c,u,i)}const hi=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,pi=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function di(t,e){const i=(""+t).match(hi);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function fi(t,e){const i={},r=o(e),n=r?Object.keys(e):e,s=o(t)?r?i=>l(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=+s(t)||0;return i}function mi(t){return fi(t,{top:"y",right:"x",bottom:"y",left:"x"})}function _i(t){return fi(t,["topLeft","topRight","bottomLeft","bottomRight"])}function gi(t){const e=mi(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function yi(t,e){t=t||{},e=e||ae.font;let i=l(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let r=l(t.style,e.style);r&&!(""+r).match(pi)&&(console.warn('Invalid font style specified: "'+r+'"'),r=void 0);const n={family:l(t.family,e.family),lineHeight:di(l(t.lineHeight,e.lineHeight),i),size:i,style:r,weight:l(t.weight,e.weight),string:""};return n.string=be(n),n}function vi(t,e,i,r){let o,s,a,l=!0;for(o=0,s=t.length;o<s;++o)if(a=t[o],void 0!==a&&(void 0!==e&&"function"==typeof a&&(a=a(e),l=!1),void 0!==i&&n(a)&&(a=a[i%a.length],l=!1),void 0!==a))return r&&!l&&(r.cacheable=!1),a}function xi(t,e,i){const{min:r,max:n}=t,o=u(e,(n-r)/2),s=(t,e)=>i&&0===t?0:t+e;return{min:s(r,-Math.abs(o)),max:s(n,o)}}function bi(t,e){return Object.assign(Object.create(t),e)}function wi(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Ti(t,e){let i,r;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,r=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=r)}function Mi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Ei(t){return"angle"===t?{between:Y,compare:X,normalize:Q}:{between:tt,compare:(t,e)=>t-e,normalize:t=>t}}function Ci({start:t,end:e,count:i,loop:r,style:n}){return{start:t%i,end:e%i,loop:r&&(e-t+1)%i==0,style:n}}function Si(t,e,i){if(!i)return[t];const{property:r,start:n,end:o}=i,s=e.length,{compare:a,between:l,normalize:c}=Ei(r),{start:u,end:h,loop:p,style:d}=function(t,e,i){const{property:r,start:n,end:o}=i,{between:s,normalize:a}=Ei(r),l=e.length;let c,u,{start:h,end:p,loop:d}=t;if(d){for(h+=l,p+=l,c=0,u=l;c<u&&s(a(e[h%l][r]),n,o);++c)h--,p--;h%=l,p%=l}return p<h&&(p+=l),{start:h,end:p,loop:d,style:t.style}}(t,e,i),f=[];let m,_,g,y=!1,v=null;for(let t=u,i=u;t<=h;++t)_=e[t%s],_.skip||(m=c(_[r]),m!==g&&(y=l(m,n,o),null===v&&(y||l(n,g,m)&&0!==a(n,g))&&(v=0===a(m,n)?t:i),null!==v&&(!y||0===a(o,m)||l(o,g,m))&&(f.push(Ci({start:v,end:t,loop:p,count:s,style:d})),v=null),i=t,g=m));return null!==v&&f.push(Ci({start:v,end:h,loop:p,count:s,style:d})),f}function ki(t,e){const i=[],r=t.segments;for(let n=0;n<r.length;n++){const o=Si(r[n],t.points,e);o.length&&i.push(...o)}return i}function Ai(t,e){const i=t.points,r=t.options.spanGaps,n=i.length;if(!n)return[];const o=!!t._loop,{start:s,end:a}=function(t,e,i,r){let n=0,o=e-1;if(i&&!r)for(;n<e&&!t[n].skip;)n++;for(;n<e&&t[n].skip;)n++;for(n%=e,i&&(o+=n);o>n&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}(i,n,o,r);return Ii(t,!0===r?[{start:s,end:a,loop:o}]:function(t,e,i,r){const n=t.length,o=[];let s,a=e,l=t[e];for(s=e+1;s<=i;++s){const i=t[s%n];i.skip||i.stop?l.skip||(r=!1,o.push({start:e%n,end:(s-1)%n,loop:r}),e=a=i.stop?s:null):(a=s,l.skip&&(e=s)),l=i}return null!==a&&o.push({start:e%n,end:a%n,loop:r}),o}(i,s,a<s?a+n:a,!!t._fullLoop&&0===s&&a===n-1),i,e)}function Ii(t,e,i,r){return r&&r.setContext&&i?function(t,e,i,r){const n=t._chart.getContext(),o=Pi(t.options),{_datasetIndex:s,options:{spanGaps:a}}=t,l=i.length,c=[];let u=o,h=e[0].start,p=h;function d(t,e,r,n){const o=a?-1:1;if(t!==e){for(t+=l;i[t%l].skip;)t-=o;for(;i[e%l].skip;)e+=o;t%l!=e%l&&(c.push({start:t%l,end:e%l,loop:r,style:n}),u=n,h=e%l)}}for(const t of e){h=a?h:t.start;let e,o=i[h%l];for(p=h+1;p<=t.end;p++){const a=i[p%l];e=Pi(r.setContext(bi(n,{type:"segment",p0:o,p1:a,p0DataIndex:(p-1)%l,p1DataIndex:p%l,datasetIndex:s}))),Li(e,u)&&d(h,p-1,t.loop,u),o=a,u=e}h<p-1&&d(h,p-1,t.loop,u)}return c}(t,e,i,r):e}function Pi(t){return{backgroundColor:t.backgroundColor,borderCapStyle:t.borderCapStyle,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderJoinStyle:t.borderJoinStyle,borderWidth:t.borderWidth,borderColor:t.borderColor}}function Li(t,e){return e&&JSON.stringify(t)!==JSON.stringify(e)}var zi=Object.freeze({__proto__:null,easingEffects:ai,isPatternOrGradient:Wt,color:Xt,getHoverColor:Qt,noop:e,uid:i,isNullOrUndef:r,isArray:n,isObject:o,isFinite:s,finiteOrDefault:a,valueOrDefault:l,toPercentage:c,toDimension:u,callback:h,each:p,_elementsEqual:d,clone:f,_merger:_,merge:g,mergeIf:y,_mergerIf:v,_deprecated:function(t,e,i,r){void 0!==e&&console.warn(t+': "'+i+'" is deprecated. Please use "'+r+'" instead')},_splitKey:b,resolveObjectKey:w,_capitalize:T,defined:M,isFunction:E,setsEqual:C,_isClickEvent:S,toFontString:be,_measureText:we,_longestText:Te,_alignPixel:Me,clearCanvas:Ee,drawPoint:Ce,drawPointLegend:Se,_isPointInArea:ke,clipArea:Ae,unclipArea:Ie,_steppedLineTo:Pe,_bezierCurveTo:Le,renderText:ze,addRoundedRectPath:Oe,_lookup:et,_lookupByKey:it,_rlookupByKey:rt,_filterBetween:nt,listenArrayEvents:st,unlistenArrayEvents:at,_arrayUnique:lt,_createResolver:Fe,_attachContext:Be,_descriptors:je,_parseObjectDataRadialScale:Qe,splineCurve:ti,splineCurveMonotone:ei,_updateBezierControlPoints:ri,_isDomSupported:le,_getParentNode:ce,getStyle:pe,getRelativePosition:me,getMaximumSize:ge,retinaScale:ye,supportsEventListenerOptions:ve,readUsedSize:xe,fontString:function(t,e,i){return e+" "+t+"px "+i},requestAnimFrame:ct,throttled:ut,debounce:ht,_toLeftRightCenter:pt,_alignStartEnd:dt,_textX:ft,_getStartAndCountOfVisiblePoints:mt,_scaleRangesChanged:_t,_pointInLine:li,_steppedInterpolation:ci,_bezierInterpolation:ui,formatNumber:te,toLineHeight:di,_readValueToProps:fi,toTRBL:mi,toTRBLCorners:_i,toPadding:gi,toFont:yi,resolve:vi,_addGrace:xi,createContext:bi,PI:k,TAU:A,PITAU:I,INFINITY:P,RAD_PER_DEG:L,HALF_PI:z,QUARTER_PI:D,TWO_THIRDS_PI:R,log10:O,sign:F,almostEquals:B,niceNum:j,_factorize:N,isNumber:V,almostWhole:U,_setMinAndMaxByKey:$,toRadians:G,toDegrees:q,_decimalPlaces:Z,getAngleFromPoint:H,distanceBetweenPoints:W,_angleDiff:X,_normalizeAngle:Q,_angleBetween:Y,_limitValue:J,_int16Range:K,_isBetween:tt,getRtlAdapter:wi,overrideTextDirection:Ti,restoreTextDirection:Mi,_boundSegment:Si,_boundSegments:ki,_computeSegments:Ai});function Di(t,e,i,r){const{controller:n,data:o,_sorted:s}=t,a=n._cachedMeta.iScale;if(a&&e===a.axis&&"r"!==e&&s&&o.length){const t=a._reversePixels?rt:it;if(!r)return t(o,e,i);if(n._sharedOptions){const r=o[0],n="function"==typeof r.getRange&&r.getRange(e);if(n){const r=t(o,e,i-n),s=t(o,e,i+n);return{lo:r.lo,hi:s.hi}}}}return{lo:0,hi:o.length-1}}function Ri(t,e,i,r,n){const o=t.getSortedVisibleDatasetMetas(),s=i[e];for(let t=0,i=o.length;t<i;++t){const{index:i,data:a}=o[t],{lo:l,hi:c}=Di(o[t],e,s,n);for(let t=l;t<=c;++t){const e=a[t];e.skip||r(e,i,t)}}}function Oi(t,e,i,r,n){const o=[];return n||t.isPointInArea(e)?(Ri(t,i,e,(function(i,s,a){(n||ke(i,t.chartArea,0))&&i.inRange(e.x,e.y,r)&&o.push({element:i,datasetIndex:s,index:a})}),!0),o):o}function Fi(t,e,i,r,n,o){return o||t.isPointInArea(e)?"r"!==i||r?function(t,e,i,r,n,o){let s=[];const a=function(t){const e=-1!==t.indexOf("x"),i=-1!==t.indexOf("y");return function(t,r){const n=e?Math.abs(t.x-r.x):0,o=i?Math.abs(t.y-r.y):0;return Math.sqrt(Math.pow(n,2)+Math.pow(o,2))}}(i);let l=Number.POSITIVE_INFINITY;return Ri(t,i,e,(function(i,c,u){const h=i.inRange(e.x,e.y,n);if(r&&!h)return;const p=i.getCenterPoint(n);if(!o&&!t.isPointInArea(p)&&!h)return;const d=a(e,p);d<l?(s=[{element:i,datasetIndex:c,index:u}],l=d):d===l&&s.push({element:i,datasetIndex:c,index:u})})),s}(t,e,i,r,n,o):function(t,e,i,r){let n=[];return Ri(t,i,e,(function(t,i,o){const{startAngle:s,endAngle:a}=t.getProps(["startAngle","endAngle"],r),{angle:l}=H(t,{x:e.x,y:e.y});Y(l,s,a)&&n.push({element:t,datasetIndex:i,index:o})})),n}(t,e,i,n):[]}function Bi(t,e,i,r,n){const o=[],s="x"===i?"inXRange":"inYRange";let a=!1;return Ri(t,i,e,((t,r,l)=>{t[s](e[i],n)&&(o.push({element:t,datasetIndex:r,index:l}),a=a||t.inRange(e.x,e.y,n))})),r&&!a?[]:o}var ji={evaluateInteractionItems:Ri,modes:{index(t,e,i,r){const n=me(e,t),o=i.axis||"x",s=i.includeInvisible||!1,a=i.intersect?Oi(t,n,o,r,s):Fi(t,n,o,!1,r,s),l=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&l.push({element:i,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,i,r){const n=me(e,t),o=i.axis||"xy",s=i.includeInvisible||!1;let a=i.intersect?Oi(t,n,o,r,s):Fi(t,n,o,!1,r,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;t<i.length;++t)a.push({element:i[t],datasetIndex:e,index:t})}return a},point:(t,e,i,r)=>Oi(t,me(e,t),i.axis||"xy",r,i.includeInvisible||!1),nearest(t,e,i,r){const n=me(e,t),o=i.axis||"xy",s=i.includeInvisible||!1;return Fi(t,n,o,i.intersect,r,s)},x:(t,e,i,r)=>Bi(t,me(e,t),"x",i.intersect,r),y:(t,e,i,r)=>Bi(t,me(e,t),"y",i.intersect,r)}};const Ni=["left","top","right","bottom"];function Vi(t,e){return t.filter((t=>t.pos===e))}function Ui(t,e){return t.filter((t=>-1===Ni.indexOf(t.pos)&&t.box.axis===e))}function $i(t,e){return t.sort(((t,i)=>{const r=e?i:t,n=e?t:i;return r.weight===n.weight?r.index-n.index:r.weight-n.weight}))}function Gi(t,e,i,r){return Math.max(t[i],e[i])+Math.max(t[r],e[r])}function qi(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function Zi(t,e,i,r){const{pos:n,box:s}=i,a=t.maxPadding;if(!o(n)){i.size&&(t[n]-=i.size);const e=r[i.stack]||{size:0,count:1};e.size=Math.max(e.size,i.horizontal?s.height:s.width),i.size=e.size/e.count,t[n]+=i.size}s.getPadding&&qi(a,s.getPadding());const l=Math.max(0,e.outerWidth-Gi(a,t,"left","right")),c=Math.max(0,e.outerHeight-Gi(a,t,"top","bottom")),u=l!==t.w,h=c!==t.h;return t.w=l,t.h=c,i.horizontal?{same:u,other:h}:{same:h,other:u}}function Hi(t,e){const i=e.maxPadding;return function(t){const r={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{r[t]=Math.max(e[t],i[t])})),r}(t?["left","right"]:["top","bottom"])}function Wi(t,e,i,r){const n=[];let o,s,a,l,c,u;for(o=0,s=t.length,c=0;o<s;++o){a=t[o],l=a.box,l.update(a.width||e.w,a.height||e.h,Hi(a.horizontal,e));const{same:s,other:h}=Zi(e,i,a,r);c|=s&&n.length,u=u||h,l.fullSize||n.push(a)}return c&&Wi(n,e,i,r)||u}function Xi(t,e,i,r,n){t.top=i,t.left=e,t.right=e+r,t.bottom=i+n,t.width=r,t.height=n}function Qi(t,e,i,r){const n=i.padding;let{x:o,y:s}=e;for(const a of t){const t=a.box,l=r[a.stack]||{count:1,placed:0,weight:1},c=a.stackWeight/l.weight||1;if(a.horizontal){const r=e.w*c,o=l.size||t.height;M(l.start)&&(s=l.start),t.fullSize?Xi(t,n.left,s,i.outerWidth-n.right-n.left,o):Xi(t,e.left+l.placed,s,r,o),l.start=s,l.placed+=r,s=t.bottom}else{const r=e.h*c,s=l.size||t.width;M(l.start)&&(o=l.start),t.fullSize?Xi(t,o,n.top,s,i.outerHeight-n.bottom-n.top):Xi(t,o,e.top+l.placed,s,r),l.start=o,l.placed+=r,o=t.right}}e.x=o,e.y=s}var Yi={addBox(t,e){t.boxes||(t.boxes=[]),e.fullSize=e.fullSize||!1,e.position=e.position||"top",e.weight=e.weight||0,e._layers=e._layers||function(){return[{z:0,draw(t){e.draw(t)}}]},t.boxes.push(e)},removeBox(t,e){const i=t.boxes?t.boxes.indexOf(e):-1;-1!==i&&t.boxes.splice(i,1)},configure(t,e,i){e.fullSize=i.fullSize,e.position=i.position,e.weight=i.weight},update(t,e,i,r){if(!t)return;const n=gi(t.options.layout.padding),o=Math.max(e-n.width,0),s=Math.max(i-n.height,0),a=function(t){const e=function(t){const e=[];let i,r,n,o,s,a;for(i=0,r=(t||[]).length;i<r;++i)n=t[i],({position:o,options:{stack:s,stackWeight:a=1}}=n),e.push({index:i,box:n,pos:o,horizontal:n.isHorizontal(),weight:n.weight,stack:s&&o+s,stackWeight:a});return e}(t),i=$i(e.filter((t=>t.box.fullSize)),!0),r=$i(Vi(e,"left"),!0),n=$i(Vi(e,"right")),o=$i(Vi(e,"top"),!0),s=$i(Vi(e,"bottom")),a=Ui(e,"x"),l=Ui(e,"y");return{fullSize:i,leftAndTop:r.concat(o),rightAndBottom:n.concat(l).concat(s).concat(a),chartArea:Vi(e,"chartArea"),vertical:r.concat(n).concat(l),horizontal:o.concat(s).concat(a)}}(t.boxes),l=a.vertical,c=a.horizontal;p(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const u=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,h=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:s,vBoxMaxWidth:o/2/u,hBoxMaxHeight:s/2}),d=Object.assign({},n);qi(d,gi(r));const f=Object.assign({maxPadding:d,w:o,h:s,x:n.left,y:n.top},n),m=function(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:r,stackWeight:n}=i;if(!t||!Ni.includes(r))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:r,hBoxMaxHeight:n}=e;let o,s,a;for(o=0,s=t.length;o<s;++o){a=t[o];const{fullSize:s}=a.box,l=i[a.stack],c=l&&a.stackWeight/l.weight;a.horizontal?(a.width=c?c*r:s&&e.availableWidth,a.height=n):(a.width=r,a.height=c?c*n:s&&e.availableHeight)}return i}(l.concat(c),h);Wi(a.fullSize,f,h,m),Wi(l,f,h,m),Wi(c,f,h,m)&&Wi(l,f,h,m),function(t){const e=t.maxPadding;function i(i){const r=Math.max(e[i]-t[i],0);return t[i]+=r,r}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),Qi(a.leftAndTop,f,h,m),f.x+=f.w,f.y+=f.h,Qi(a.rightAndBottom,f,h,m),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},p(a.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})}))}};class Ji{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,r){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,r?Math.floor(e/r):i)}}isAttached(t){return!0}updateConfig(t){}}class Ki extends Ji{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const tr={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},er=t=>null===t||""===t,ir=!!ve&&{passive:!0};function rr(t,e,i){t.canvas.removeEventListener(e,i,ir)}function nr(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function or(t,e,i){const r=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nr(i.addedNodes,r),e=e&&!nr(i.removedNodes,r);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function sr(t,e,i){const r=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||nr(i.removedNodes,r),e=e&&!nr(i.addedNodes,r);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const ar=new Map;let lr=0;function cr(){const t=window.devicePixelRatio;t!==lr&&(lr=t,ar.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function ur(t,e,i){const r=t.canvas,n=r&&ce(r);if(!n)return;const o=ut(((t,e)=>{const r=n.clientWidth;i(t,e),r<n.clientWidth&&i()}),window),s=new ResizeObserver((t=>{const e=t[0],i=e.contentRect.width,r=e.contentRect.height;0===i&&0===r||o(i,r)}));return s.observe(n),function(t,e){ar.size||window.addEventListener("resize",cr),ar.set(t,e)}(t,o),s}function hr(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){ar.delete(t),ar.size||window.removeEventListener("resize",cr)}(t)}function pr(t,e,i){const r=t.canvas,n=ut((e=>{null!==t.ctx&&i(function(t,e){const i=tr[t.type]||t.type,{x:r,y:n}=me(t,e);return{type:i,chart:e,native:t,x:void 0!==r?r:null,y:void 0!==n?n:null}}(e,t))}),t);return function(t,e,i){t.addEventListener(e,i,ir)}(r,e,n),n}class dr extends Ji{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,r=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:r,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",er(n)){const e=xe(t,"width");void 0!==e&&(t.width=e)}if(er(r))if(""===t.style.height)t.height=t.width/(e||2);else{const e=xe(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const n=i[t];r(n)?e.removeAttribute(t):e.setAttribute(t,n)}));const n=i.style||{};return Object.keys(n).forEach((t=>{e.style[t]=n[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const r=t.$proxies||(t.$proxies={}),n={attach:or,detach:sr,resize:ur}[e]||pr;r[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),r=i[e];r&&(({attach:hr,detach:hr,resize:hr}[e]||rr)(t,e,r),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,r){return ge(t,e,i,r)}isAttached(t){const e=ce(t);return!(!e||!e.isConnected)}}function fr(t){return!le()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Ki:dr}var mr=Object.freeze({__proto__:null,_detectPlatform:fr,BasePlatform:Ji,BasicPlatform:Ki,DomPlatform:dr});const _r="transparent",gr={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const r=Xt(t||_r),n=r.valid&&Xt(e||_r);return n&&n.valid?n.mix(r,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class yr{constructor(t,e,i,r){const n=e[i];r=vi([t.to,r,n,t.from]);const o=vi([t.from,n,r]);this._active=!0,this._fn=t.fn||gr[t.type||typeof o],this._easing=ai[t.easing]||ai.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=r,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const r=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=vi([t.to,e,r,t.from]),this._from=vi([t.from,r,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,r=this._prop,n=this._from,o=this._loop,s=this._to;let a;if(this._active=n!==s&&(o||e<i),!this._active)return this._target[r]=s,void this._notify(!0);e<0?this._target[r]=n:(a=e/i%2,a=o&&a>1?2-a:a,a=this._easing(Math.min(1,Math.max(0,a))),this._target[r]=this._fn(n,s,a))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t<i.length;t++)i[t][e]()}}class vr{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!o(t))return;const e=Object.keys(ae.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach((r=>{const s=t[r];if(!o(s))return;const a={};for(const t of e)a[t]=s[t];(n(s.properties)&&s.properties||[r]).forEach((t=>{t!==r&&i.has(t)||i.set(t,a)}))}))}_animateOptions(t,e){const i=e.options,r=function(t,e){if(!e)return;let i=t.options;if(i){i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}t.options=e}(t,i);if(!r)return[];const n=this._createAnimations(r,i);return i.$shared&&function(t,e){const i=[],r=Object.keys(e);for(let e=0;e<r.length;e++){const n=t[r[e]];n&&n.active()&&i.push(n.wait())}return Promise.all(i)}(t.options.$animations,i).then((()=>{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,r=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),s=Date.now();let a;for(a=o.length-1;a>=0;--a){const l=o[a];if("$"===l.charAt(0))continue;if("options"===l){r.push(...this._animateOptions(t,e));continue}const c=e[l];let u=n[l];const h=i.get(l);if(u){if(h&&u.active()){u.update(h,c,s);continue}u.cancel()}h&&h.duration?(n[l]=u=new yr(h,t,l,c),r.push(u)):t[l]=c}return r}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(gt.add(this._chart,i),!0):void 0}}function xr(t,e){const i=t&&t.options||{},r=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:r?o:n,end:r?n:o}}function br(t,e){const i=[],r=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=r.length;n<o;++n)i.push(r[n].index);return i}function wr(t,e,i,r={}){const n=t.keys,o="single"===r.mode;let a,l,c,u;if(null!==e){for(a=0,l=n.length;a<l;++a){if(c=+n[a],c===i){if(r.all)continue;break}u=t.values[c],s(u)&&(o||0===e||F(e)===F(u))&&(e+=u)}return e}}function Tr(t,e){const i=t&&t.options.stacked;return i||void 0===i&&void 0!==e.stack}function Mr(t,e,i){const r=t[e]||(t[e]={});return r[i]||(r[i]={})}function Er(t,e,i,r){for(const n of e.getMatchingVisibleMetas(r).reverse()){const e=t[n.index];if(i&&e>0||!i&&e<0)return n.index}return null}function Cr(t,e){const{chart:i,_cachedMeta:r}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:s,index:a}=r,l=o.axis,c=s.axis,u=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,s,r),h=e.length;let p;for(let t=0;t<h;++t){const i=e[t],{[l]:o,[c]:h}=i;p=(i._stacks||(i._stacks={}))[c]=Mr(n,u,o),p[a]=h,p._top=Er(p,s,!0,r.type),p._bottom=Er(p,s,!1,r.type);(p._visualValues||(p._visualValues={}))[a]=h}}function Sr(t,e){const i=t.scales;return Object.keys(i).filter((t=>i[t].axis===e)).shift()}function kr(t,e){const i=t.controller.index,r=t.vScale&&t.vScale.axis;if(r){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[r]||void 0===e[r][i])return;delete e[r][i],void 0!==e[r]._visualValues&&void 0!==e[r]._visualValues[i]&&delete e[r]._visualValues[i]}}}const Ar=t=>"reset"===t||"none"===t,Ir=(t,e)=>e?t:Object.assign({},t);class Pr{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Tr(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&kr(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),r=(t,e,i,r)=>"x"===t?e:"r"===t?r:i,n=e.xAxisID=l(i.xAxisID,Sr(t,"x")),o=e.yAxisID=l(i.yAxisID,Sr(t,"y")),s=e.rAxisID=l(i.rAxisID,Sr(t,"r")),a=e.indexAxis,c=e.iAxisID=r(a,n,o,s),u=e.vAxisID=r(a,o,n,s);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(s),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&at(this._data,this),t._stacked&&kr(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(o(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let r,n,o;for(r=0,n=e.length;r<n;++r)o=e[r],i[r]={x:o,y:t[o]};return i}(e);else if(i!==e){if(i){at(i,this);const t=this._cachedMeta;kr(t),t._parsed=[]}e&&Object.isExtensible(e)&&st(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let r=!1;this._dataCheck();const n=e._stacked;e._stacked=Tr(e.vScale,e),e.stack!==i.stack&&(r=!0,kr(e),e.stack=i.stack),this._resyncElements(t),(r||n!==e._stacked)&&Cr(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:r}=this,{iScale:s,_stacked:a}=i,l=s.axis;let c,u,h,p=0===t&&e===r.length||i._sorted,d=t>0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=r,i._sorted=!0,h=r;else{h=n(r[t])?this.parseArrayData(i,r,t,e):o(r[t])?this.parseObjectData(i,r,t,e):this.parsePrimitiveData(i,r,t,e);const s=()=>null===u[l]||d&&u[l]<d[l];for(c=0;c<e;++c)i._parsed[c+t]=u=h[c],p&&(s()&&(p=!1),d=u);i._sorted=p}a&&Cr(this,h)}parsePrimitiveData(t,e,i,r){const{iScale:n,vScale:o}=t,s=n.axis,a=o.axis,l=n.getLabels(),c=n===o,u=new Array(r);let h,p,d;for(h=0,p=r;h<p;++h)d=h+i,u[h]={[s]:c||n.parse(l[d],d),[a]:o.parse(e[d],d)};return u}parseArrayData(t,e,i,r){const{xScale:n,yScale:o}=t,s=new Array(r);let a,l,c,u;for(a=0,l=r;a<l;++a)c=a+i,u=e[c],s[a]={x:n.parse(u[0],c),y:o.parse(u[1],c)};return s}parseObjectData(t,e,i,r){const{xScale:n,yScale:o}=t,{xAxisKey:s="x",yAxisKey:a="y"}=this._parsing,l=new Array(r);let c,u,h,p;for(c=0,u=r;c<u;++c)h=c+i,p=e[h],l[c]={x:n.parse(w(p,s),h),y:o.parse(w(p,a),h)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,i){const r=this.chart,n=this._cachedMeta,o=e[t.axis];return wr({keys:br(r,!0),values:e._stacks[t.axis]._visualValues},o,n.index,{mode:i})}updateRangeFromParsed(t,e,i,r){const n=i[e.axis];let o=null===n?NaN:n;const s=r&&i._stacks[e.axis];r&&s&&(r.values=s,o=wr(r,n,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,e){const i=this._cachedMeta,r=i._parsed,n=i._sorted&&t===i.iScale,o=r.length,a=this._getOtherScale(t),l=((t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:br(i,!0),values:null})(e,i,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:h}=function(t){const{min:e,max:i,minDefined:r,maxDefined:n}=t.getUserBounds();return{min:r?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}(a);let p,d;function f(){d=r[p];const e=d[a.axis];return!s(d[t.axis])||u>e||h<e}for(p=0;p<o&&(f()||(this.updateRangeFromParsed(c,t,d,l),!n));++p);if(n)for(p=o-1;p>=0;--p)if(!f()){this.updateRangeFromParsed(c,t,d,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let r,n,o;for(r=0,n=e.length;r<n;++r)o=e[r][t.axis],s(o)&&i.push(o);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,i=e.iScale,r=e.vScale,n=this.getParsed(t);return{label:i?""+i.getLabelForValue(n[i.axis]):"",value:r?""+r.getLabelForValue(n[r.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=function(t){let e,i,r,n;return o(t)?(e=t.top,i=t.right,r=t.bottom,n=t.left):e=i=r=n=t,{top:e,right:i,bottom:r,left:n,disabled:!1===t}}(l(this.options.clip,function(t,e,i){if(!1===i)return!1;const r=xr(t,i),n=xr(e,i);return{top:n.end,right:r.end,bottom:n.start,left:r.start}}(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,i=this._cachedMeta,r=i.data||[],n=e.chartArea,o=[],s=this._drawStart||0,a=this._drawCount||r.length-s,l=this.options.drawActiveElementsOnTop;let c;for(i.dataset&&i.dataset.draw(t,n,s,a),c=s;c<s+a;++c){const e=r[c];e.hidden||(e.active&&l?o.push(e):e.draw(t,n))}for(c=0;c<o.length;++c)o[c].draw(t,n)}getStyle(t,e){const i=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,e,i){const r=this.getDataset();let n;if(t>=0&&t<this._cachedMeta.data.length){const e=this._cachedMeta.data[t];n=e.$context||(e.$context=function(t,e,i){return bi(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:i,index:e,mode:"default",type:"data"})}(this.getContext(),t,e)),n.parsed=this.getParsed(t),n.raw=r.data[t],n.index=n.dataIndex=t}else n=this.$context||(this.$context=function(t,e){return bi(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}(this.chart.getContext(),this.index)),n.dataset=r,n.index=n.datasetIndex=this.index;return n.active=!!e,n.mode=i,n}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",i){const r="active"===e,n=this._cachedDataOpts,o=t+"-"+e,s=n[o],a=this.enableOptionSharing&&M(i);if(s)return Ir(s,a);const l=this.chart.config,c=l.datasetElementScopeKeys(this._type,t),u=r?[`${t}Hover`,"hover",t,""]:[t,""],h=l.getOptionScopes(this.getDataset(),c),p=Object.keys(ae.elements[t]),d=l.resolveNamedOptions(h,p,(()=>this.getContext(i,r,e)),u);return d.$shared&&(d.$shared=a,n[o]=Object.freeze(Ir(d,a))),d}_resolveAnimations(t,e,i){const r=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,s=n[o];if(s)return s;let a;if(!1!==r.options.animation){const r=this.chart.config,n=r.datasetAnimationScopeKeys(this._type,e),o=r.getOptionScopes(this.getDataset(),n);a=r.createResolver(o,this.getContext(t,i,e))}const l=new vr(r,a&&a.animations);return a&&a._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ar(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),r=this._sharedOptions,n=this.getSharedOptions(i),o=this.includeOptions(e,n)||n!==r;return this.updateSharedOptions(n,e,i),{sharedOptions:n,includeOptions:o}}updateElement(t,e,i,r){Ar(r)?Object.assign(t,i):this._resolveAnimations(e,r).update(t,i)}updateSharedOptions(t,e,i){t&&!Ar(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,r){t.active=r;const n=this.getStyle(e,r);this._resolveAnimations(e,i,r).update(t,{options:!r&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const r=i.length,n=e.length,o=Math.min(n,r);o&&this.parse(0,o),n>r?this._insertElements(r,n-r,t):n<r&&this._removeElements(n,r-n)}_insertElements(t,e,i=!0){const r=this._cachedMeta,n=r.data,o=t+e;let s;const a=t=>{for(t.length+=e,s=t.length-1;s>=o;s--)t[s]=t[s-e]};for(a(n),s=t;s<o;++s)n[s]=new this.dataElementType;this._parsing&&a(r._parsed),this.parse(t,e),i&&this.updateElements(n,t,e,"reset")}updateElements(t,e,i,r){}_removeElements(t,e){const i=this._cachedMeta;if(this._parsing){const r=i._parsed.splice(t,e);i._stacked&&kr(i,r)}i.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,i,r]=t;this[e](i,r)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}class Lr{static defaults={};static defaultRoutes=void 0;active=!1;tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return V(this.x)&&V(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const r={};return t.forEach((t=>{r[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),r}}function zr(t,e){const i=t.options.ticks,n=function(t){const e=t.options.offset,i=t._tickSize(),r=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(r,n))}(t),o=Math.min(i.maxTicksLimit||n,n),s=i.major.enabled?function(t){const e=[];let i,r;for(i=0,r=t.length;i<r;i++)t[i].major&&e.push(i);return e}(e):[],a=s.length,l=s[0],c=s[a-1],u=[];if(a>o)return function(t,e,i,r){let n,o=0,s=i[0];for(r=Math.ceil(r),n=0;n<t.length;n++)n===s&&(e.push(t[n]),o++,s=i[o*r])}(e,u,s,a/o),u;const h=function(t,e,i){const r=function(t){const e=t.length;let i,r;if(e<2)return!1;for(r=t[0],i=1;i<e;++i)if(t[i]-t[i-1]!==r)return!1;return r}(t),n=e.length/i;if(!r)return Math.max(n,1);const o=N(r);for(let t=0,e=o.length-1;t<e;t++){const e=o[t];if(e>n)return e}return Math.max(n,1)}(s,e,o);if(a>0){let t,i;const n=a>1?Math.round((c-l)/(a-1)):null;for(Dr(e,u,h,r(n)?0:l-n,l),t=0,i=a-1;t<i;t++)Dr(e,u,h,s[t],s[t+1]);return Dr(e,u,h,c,r(n)?e.length:c+n),u}return Dr(e,u,h),u}function Dr(t,e,i,r,n){const o=l(r,0),s=Math.min(l(n,t.length),t.length);let a,c,u,h=0;for(i=Math.ceil(i),n&&(a=n-r,i=a/Math.floor(a/i)),u=o;u<0;)h++,u=Math.round(o+h*i);for(c=Math.max(o,0);c<s;c++)c===u&&(e.push(t[c]),h++,u=Math.round(o+h*i))}const Rr=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i,Or=(t,e)=>Math.min(e||t,t);function Fr(t,e){const i=[],r=t.length/e,n=t.length;let o=0;for(;o<n;o+=r)i.push(t[Math.floor(o)]);return i}function Br(t,e,i){const r=t.ticks.length,n=Math.min(e,r-1),o=t._startPixel,s=t._endPixel,a=1e-6;let l,c=t.getPixelForTick(n);if(!(i&&(l=1===r?Math.max(c-o,s-c):0===e?(t.getPixelForTick(1)-c)/2:(c-t.getPixelForTick(n-1))/2,c+=n<e?l:-l,c<o-a||c>s+a)))return c}function jr(t){return t.drawTicks?t.tickLength:0}function Nr(t,e){if(!t.display)return 0;const i=yi(t.font,e),r=gi(t.padding);return(n(t.text)?t.text.length:1)*i.lineHeight+r.height}function Vr(t,e,i){let r=pt(t);return(i&&"right"!==e||!i&&"right"===e)&&(r=(t=>"left"===t?"right":"right"===t?"left":t)(r)),r}class Ur extends Lr{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:r}=this;return t=a(t,Number.POSITIVE_INFINITY),e=a(e,Number.NEGATIVE_INFINITY),i=a(i,Number.POSITIVE_INFINITY),r=a(r,Number.NEGATIVE_INFINITY),{min:a(t,i),max:a(e,r),minDefined:s(t),maxDefined:s(e)}}getMinMax(t){let e,{min:i,max:r,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:r};const s=this.getMatchingVisibleMetas();for(let a=0,l=s.length;a<l;++a)e=s[a].controller.getMinMax(this,t),n||(i=Math.min(i,e.min)),o||(r=Math.max(r,e.max));return i=o&&i>r?r:i,r=n&&i>r?i:r,{min:a(i,a(r,i)),max:a(r,a(i,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){h(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:r,grace:n,ticks:o}=this.options,s=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=xi(this,n,r),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const a=s<this.ticks.length;this._convertTicksToLabels(a?Fr(this.ticks,s):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||"auto"===o.source)&&(this.ticks=zr(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),a&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t,e,i=this.options.reverse;this.isHorizontal()?(t=this.left,e=this.right):(t=this.top,e=this.bottom,i=!i),this._startPixel=t,this._endPixel=e,this._reversePixels=i,this._length=e-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){h(this.options.afterUpdate,[this])}beforeSetDimensions(){h(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){h(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),h(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){h(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let i,r,n;for(i=0,r=t.length;i<r;i++)n=t[i],n.label=h(e.callback,[n.value,i,t],this)}afterTickToLabelConversion(){h(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){h(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,i=Or(this.ticks.length,t.ticks.maxTicksLimit),r=e.minRotation||0,n=e.maxRotation;let o,s,a,l=r;if(!this._isVisible()||!e.display||r>=n||i<=1||!this.isHorizontal())return void(this.labelRotation=r);const c=this._getLabelSizes(),u=c.widest.width,h=c.highest.height,p=J(this.chart.width-u,0,this.maxWidth);o=t.offset?this.maxWidth/i:p/(i-1),u+6>o&&(o=p/(i-(t.offset?.5:1)),s=this.maxHeight-jr(t.grid)-e.padding-Nr(t.title,this.chart.options.font),a=Math.sqrt(u*u+h*h),l=q(Math.min(Math.asin(J((c.highest.height+6)/o,-1,1)),Math.asin(J(s/a,-1,1))-Math.asin(J(h/a,-1,1)))),l=Math.max(r,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){h(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){h(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:r,grid:n}}=this,o=this._isVisible(),s=this.isHorizontal();if(o){const o=Nr(r,e.options.font);if(s?(t.width=this.maxWidth,t.height=jr(n)+o):(t.height=this.maxHeight,t.width=jr(n)+o),i.display&&this.ticks.length){const{first:e,last:r,widest:n,highest:o}=this._getLabelSizes(),a=2*i.padding,l=G(this.labelRotation),c=Math.cos(l),u=Math.sin(l);if(s){const e=i.mirror?0:u*n.width+c*o.height;t.height=Math.min(this.maxHeight,t.height+e+a)}else{const e=i.mirror?0:c*n.width+u*o.height;t.width=Math.min(this.maxWidth,t.width+e+a)}this._calculatePadding(e,r,u,c)}}this._handleMargins(),s?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,r){const{ticks:{align:n,padding:o},position:s}=this.options,a=0!==this.labelRotation,l="top"!==s&&"x"===this.axis;if(this.isHorizontal()){const s=this.getPixelForTick(0)-this.left,c=this.right-this.getPixelForTick(this.ticks.length-1);let u=0,h=0;a?l?(u=r*t.width,h=i*e.height):(u=i*t.height,h=r*e.width):"start"===n?h=e.width:"end"===n?u=t.width:"inner"!==n&&(u=t.width/2,h=e.width/2),this.paddingLeft=Math.max((u-s+o)*this.width/(this.width-s),0),this.paddingRight=Math.max((h-c+o)*this.width/(this.width-c),0)}else{let i=e.height/2,r=t.height/2;"start"===n?(i=0,r=t.height):"end"===n&&(i=e.height,r=0),this.paddingTop=i+o,this.paddingBottom=r+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){h(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e<i;e++)r(t[e].label)&&(t.splice(e,1),i--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let i=this.ticks;e<i.length&&(i=Fr(i,e)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,i){const{ctx:o,_longestTextCache:s}=this,a=[],l=[],c=Math.floor(e/Or(e,i));let u,h,d,f,m,_,g,y,v,x,b,w=0,T=0;for(u=0;u<e;u+=c){if(f=t[u].label,m=this._resolveTickFontOptions(u),o.font=_=m.string,g=s[_]=s[_]||{data:{},gc:[]},y=m.lineHeight,v=x=0,r(f)||n(f)){if(n(f))for(h=0,d=f.length;h<d;++h)b=f[h],r(b)||n(b)||(v=we(o,g.data,g.gc,v,b),x+=y)}else v=we(o,g.data,g.gc,v,f),x=y;a.push(v),l.push(x),w=Math.max(v,w),T=Math.max(x,T)}!function(t,e){p(t,(t=>{const i=t.gc,r=i.length/2;let n;if(r>e){for(n=0;n<r;++n)delete t.data[i[n]];i.splice(0,r)}}))}(s,e);const M=a.indexOf(w),E=l.indexOf(T),C=t=>({width:a[t]||0,height:l[t]||0});return{first:C(0),last:C(e-1),widest:C(M),highest:C(E),widths:a,heights:l}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return K(this._alignToPixels?Me(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&t<e.length){const i=e[t];return i.$context||(i.$context=function(t,e,i){return bi(t,{tick:i,index:e,type:"tick"})}(this.getContext(),t,i))}return this.$context||(this.$context=bi(this.chart.getContext(),{scale:this,type:"scale"}))}_tickSize(){const t=this.options.ticks,e=G(this.labelRotation),i=Math.abs(Math.cos(e)),r=Math.abs(Math.sin(e)),n=this._getLabelSizes(),o=t.autoSkipPadding||0,s=n?n.widest.width+o:0,a=n?n.highest.height+o:0;return this.isHorizontal()?a*i>s*r?s/i:a/r:a*r<s*i?a/i:s/r}_isVisible(){const t=this.options.display;return"auto"!==t?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,i=this.chart,r=this.options,{grid:n,position:s,border:a}=r,c=n.offset,u=this.isHorizontal(),h=this.ticks.length+(c?1:0),p=jr(n),d=[],f=a.setContext(this.getContext()),m=f.display?f.width:0,_=m/2,g=function(t){return Me(i,t,m)};let y,v,x,b,w,T,M,E,C,S,k,A;if("top"===s)y=g(this.bottom),T=this.bottom-p,E=y-_,S=g(t.top)+_,A=t.bottom;else if("bottom"===s)y=g(this.top),S=t.top,A=g(t.bottom)-_,T=y+_,E=this.top+p;else if("left"===s)y=g(this.right),w=this.right-p,M=y-_,C=g(t.left)+_,k=t.right;else if("right"===s)y=g(this.left),C=t.left,k=g(t.right)-_,w=y+_,M=this.left+p;else if("x"===e){if("center"===s)y=g((t.top+t.bottom)/2+.5);else if(o(s)){const t=Object.keys(s)[0],e=s[t];y=g(this.chart.scales[t].getPixelForValue(e))}S=t.top,A=t.bottom,T=y+_,E=T+p}else if("y"===e){if("center"===s)y=g((t.left+t.right)/2);else if(o(s)){const t=Object.keys(s)[0],e=s[t];y=g(this.chart.scales[t].getPixelForValue(e))}w=y-_,M=w-p,C=t.left,k=t.right}const I=l(r.ticks.maxTicksLimit,h),P=Math.max(1,Math.ceil(h/I));for(v=0;v<h;v+=P){const t=this.getContext(v),e=n.setContext(t),r=a.setContext(t),o=e.lineWidth,s=e.color,l=r.dash||[],h=r.dashOffset,p=e.tickWidth,f=e.tickColor,m=e.tickBorderDash||[],_=e.tickBorderDashOffset;x=Br(this,v,c),void 0!==x&&(b=Me(i,x,o),u?w=M=C=k=b:T=E=S=A=b,d.push({tx1:w,ty1:T,tx2:M,ty2:E,x1:C,y1:S,x2:k,y2:A,width:o,color:s,borderDash:l,borderDashOffset:h,tickWidth:p,tickColor:f,tickBorderDash:m,tickBorderDashOffset:_}))}return this._ticksLength=h,this._borderValue=y,d}_computeLabelItems(t){const e=this.axis,i=this.options,{position:r,ticks:s}=i,a=this.isHorizontal(),l=this.ticks,{align:c,crossAlign:u,padding:h,mirror:p}=s,d=jr(i.grid),f=d+h,m=p?-h:f,_=-G(this.labelRotation),g=[];let y,v,x,b,w,T,M,E,C,S,k,A,I="middle";if("top"===r)T=this.bottom-m,M=this._getXAxisLabelAlignment();else if("bottom"===r)T=this.top+m,M=this._getXAxisLabelAlignment();else if("left"===r){const t=this._getYAxisLabelAlignment(d);M=t.textAlign,w=t.x}else if("right"===r){const t=this._getYAxisLabelAlignment(d);M=t.textAlign,w=t.x}else if("x"===e){if("center"===r)T=(t.top+t.bottom)/2+f;else if(o(r)){const t=Object.keys(r)[0],e=r[t];T=this.chart.scales[t].getPixelForValue(e)+f}M=this._getXAxisLabelAlignment()}else if("y"===e){if("center"===r)w=(t.left+t.right)/2-f;else if(o(r)){const t=Object.keys(r)[0],e=r[t];w=this.chart.scales[t].getPixelForValue(e)}M=this._getYAxisLabelAlignment(d).textAlign}"y"===e&&("start"===c?I="top":"end"===c&&(I="bottom"));const P=this._getLabelSizes();for(y=0,v=l.length;y<v;++y){x=l[y],b=x.label;const t=s.setContext(this.getContext(y));E=this.getPixelForTick(y)+s.labelOffset,C=this._resolveTickFontOptions(y),S=C.lineHeight,k=n(b)?b.length:1;const e=k/2,i=t.color,o=t.textStrokeColor,c=t.textStrokeWidth;let h,d=M;if(a?(w=E,"inner"===M&&(d=y===v-1?this.options.reverse?"left":"right":0===y?this.options.reverse?"right":"left":"center"),A="top"===r?"near"===u||0!==_?-k*S+S/2:"center"===u?-P.highest.height/2-e*S+S:-P.highest.height+S/2:"near"===u||0!==_?S/2:"center"===u?P.highest.height/2-e*S:P.highest.height-k*S,p&&(A*=-1),0===_||t.showLabelBackdrop||(w+=S/2*Math.sin(_))):(T=E,A=(1-k)*S/2),t.showLabelBackdrop){const e=gi(t.backdropPadding),i=P.heights[y],r=P.widths[y];let n=A-e.top,o=0-e.left;switch(I){case"middle":n-=i/2;break;case"bottom":n-=i}switch(M){case"center":o-=r/2;break;case"right":o-=r}h={left:o,top:n,width:r+e.width,height:i+e.height,color:t.backdropColor}}g.push({label:b,font:C,textOffset:A,options:{rotation:_,color:i,strokeColor:o,strokeWidth:c,textAlign:d,textBaseline:I,translation:[w,T],backdrop:h}})}return g}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-G(this.labelRotation))return"top"===t?"left":"right";let i="center";return"start"===e.align?i="left":"end"===e.align?i="right":"inner"===e.align&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:r,padding:n}}=this.options,o=t+n,s=this._getLabelSizes().widest.width;let a,l;return"left"===e?r?(l=this.right+n,"near"===i?a="left":"center"===i?(a="center",l+=s/2):(a="right",l+=s)):(l=this.right-o,"near"===i?a="right":"center"===i?(a="center",l-=s/2):(a="left",l=this.left)):"right"===e?r?(l=this.left+n,"near"===i?a="right":"center"===i?(a="center",l-=s/2):(a="left",l-=s)):(l=this.left+o,"near"===i?a="left":"center"===i?(a="center",l+=s/2):(a="right",l=this.right)):a="right",{textAlign:a,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:r,width:n,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,r,n,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const i=this.ticks.findIndex((e=>e.value===t));return i>=0?e.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const e=this.options.grid,i=this.ctx,r=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const s=(t,e,r)=>{r.width&&r.color&&(i.save(),i.lineWidth=r.width,i.strokeStyle=r.color,i.setLineDash(r.borderDash||[]),i.lineDashOffset=r.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=r.length;n<o;++n){const t=r[n];e.drawOnChartArea&&s({x:t.x1,y:t.y1},{x:t.x2,y:t.y2},t),e.drawTicks&&s({x:t.tx1,y:t.ty1},{x:t.tx2,y:t.ty2},{color:t.tickColor,width:t.tickWidth,borderDash:t.tickBorderDash,borderDashOffset:t.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:e,options:{border:i,grid:r}}=this,n=i.setContext(this.getContext()),o=i.display?n.width:0;if(!o)return;const s=r.setContext(this.getContext(0)).lineWidth,a=this._borderValue;let l,c,u,h;this.isHorizontal()?(l=Me(t,this.left,o)-o/2,c=Me(t,this.right,s)+s/2,u=h=a):(u=Me(t,this.top,o)-o/2,h=Me(t,this.bottom,s)+s/2,l=c=a),e.save(),e.lineWidth=n.width,e.strokeStyle=n.color,e.beginPath(),e.moveTo(l,u),e.lineTo(c,h),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const e=this.ctx,i=this._computeLabelArea();i&&Ae(e,i);const r=this.getLabelItems(t);for(const t of r){const i=t.options,r=t.font;ze(e,t.label,0,t.textOffset,r,i)}i&&Ie(e)}drawTitle(){const{ctx:t,options:{position:e,title:i,reverse:r}}=this;if(!i.display)return;const s=yi(i.font),a=gi(i.padding),l=i.align;let c=s.lineHeight/2;"bottom"===e||"center"===e||o(e)?(c+=a.bottom,n(i.text)&&(c+=s.lineHeight*(i.text.length-1))):c+=a.top;const{titleX:u,titleY:h,maxWidth:p,rotation:d}=function(t,e,i,r){const{top:n,left:s,bottom:a,right:l,chart:c}=t,{chartArea:u,scales:h}=c;let p,d,f,m=0;const _=a-n,g=l-s;if(t.isHorizontal()){if(d=dt(r,s,l),o(i)){const t=Object.keys(i)[0],r=i[t];f=h[t].getPixelForValue(r)+_-e}else f="center"===i?(u.bottom+u.top)/2+_-e:Rr(t,i,e);p=l-s}else{if(o(i)){const t=Object.keys(i)[0],r=i[t];d=h[t].getPixelForValue(r)-g+e}else d="center"===i?(u.left+u.right)/2-g+e:Rr(t,i,e);f=dt(r,a,n),m="left"===i?-z:z}return{titleX:d,titleY:f,maxWidth:p,rotation:m}}(this,c,e,l);ze(t,i.text,0,0,s,{color:i.color,maxWidth:p,rotation:d,textAlign:Vr(l,e,r),textBaseline:"middle",translation:[u,h]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,e=t.ticks&&t.ticks.z||0,i=l(t.grid&&t.grid.z,-1),r=l(t.border&&t.border.z,0);return this._isVisible()&&this.draw===Ur.prototype.draw?[{z:i,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:r,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",r=[];let n,o;for(n=0,o=e.length;n<o;++n){const o=e[n];o[i]!==this.id||t&&o.type!==t||r.push(o)}return r}_resolveTickFontOptions(t){return yi(this.options.ticks.setContext(this.getContext(t)).font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class $r{constructor(t,e,i){this.type=t,this.scope=e,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const e=Object.getPrototypeOf(t);let i;(function(t){return"id"in t&&"defaults"in t})(e)&&(i=this.register(e));const r=this.items,n=t.id,o=this.scope+"."+n;if(!n)throw new Error("class does not have id: "+t);return n in r||(r[n]=t,function(t,e,i){const r=g(Object.create(null),[i?ae.get(i):{},ae.get(e),t.defaults]);ae.set(e,r),t.defaultRoutes&&function(t,e){Object.keys(e).forEach((i=>{const r=i.split("."),n=r.pop(),o=[t].concat(r).join("."),s=e[i].split("."),a=s.pop(),l=s.join(".");ae.route(o,n,l,a)}))}(e,t.defaultRoutes);t.descriptors&&ae.describe(e,t.descriptors)}(t,o,i),this.override&&ae.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,r=this.scope;i in e&&delete e[i],r&&i in ae[r]&&(delete ae[r][i],this.override&&delete re[i])}}var Gr=new class{constructor(){this.controllers=new $r(Pr,"datasets",!0),this.elements=new $r(Lr,"elements"),this.plugins=new $r(Object,"plugins"),this.scales=new $r(Ur,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const r=i||this._getRegistryForType(e);i||r.isForType(e)||r===this.plugins&&e.id?this._exec(t,r,e):p(e,(e=>{const r=i||this._getRegistryForType(e);this._exec(t,r,e)}))}))}_exec(t,e,i){const r=T(t);h(i["before"+r],[],i),e[t](i),h(i["after"+r],[],i)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const i=this._typedRegistries[e];if(i.isForType(t))return i}return this.plugins}_get(t,e,i){const r=e.get(t);if(void 0===r)throw new Error('"'+t+'" is not a registered '+i+".");return r}};class qr{constructor(){this._init=[]}notify(t,e,i,r){"beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const n=r?this._descriptors(t).filter(r):this._descriptors(t),o=this._notify(n,t,e,i);return"afterDestroy"===e&&(this._notify(n,t,"stop"),this._notify(this._init,t,"uninstall")),o}_notify(t,e,i,r){r=r||{};for(const n of t){const t=n.plugin;if(!1===h(t[i],[e,r,n.options],t)&&r.cancelable)return!1}return!0}invalidate(){r(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){const i=t&&t.config,r=l(i.options&&i.options.plugins,{}),n=function(t){const e={},i=[],r=Object.keys(Gr.plugins.items);for(let t=0;t<r.length;t++)i.push(Gr.getPlugin(r[t]));const n=t.plugins||[];for(let t=0;t<n.length;t++){const r=n[t];-1===i.indexOf(r)&&(i.push(r),e[r.id]=!0)}return{plugins:i,localIds:e}}(i);return!1!==r||e?function(t,{plugins:e,localIds:i},r,n){const o=[],s=t.getContext();for(const a of e){const e=a.id,l=Zr(r[e],n);null!==l&&o.push({plugin:a,options:Hr(t.config,{plugin:a,local:i[e]},l,s)})}return o}(t,n,r,e):[]}_notifyStateChanges(t){const e=this._oldCache||[],i=this._cache,r=(t,e)=>t.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(r(e,i),t,"stop"),this._notify(r(i,e),t,"start")}}function Zr(t,e){return e||!1!==t?!0===t?{}:t:null}function Hr(t,{plugin:e,local:i},r,n){const o=t.pluginScopeKeys(e),s=t.getOptionScopes(r,o);return i&&e.defaults&&s.push(e.defaults),t.createResolver(s,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Wr(t,e){const i=ae.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Xr(t,e){if("x"===t||"y"===t||"r"===t)return t;var i;if(t=e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.length>1&&Xr(t[0].toLowerCase(),e))return t;throw new Error(`Cannot determine type of '${name}' axis. Please provide 'axis' or 'position' option.`)}function Qr(t){const e=t.options||(t.options={});e.plugins=l(e.plugins,{}),e.scales=function(t,e){const i=re[t.type]||{scales:{}},r=e.scales||{},n=Wr(t.type,e),s=Object.create(null);return Object.keys(r).forEach((t=>{const e=r[t];if(!o(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const a=Xr(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(a,n),c=i.scales||{};s[t]=y(Object.create(null),[{axis:a},e,c[a],c[l]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,o=i.indexAxis||Wr(n,e),a=(re[n]||{}).scales||{};Object.keys(a).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,o),n=i[e+"AxisID"]||e;s[n]=s[n]||Object.create(null),y(s[n],[{axis:e},r[n],a[t]])}))})),Object.keys(s).forEach((t=>{const e=s[t];y(e,[ae.scales[e.type],ae.scale])})),s}(t,e)}function Yr(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Jr=new Map,Kr=new Set;function tn(t,e){let i=Jr.get(t);return i||(i=e(),Jr.set(t,i),Kr.add(i)),i}const en=(t,e,i)=>{const r=w(e,i);void 0!==r&&t.add(r)};class rn{constructor(t){this._config=function(t){return(t=t||{}).data=Yr(t.data),Qr(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Yr(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Qr(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return tn(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return tn(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return tn(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return tn(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let r=i.get(t);return r&&!e||(r=new Map,i.set(t,r)),r}getOptionScopes(t,e,i){const{options:r,type:n}=this,o=this._cachedScopes(t,i),s=o.get(e);if(s)return s;const a=new Set;e.forEach((e=>{t&&(a.add(t),e.forEach((e=>en(a,t,e)))),e.forEach((t=>en(a,r,t))),e.forEach((t=>en(a,re[n]||{},t))),e.forEach((t=>en(a,ae,t))),e.forEach((t=>en(a,ne,t)))}));const l=Array.from(a);return 0===l.length&&l.push(Object.create(null)),Kr.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,re[e]||{},ae.datasets[e]||{},{type:e},ae,ne]}resolveNamedOptions(t,e,i,r=[""]){const o={$shared:!0},{resolver:s,subPrefixes:a}=nn(this._resolverCache,t,r);let l=s;if(function(t,e){const{isScriptable:i,isIndexable:r}=je(t);for(const o of e){const e=i(o),s=r(o),a=(s||e)&&t[o];if(e&&(E(a)||on(a))||s&&n(a))return!0}return!1}(s,e)){o.$shared=!1;l=Be(s,i=E(i)?i():i,this.createResolver(t,i,a))}for(const t of e)o[t]=l[t];return o}createResolver(t,e,i=[""],r){const{resolver:n}=nn(this._resolverCache,t,i);return o(e)?Be(n,e,void 0,r):n}}function nn(t,e,i){let r=t.get(e);r||(r=new Map,t.set(e,r));const n=i.join();let o=r.get(n);o||(o={resolver:Fe(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},r.set(n,o));return o}const on=t=>o(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||E(t[i])),!1),sn=["top","bottom","left","right","chartArea"];function an(t,e){return"top"===t||"bottom"===t||-1===sn.indexOf(t)&&"x"===e}function ln(t,e){return function(i,r){return i[t]===r[t]?i[e]-r[e]:i[t]-r[t]}}function cn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),h(i&&i.onComplete,[t],e)}function un(t){const e=t.chart,i=e.options.animation;h(i&&i.onProgress,[t],e)}function hn(t){return le()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const pn={},dn=t=>{const e=hn(t);return Object.values(pn).filter((t=>t.canvas===e)).pop()};function fn(t,e,i){const r=Object.keys(t);for(const n of r){const r=+n;if(r>=e){const o=t[n];delete t[n],(i>0||r>e)&&(t[r+i]=o)}}}class mn{static defaults=ae;static instances=pn;static overrides=re;static registry=Gr;static version="4.2.1";static getChart=dn;static register(...t){Gr.add(...t),_n()}static unregister(...t){Gr.remove(...t),_n()}constructor(t,e){const r=this.config=new rn(e),n=hn(t),o=dn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const s=r.createResolver(r.chartOptionScopes(),this.getContext());this.platform=new(r.platform||fr(n)),this.platform.updateConfig(r);const a=this.platform.acquireContext(n,s.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;this.id=i(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=s,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new qr,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ht((t=>this.update(t)),s.resizeDelay||0),this._dataChanges=[],pn[this.id]=this,a&&l?(gt.listen(this,"complete",cn),gt.listen(this,"progress",un),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:n,_aspectRatio:o}=this;return r(t)?e&&o?o:n?i/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Gr}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ye(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ee(this.canvas,this.ctx),this}stop(){return gt.stop(this),this}resize(t,e){gt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,r=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(r,t,e,n),s=i.devicePixelRatio||this.platform.getDevicePixelRatio(),a=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,ye(this,s,!0)&&(this.notifyPlugins("resize",{size:o}),h(i.onResize,[this,o],this),this.attached&&this._doResize(a)&&this.render())}ensureScalesHaveIDs(){p(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,r=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],r=Xr(t,i),n="r"===r,o="x"===r;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),p(n,(e=>{const n=e.options,o=n.id,s=Xr(o,n),a=l(n.type,e.dtype);void 0!==n.position&&an(n.position,s)===an(e.dposition)||(n.position=e.dposition),r[o]=!0;let c=null;o in i&&i[o].type===a?c=i[o]:(c=new(Gr.getScale(a))({id:o,type:a,ctx:this.ctx,chart:this}),i[c.id]=c);c.init(n,t)})),p(r,((t,e)=>{t||delete i[e]})),p(i,(t=>{Yi.configure(this,t,t.options),Yi.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;t<i;++t)this._destroyDatasetMeta(t);t.splice(e,i-e)}this._sortedMetasets=t.slice(0).sort(ln("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,r;for(this._removeUnreferencedMetasets(),i=0,r=e.length;i<r;i++){const r=e[i];let n=this.getDatasetMeta(i);const o=r.type||this.config.type;if(n.type&&n.type!==o&&(this._destroyDatasetMeta(i),n=this.getDatasetMeta(i)),n.type=o,n.indexAxis=r.indexAxis||Wr(o,this.options),n.order=r.order||0,n.index=i,n.label=""+r.label,n.visible=this.isDatasetVisible(i),n.controller)n.controller.updateIndex(i),n.controller.linkScales();else{const e=Gr.getController(o),{datasetElementType:r,dataElementType:s}=ae.datasets[o];Object.assign(e,{dataElementType:Gr.getElement(s),datasetElementType:r&&Gr.getElement(r)}),n.controller=new e(this,i),t.push(n.controller)}}return this._updateMetasets(),t}_resetElements(){p(this.data.datasets,((t,e)=>{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t<e;t++){const{controller:e}=this.getDatasetMeta(t),i=!r&&-1===n.indexOf(e);e.buildOrUpdateElements(i),o=Math.max(+e.getMaxOverflow(),o)}o=this._minPadding=i.layout.autoPadding?o:0,this._updateLayout(o),r||p(n,(t=>{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ln("z","_idx"));const{_active:s,_lastEvent:a}=this;a?this._eventHandler(a,!0):s.length&&this._updateHoverStyles(s,s,!0),this.render()}_updateScales(){p(this.scales,(t=>{Yi.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);C(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:r,count:n}of e)fn(t,r,"_removeElements"===i?-n:n)}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),r=i(0);for(let t=1;t<e;t++)if(!C(r,i(t)))return;return Array.from(r).map((t=>t.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;Yi.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],p(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t<e;++t)this.getDatasetMeta(t).controller.configure();for(let e=0,i=this.data.datasets.length;e<i;++e)this._updateDataset(e,E(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const i=this.getDatasetMeta(t),r={meta:i,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",r)&&(i.controller._update(e),r.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",r))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(gt.has(this)?this.attached&&!gt.running(this)&&gt.start(this):(this.draw(),cn({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:t,height:e}=this._resizeBeforeDraw;this._resize(t,e),this._resizeBeforeDraw=null}if(this.clear(),this.width<=0||this.height<=0)return;if(!1===this.notifyPlugins("beforeDraw",{cancelable:!0}))return;const e=this._layers;for(t=0;t<e.length&&e[t].z<=0;++t)e[t].draw(this.chartArea);for(this._drawDatasets();t<e.length;++t)e[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const e=this._sortedMetasets,i=[];let r,n;for(r=0,n=e.length;r<n;++r){const n=e[r];t&&!n.visible||i.push(n)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1===this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0}))return;const t=this.getSortedVisibleDatasetMetas();for(let e=t.length-1;e>=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,r=!i.disabled,n=function(t){const{xScale:e,yScale:i}=t;if(e&&i)return{left:e.left,right:e.right,top:i.top,bottom:i.bottom}}(t)||this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(r&&Ae(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),r&&Ie(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(t){return ke(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,r){const n=ji.modes[e];return"function"==typeof n?n(this,t,i,r):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let r=i.filter((t=>t&&t._dataset===e)).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(r)),r}getContext(){return this.$context||(this.$context=bi(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const r=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,r);M(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?r:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),gt.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),Ee(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete pn[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,e=this.platform,i=(i,r)=>{e.addEventListener(this,i,r),t[i]=r},r=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};p(this.options.events,(t=>i(t,r)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,r)=>{e.addEventListener(this,i,r),t[i]=r},r=(i,r)=>{t[i]&&(e.removeEventListener(this,i,r),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const s=()=>{r("attach",s),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,r("resize",n),this._stop(),this._resize(0,0),i("attach",s)},e.isAttached(this.canvas)?s():o()}unbindEvents(){p(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},p(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const r=i?"set":"remove";let n,o,s,a;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+r+"DatasetHoverStyle"]()),s=0,a=t.length;s<a;++s){o=t[s];const e=o&&this.getDatasetMeta(o.datasetIndex).controller;e&&e[r+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],i=t.map((({datasetIndex:t,index:e})=>{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!d(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,i){const r=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),s=i?t:n(t,e);o.length&&this.updateHoverStyle(o,r.mode,!1),s.length&&r.mode&&this.updateHoverStyle(s,r.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},r=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,r))return;const n=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,r),(n||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:r=[],options:n}=this,o=e,s=this._getActiveElements(t,r,i,o),a=S(t),l=function(t,e,i,r){return i&&"mouseout"!==t.type?r?e:t:null}(t,this._lastEvent,i,a);i&&(this._lastEvent=null,h(n.onHover,[t,s,this],this),a&&h(n.onClick,[t,s,this],this));const c=!d(s,r);return(c||e)&&(this._active=s,this._updateHoverStyles(s,r,e)),this._lastEvent=l,c}_getActiveElements(t,e,i,r){if("mouseout"===t.type)return[];if(!i)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,r)}}function _n(){return p(mn.instances,(t=>t._plugins.invalidate()))}function gn(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class yn{static override(t){Object.assign(yn.prototype,t)}constructor(t){this.options=t||{}}init(){}formats(){return gn()}parse(){return gn()}format(){return gn()}add(){return gn()}diff(){return gn()}startOf(){return gn()}endOf(){return gn()}}var vn={_date:yn};function xn(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let r=[];for(let e=0,n=i.length;e<n;e++)r=r.concat(i[e].controller.getAllParsedValues(t));t._cache.$bar=lt(r.sort(((t,e)=>t-e)))}return t._cache.$bar}(e,t.type);let r,n,o,s,a=e._length;const l=()=>{32767!==o&&-32768!==o&&(M(s)&&(a=Math.min(a,Math.abs(o-s)||a)),s=o)};for(r=0,n=i.length;r<n;++r)o=e.getPixelForValue(i[r]),l();for(s=void 0,r=0,n=e.ticks.length;r<n;++r)o=e.getPixelForTick(r),l();return a}function bn(t,e,i,r){return n(t)?function(t,e,i,r){const n=i.parse(t[0],r),o=i.parse(t[1],r),s=Math.min(n,o),a=Math.max(n,o);let l=s,c=a;Math.abs(s)>Math.abs(a)&&(l=a,c=s),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:n,end:o,min:s,max:a}}(t,e,i,r):e[i.axis]=i.parse(t,r),e}function wn(t,e,i,r){const n=t.iScale,o=t.vScale,s=n.getLabels(),a=n===o,l=[];let c,u,h,p;for(c=i,u=i+r;c<u;++c)p=e[c],h={},h[n.axis]=a||n.parse(s[c],c),l.push(bn(p,h,o,c));return l}function Tn(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function Mn(t,e,i,r){let n=e.borderSkipped;const o={};if(!n)return void(t.borderSkipped=o);if(!0===n)return void(t.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:s,end:a,reverse:l,top:c,bottom:u}=function(t){let e,i,r,n,o;return t.horizontal?(e=t.base>t.x,i="left",r="right"):(e=t.base<t.y,i="bottom",r="top"),e?(n="end",o="start"):(n="start",o="end"),{start:i,end:r,reverse:e,top:n,bottom:o}}(t);"middle"===n&&i&&(t.enableBorderRadius=!0,(i._top||0)===r?n=c:(i._bottom||0)===r?n=u:(o[En(u,s,a,l)]=!0,n=c)),o[En(n,s,a,l)]=!0,t.borderSkipped=o}function En(t,e,i,r){var n,o,s;return r?(s=i,t=Cn(t=(n=t)===(o=e)?s:n===s?o:n,i,e)):t=Cn(t,e,i),t}function Cn(t,e,i){return"start"===t?e:"end"===t?i:t}function Sn(t,{inflateAmount:e},i){t.inflateAmount="auto"===e?1===i?.33:0:e}class kn extends Pr{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>"spacing"!==t,_indexable:t=>"spacing"!==t};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:r}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:r,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,r=this._cachedMeta;if(!1===this._parsing)r._parsed=i;else{let n,s,a=t=>+i[t];if(o(i[t])){const{key:t="value"}=this._parsing;a=e=>+w(i[e],t)}for(n=t,s=t+e;n<s;++n)r._parsed[n]=a(n)}}_getRotation(){return G(this.options.rotation-90)}_getCircumference(){return G(this.options.circumference)}_getRotationExtents(){let t=A,e=-A;for(let i=0;i<this.chart.data.datasets.length;++i)if(this.chart.isDatasetVisible(i)&&this.chart.getDatasetMeta(i).type===this._type){const r=this.chart.getDatasetMeta(i).controller,n=r._getRotation(),o=r._getCircumference();t=Math.min(t,n),e=Math.max(e,n+o)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:i}=e,r=this._cachedMeta,n=r.data,o=this.getMaxBorderWidth()+this.getMaxOffset(n)+this.options.spacing,s=Math.max((Math.min(i.width,i.height)-o)/2,0),a=Math.min(c(this.options.cutout,s),1),l=this._getRingWeight(this.index),{circumference:h,rotation:p}=this._getRotationExtents(),{ratioX:d,ratioY:f,offsetX:m,offsetY:_}=function(t,e,i){let r=1,n=1,o=0,s=0;if(e<A){const a=t,l=a+e,c=Math.cos(a),u=Math.sin(a),h=Math.cos(l),p=Math.sin(l),d=(t,e,r)=>Y(t,a,l,!0)?1:Math.max(e,e*i,r,r*i),f=(t,e,r)=>Y(t,a,l,!0)?-1:Math.min(e,e*i,r,r*i),m=d(0,c,h),_=d(z,u,p),g=f(k,c,h),y=f(k+z,u,p);r=(m-g)/2,n=(_-y)/2,o=-(m+g)/2,s=-(_+y)/2}return{ratioX:r,ratioY:n,offsetX:o,offsetY:s}}(p,h,a),g=(i.width-o)/d,y=(i.height-o)/f,v=Math.max(Math.min(g,y)/2,0),x=u(this.options.radius,v),b=(x-Math.max(x*a,0))/this._getVisibleDatasetWeightTotal();this.offsetX=m*x,this.offsetY=_*x,r.total=this.calculateTotal(),this.outerRadius=x-b*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-b*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,r=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===r._parsed[t]||r.data[t].hidden?0:this.calculateCircumference(r._parsed[t]*n/A)}updateElements(t,e,i,r){const n="reset"===r,o=this.chart,s=o.chartArea,a=o.options.animation,l=(s.left+s.right)/2,c=(s.top+s.bottom)/2,u=n&&a.animateScale,h=u?0:this.innerRadius,p=u?0:this.outerRadius,{sharedOptions:d,includeOptions:f}=this._getSharedOptions(e,r);let m,_=this._getRotation();for(m=0;m<e;++m)_+=this._circumference(m,n);for(m=e;m<e+i;++m){const e=this._circumference(m,n),i=t[m],o={x:l+this.offsetX,y:c+this.offsetY,startAngle:_,endAngle:_+e,circumference:e,outerRadius:p,innerRadius:h};f&&(o.options=d||this.resolveDataElementOptions(m,i.active?"active":r)),_+=e,this.updateElement(i,m,o,r)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let i,r=0;for(i=0;i<e.length;i++){const n=t._parsed[i];null===n||isNaN(n)||!this.chart.getDataVisibility(i)||e[i].hidden||(r+=Math.abs(n))}return r}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?A*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,r=i.data.labels||[],n=te(e._parsed[t],i.options.locale);return{label:r[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let r,n,o,s,a;if(!t)for(r=0,n=i.data.datasets.length;r<n;++r)if(i.isDatasetVisible(r)){o=i.getDatasetMeta(r),t=o.data,s=o.controller;break}if(!t)return 0;for(r=0,n=t.length;r<n;++r)a=s.resolveDataElementOptions(r),"inner"!==a.borderAlign&&(e=Math.max(e,a.borderWidth||0,a.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let i=0,r=t.length;i<r;++i){const t=this.resolveDataElementOptions(i);e=Math.max(e,t.offset||0,t.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let i=0;i<t;++i)this.chart.isDatasetVisible(i)&&(e+=this._getRingWeight(i));return e}_getRingWeight(t){return Math.max(l(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class An extends Pr{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:r}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:r,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,r=i.data.labels||[],n=te(e._parsed[t].r,i.options.locale);return{label:r[t]||"",value:n}}parseObjectData(t,e,i,r){return Qe.bind(this)(t,e,i,r)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach(((t,i)=>{const r=this.getParsed(i).r;!isNaN(r)&&this.chart.getDataVisibility(i)&&(r<e.min&&(e.min=r),r>e.max&&(e.max=r))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,r=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(r/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,r){const n="reset"===r,o=this.chart,s=o.options.animation,a=this._cachedMeta.rScale,l=a.xCenter,c=a.yCenter,u=a.getIndexAngle(0)-.5*k;let h,p=u;const d=360/this.countVisibleElements();for(h=0;h<e;++h)p+=this._computeAngle(h,r,d);for(h=e;h<e+i;h++){const e=t[h];let i=p,f=p+this._computeAngle(h,r,d),m=o.getDataVisibility(h)?a.getDistanceFromCenterForValue(this.getParsed(h).r):0;p=f,n&&(s.animateScale&&(m=0),s.animateRotate&&(i=f=u));const _={x:l,y:c,innerRadius:0,outerRadius:m,startAngle:i,endAngle:f,options:this.resolveDataElementOptions(h,e.active?"active":r)};this.updateElement(e,h,_,r)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach(((t,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++})),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?G(this.resolveDataElementOptions(t,e).angle||i):0}}var In=Object.freeze({__proto__:null,BarController:class extends Pr{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,i,r){return wn(t,e,i,r)}parseArrayData(t,e,i,r){return wn(t,e,i,r)}parseObjectData(t,e,i,r){const{iScale:n,vScale:o}=t,{xAxisKey:s="x",yAxisKey:a="y"}=this._parsing,l="x"===n.axis?s:a,c="x"===o.axis?s:a,u=[];let h,p,d,f;for(h=i,p=i+r;h<p;++h)f=e[h],d={},d[n.axis]=n.parse(w(f,l),h),u.push(bn(w(f,c),d,o,h));return u}updateRangeFromParsed(t,e,i,r){super.updateRangeFromParsed(t,e,i,r);const n=i._custom;n&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,n.min),t.max=Math.max(t.max,n.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:i,vScale:r}=e,n=this.getParsed(t),o=n._custom,s=Tn(o)?"["+o.start+", "+o.end+"]":""+r.getLabelForValue(n[r.axis]);return{label:""+i.getLabelForValue(n[i.axis]),value:s}}initialize(){this.enableOptionSharing=!0,super.initialize();this._cachedMeta.stack=this.getDataset().stack}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,i,n){const o="reset"===n,{index:s,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),u=this._getRuler(),{sharedOptions:h,includeOptions:p}=this._getSharedOptions(e,n);for(let d=e;d<e+i;d++){const e=this.getParsed(d),i=o||r(e[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(d),f=this._calculateBarIndexPixels(d,u),m=(e._stacks||{})[a.axis],_={horizontal:c,base:i.base,enableBorderRadius:!m||Tn(e._custom)||s===m._top||s===m._bottom,x:c?i.head:f.center,y:c?f.center:i.head,height:c?f.size:Math.abs(i.size),width:c?Math.abs(i.size):f.size};p&&(_.options=h||this.resolveDataElementOptions(d,t[d].active?"active":n));const g=_.options||t[d].options;Mn(_,g,m,s),Sn(_,g,u.ratio),this.updateElement(t[d],d,_,n)}}_getStacks(t,e){const{iScale:i}=this._cachedMeta,n=i.getMatchingVisibleMetas(this._type).filter((t=>t.controller.options.grouped)),o=i.options.stacked,s=[],a=t=>{const i=t.controller.getParsed(e),n=i&&i[t.vScale.axis];if(r(n)||isNaN(n))return!0};for(const i of n)if((void 0===e||!a(i))&&((!1===o||-1===s.indexOf(i.stack)||void 0===o&&void 0===i.stack)&&s.push(i.stack),i.index===t))break;return s.length||s.push(void 0),s}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const r=this._getStacks(t,i),n=void 0!==e?r.indexOf(e):-1;return-1===n?r.length-1:n}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,r=[];let n,o;for(n=0,o=e.data.length;n<o;++n)r.push(i.getPixelForValue(this.getParsed(n)[i.axis],n));const s=t.barThickness;return{min:s||xn(e),pixels:r,start:i._startPixel,end:i._endPixel,stackCount:this._getStackCount(),scale:i,grouped:t.grouped,ratio:s?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:i,index:n},options:{base:o,minBarLength:s}}=this,a=o||0,l=this.getParsed(t),c=l._custom,u=Tn(c);let h,p,d=l[e.axis],f=0,m=i?this.applyStack(e,l,i):d;m!==d&&(f=m-d,m=d),u&&(d=c.barStart,m=c.barEnd-c.barStart,0!==d&&F(d)!==F(c.barEnd)&&(f=0),f+=d);const _=r(o)||u?f:o;let g=e.getPixelForValue(_);if(h=this.chart.getDataVisibility(t)?e.getPixelForValue(f+m):g,p=h-g,Math.abs(p)<s){p=function(t,e,i){return 0!==t?F(t):(e.isHorizontal()?1:-1)*(e.min>=i?1:-1)}(p,e,a)*s,d===a&&(g-=p/2);const t=e.getPixelForDecimal(0),r=e.getPixelForDecimal(1),o=Math.min(t,r),c=Math.max(t,r);g=Math.max(Math.min(g,c),o),h=g+p,i&&!u&&(l._stacks[e.axis]._visualValues[n]=e.getValueForPixel(h)-e.getValueForPixel(g))}if(g===e.getPixelForValue(a)){const t=F(p)*e.getLineWidthForValue(a)/2;g+=t,p-=t}return{size:p,base:g,head:h,center:h+p/2}}_calculateBarIndexPixels(t,e){const i=e.scale,n=this.options,o=n.skipNull,s=l(n.maxBarThickness,1/0);let a,c;if(e.grouped){const i=o?this._getStackCount(t):e.stackCount,l="flex"===n.barThickness?function(t,e,i,r){const n=e.pixels,o=n[t];let s=t>0?n[t-1]:null,a=t<n.length-1?n[t+1]:null;const l=i.categoryPercentage;null===s&&(s=o-(null===a?e.end-e.start:a-o)),null===a&&(a=o+o-s);const c=o-(o-Math.min(s,a))/2*l;return{chunk:Math.abs(a-s)/2*l/r,ratio:i.barPercentage,start:c}}(t,e,n,i):function(t,e,i,n){const o=i.barThickness;let s,a;return r(o)?(s=e.min*i.categoryPercentage,a=i.barPercentage):(s=o*n,a=1),{chunk:s/n,ratio:a,start:e.pixels[t]-s/2}}(t,e,n,i),u=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0);a=l.start+l.chunk*u+l.chunk/2,c=Math.min(s,l.chunk*l.ratio)}else a=i.getPixelForValue(this.getParsed(t)[i.axis],t),c=Math.min(s,e.min*e.ratio);return{base:a-c/2,head:a+c/2,center:a,size:c}}draw(){const t=this._cachedMeta,e=t.vScale,i=t.data,r=i.length;let n=0;for(;n<r;++n)null!==this.getParsed(n)[e.axis]&&i[n].draw(this._ctx)}},BubbleController:class extends Pr{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,i,r){const n=super.parsePrimitiveData(t,e,i,r);for(let t=0;t<n.length;t++)n[t]._custom=this.resolveDataElementOptions(t+i).radius;return n}parseArrayData(t,e,i,r){const n=super.parseArrayData(t,e,i,r);for(let t=0;t<n.length;t++){const r=e[i+t];n[t]._custom=l(r[2],this.resolveDataElementOptions(t+i).radius)}return n}parseObjectData(t,e,i,r){const n=super.parseObjectData(t,e,i,r);for(let t=0;t<n.length;t++){const r=e[i+t];n[t]._custom=l(r&&r.r&&+r.r,this.resolveDataElementOptions(t+i).radius)}return n}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let i=t.length-1;i>=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:r,yScale:n}=e,o=this.getParsed(t),s=r.getLabelForValue(o.x),a=n.getLabelForValue(o.y),l=o._custom;return{label:i[t]||"",value:"("+s+", "+a+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,r){const n="reset"===r,{iScale:o,vScale:s}=this._cachedMeta,{sharedOptions:a,includeOptions:l}=this._getSharedOptions(e,r),c=o.axis,u=s.axis;for(let h=e;h<e+i;h++){const e=t[h],i=!n&&this.getParsed(h),p={},d=p[c]=n?o.getPixelForDecimal(.5):o.getPixelForValue(i[c]),f=p[u]=n?s.getBasePixel():s.getPixelForValue(i[u]);p.skip=isNaN(d)||isNaN(f),l&&(p.options=a||this.resolveDataElementOptions(h,e.active?"active":r),n&&(p.options.radius=0)),this.updateElement(e,h,p,r)}}resolveDataElementOptions(t,e){const i=this.getParsed(t);let r=super.resolveDataElementOptions(t,e);r.$shared&&(r=Object.assign({},r,{$shared:!1}));const n=r.radius;return"active"!==e&&(r.radius=0),r.radius+=l(i&&i._custom,n),r}},DoughnutController:kn,LineController:class extends Pr{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:r=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:s,count:a}=mt(e,r,o);this._drawStart=s,this._drawCount=a,_t(e)&&(s=0,a=r.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=r;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(r,s,a,t)}updateElements(t,e,i,n){const o="reset"===n,{iScale:s,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(e,n),p=s.axis,d=a.axis,{spanGaps:f,segment:m}=this.options,_=V(f)?f:Number.POSITIVE_INFINITY,g=this.chart._animationsDisabled||o||"none"===n,y=e+i,v=t.length;let x=e>0&&this.getParsed(e-1);for(let i=0;i<v;++i){const f=t[i],v=g?f:{};if(i<e||i>=y){v.skip=!0;continue}const b=this.getParsed(i),w=r(b[d]),T=v[p]=s.getPixelForValue(b[p],i),M=v[d]=o||w?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,b,l):b[d],i);v.skip=isNaN(T)||isNaN(M)||w,v.stop=i>0&&Math.abs(b[p]-x[p])>_,m&&(v.parsed=b,v.raw=c.data[i]),h&&(v.options=u||this.resolveDataElementOptions(i,f.active?"active":n)),g||this.updateElement(f,i,v,n),x=b}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,r=t.data||[];if(!r.length)return i;const n=r[0].size(this.resolveDataElementOptions(0)),o=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},PolarAreaController:An,PieController:class extends kn{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},RadarController:class extends Pr{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,r){return Qe.bind(this)(t,e,i,r)}update(t){const e=this._cachedMeta,i=e.dataset,r=e.data||[],n=e.iScale.getLabels();if(i.points=r,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===r.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(r,0,r.length,t)}updateElements(t,e,i,r){const n=this._cachedMeta.rScale,o="reset"===r;for(let s=e;s<e+i;s++){const e=t[s],i=this.resolveDataElementOptions(s,e.active?"active":r),a=n.getPointPositionForValue(s,this.getParsed(s).r),l=o?n.xCenter:a.x,c=o?n.yCenter:a.y,u={x:l,y:c,angle:a.angle,skip:isNaN(l)||isNaN(c),options:i};this.updateElement(e,s,u,r)}}},ScatterController:class extends Pr{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:r,yScale:n}=e,o=this.getParsed(t),s=r.getLabelForValue(o.x),a=n.getLabelForValue(o.y);return{label:i[t]||"",value:"("+s+", "+a+")"}}update(t){const e=this._cachedMeta,{data:i=[]}=e,r=this.chart._animationsDisabled;let{start:n,count:o}=mt(e,i,r);if(this._drawStart=n,this._drawCount=o,_t(e)&&(n=0,o=i.length),this.options.showLine){const{dataset:n,_dataset:o}=e;n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;const s=this.resolveDatasetElementOptions(t);s.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:s},t)}this.updateElements(i,n,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,i,n){const o="reset"===n,{iScale:s,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,u=this.resolveDataElementOptions(e,n),h=this.getSharedOptions(u),p=this.includeOptions(n,h),d=s.axis,f=a.axis,{spanGaps:m,segment:_}=this.options,g=V(m)?m:Number.POSITIVE_INFINITY,y=this.chart._animationsDisabled||o||"none"===n;let v=e>0&&this.getParsed(e-1);for(let u=e;u<e+i;++u){const e=t[u],i=this.getParsed(u),m=y?e:{},x=r(i[f]),b=m[d]=s.getPixelForValue(i[d],u),w=m[f]=o||x?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,i,l):i[f],u);m.skip=isNaN(b)||isNaN(w)||x,m.stop=u>0&&Math.abs(i[d]-v[d])>g,_&&(m.parsed=i,m.raw=c.data[u]),p&&(m.options=h||this.resolveDataElementOptions(u,e.active?"active":n)),y||this.updateElement(e,u,m,n),v=i}this.updateSharedOptions(h,n,u)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let i=e.length-1;i>=0;--i)t=Math.max(t,e[i].size(this.resolveDataElementOptions(i))/2);return t>0&&t}const i=t.dataset,r=i.options&&i.options.borderWidth||0;if(!e.length)return r;const n=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(r,n,o)/2}}});function Pn(t,e,i,r){return{x:i+t*Math.cos(e),y:r+t*Math.sin(e)}}function Ln(t,e,i,r,n,o){const{x:s,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=e,h=Math.max(e.outerRadius+r+i-c,0),p=u>0?u+r+i+c:0;let d=0;const f=n-l;if(r){const t=((u>0?u-r:0)+(h>0?h-r:0))/2;d=(f-(0!==t?f*t/(t+r):f))/2}const m=(f-Math.max(.001,f*h-i/k)/h)/2,_=l+m+d,g=n-m-d,{outerStart:y,outerEnd:v,innerStart:x,innerEnd:b}=function(t,e,i,r){const n=fi(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(i-e)/2,s=Math.min(o,r*e/2),a=t=>{const e=(i-Math.min(o,t))*r/2;return J(t,0,Math.min(o,e))};return{outerStart:a(n.outerStart),outerEnd:a(n.outerEnd),innerStart:J(n.innerStart,0,s),innerEnd:J(n.innerEnd,0,s)}}(e,p,h,g-_),w=h-y,T=h-v,M=_+y/w,E=g-v/T,C=p+x,S=p+b,A=_+x/C,I=g-b/S;if(t.beginPath(),o){const e=(M+E)/2;if(t.arc(s,a,h,M,e),t.arc(s,a,h,e,E),v>0){const e=Pn(T,E,s,a);t.arc(e.x,e.y,v,E,g+z)}const i=Pn(S,g,s,a);if(t.lineTo(i.x,i.y),b>0){const e=Pn(S,I,s,a);t.arc(e.x,e.y,b,g+z,I+Math.PI)}const r=(g-b/p+(_+x/p))/2;if(t.arc(s,a,p,g-b/p,r,!0),t.arc(s,a,p,r,_+x/p,!0),x>0){const e=Pn(C,A,s,a);t.arc(e.x,e.y,x,A+Math.PI,_-z)}const n=Pn(w,_,s,a);if(t.lineTo(n.x,n.y),y>0){const e=Pn(w,M,s,a);t.arc(e.x,e.y,y,_-z,M)}}else{t.moveTo(s,a);const e=Math.cos(M)*h+s,i=Math.sin(M)*h+a;t.lineTo(e,i);const r=Math.cos(E)*h+s,n=Math.sin(E)*h+a;t.lineTo(r,n)}t.closePath()}function zn(t,e,i=e){t.lineCap=l(i.borderCapStyle,e.borderCapStyle),t.setLineDash(l(i.borderDash,e.borderDash)),t.lineDashOffset=l(i.borderDashOffset,e.borderDashOffset),t.lineJoin=l(i.borderJoinStyle,e.borderJoinStyle),t.lineWidth=l(i.borderWidth,e.borderWidth),t.strokeStyle=l(i.borderColor,e.borderColor)}function Dn(t,e,i){t.lineTo(i.x,i.y)}function Rn(t,e,i={}){const r=t.length,{start:n=0,end:o=r-1}=i,{start:s,end:a}=e,l=Math.max(n,s),c=Math.min(o,a),u=n<s&&o<s||n>a&&o>a;return{count:r,start:l,loop:e.loop,ilen:c<l&&!u?r+c-l:c-l}}function On(t,e,i,r){const{points:n,options:o}=e,{count:s,start:a,loop:l,ilen:c}=Rn(n,i,r),u=function(t){return t.stepped?Pe:t.tension||"monotone"===t.cubicInterpolationMode?Le:Dn}(o);let h,p,d,{move:f=!0,reverse:m}=r||{};for(h=0;h<=c;++h)p=n[(a+(m?c-h:h))%s],p.skip||(f?(t.moveTo(p.x,p.y),f=!1):u(t,d,p,m,o.stepped),d=p);return l&&(p=n[(a+(m?c:0))%s],u(t,d,p,m,o.stepped)),!!l}function Fn(t,e,i,r){const n=e.points,{count:o,start:s,ilen:a}=Rn(n,i,r),{move:l=!0,reverse:c}=r||{};let u,h,p,d,f,m,_=0,g=0;const y=t=>(s+(c?a-t:t))%o,v=()=>{d!==f&&(t.lineTo(_,f),t.lineTo(_,d),t.lineTo(_,m))};for(l&&(h=n[y(0)],t.moveTo(h.x,h.y)),u=0;u<=a;++u){if(h=n[y(u)],h.skip)continue;const e=h.x,i=h.y,r=0|e;r===p?(i<d?d=i:i>f&&(f=i),_=(g*_+e)/++g):(v(),t.lineTo(e,i),p=r,g=0,d=f=i),m=i}v()}function Bn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i?On:Fn}const jn="function"==typeof Path2D;class Nn extends Lr{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const r=i.spanGaps?this._loop:this._fullLoop;ri(this._points,i,t,r,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Ai(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,r=t[e],n=this.points,o=ki(this,{property:e,start:r,end:r});if(!o.length)return;const s=[],a=function(t){return t.stepped?ci:t.tension||"monotone"===t.cubicInterpolationMode?ui:li}(i);let l,c;for(l=0,c=o.length;l<c;++l){const{start:c,end:u}=o[l],h=n[c],p=n[u];if(h===p){s.push(h);continue}const d=a(h,p,Math.abs((r-h[e])/(p[e]-h[e])),i.stepped);d[e]=t[e],s.push(d)}return 1===s.length?s[0]:s}pathSegment(t,e,i){return Bn(this)(t,this,e,i)}path(t,e,i){const r=this.segments,n=Bn(this);let o=this._loop;e=e||0,i=i||this.points.length-e;for(const s of r)o&=n(t,this,s,{start:e,end:e+i-1});return!!o}draw(t,e,i,r){const n=this.options||{};(this.points||[]).length&&n.borderWidth&&(t.save(),function(t,e,i,r){jn&&!e.options.segment?function(t,e,i,r){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,r)&&n.closePath()),zn(t,e.options),t.stroke(n)}(t,e,i,r):function(t,e,i,r){const{segments:n,options:o}=e,s=Bn(e);for(const a of n)zn(t,o,a.style),t.beginPath(),s(t,e,a,{start:i,end:i+r-1})&&t.closePath(),t.stroke()}(t,e,i,r)}(t,this,i,r),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function Vn(t,e,i,r){const n=t.options,{[i]:o}=t.getProps([i],r);return Math.abs(e-o)<n.radius+n.hitRadius}function Un(t,e){const{x:i,y:r,base:n,width:o,height:s}=t.getProps(["x","y","base","width","height"],e);let a,l,c,u,h;return t.horizontal?(h=s/2,a=Math.min(i,n),l=Math.max(i,n),c=r-h,u=r+h):(h=o/2,a=i-h,l=i+h,c=Math.min(r,n),u=Math.max(r,n)),{left:a,top:c,right:l,bottom:u}}function $n(t,e,i,r){return t?0:J(e,i,r)}function Gn(t){const e=Un(t),i=e.right-e.left,r=e.bottom-e.top,n=function(t,e,i){const r=t.options.borderWidth,n=t.borderSkipped,o=mi(r);return{t:$n(n.top,o.top,0,i),r:$n(n.right,o.right,0,e),b:$n(n.bottom,o.bottom,0,i),l:$n(n.left,o.left,0,e)}}(t,i/2,r/2),s=function(t,e,i){const{enableBorderRadius:r}=t.getProps(["enableBorderRadius"]),n=t.options.borderRadius,s=_i(n),a=Math.min(e,i),l=t.borderSkipped,c=r||o(n);return{topLeft:$n(!c||l.top||l.left,s.topLeft,0,a),topRight:$n(!c||l.top||l.right,s.topRight,0,a),bottomLeft:$n(!c||l.bottom||l.left,s.bottomLeft,0,a),bottomRight:$n(!c||l.bottom||l.right,s.bottomRight,0,a)}}(t,i/2,r/2);return{outer:{x:e.left,y:e.top,w:i,h:r,radius:s},inner:{x:e.left+n.l,y:e.top+n.t,w:i-n.l-n.r,h:r-n.t-n.b,radius:{topLeft:Math.max(0,s.topLeft-Math.max(n.t,n.l)),topRight:Math.max(0,s.topRight-Math.max(n.t,n.r)),bottomLeft:Math.max(0,s.bottomLeft-Math.max(n.b,n.l)),bottomRight:Math.max(0,s.bottomRight-Math.max(n.b,n.r))}}}}function qn(t,e,i,r){const n=null===e,o=null===i,s=t&&!(n&&o)&&Un(t,r);return s&&(n||tt(e,s.left,s.right))&&(o||tt(i,s.top,s.bottom))}function Zn(t,e){t.rect(e.x,e.y,e.w,e.h)}function Hn(t,e,i={}){const r=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-r,s=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+r,y:t.y+n,w:t.w+o,h:t.h+s,radius:t.radius}}var Wn=Object.freeze({__proto__:null,ArcElement:class extends Lr{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0};static defaultRoutes={backgroundColor:"backgroundColor"};constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,i){const r=this.getProps(["x","y"],i),{angle:n,distance:o}=H(r,{x:t,y:e}),{startAngle:s,endAngle:a,innerRadius:c,outerRadius:u,circumference:h}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),p=this.options.spacing/2,d=l(h,a-s)>=A||Y(n,s,a),f=tt(o,c+p,u+p);return d&&f}getCenterPoint(t){const{x:e,y:i,startAngle:r,endAngle:n,innerRadius:o,outerRadius:s}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:a,spacing:l}=this.options,c=(r+n)/2,u=(o+s+l+a)/2;return{x:e+Math.cos(c)*u,y:i+Math.sin(c)*u}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,r=(e.offset||0)/4,n=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>A?Math.floor(i/A):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();const s=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(s)*r,Math.sin(s)*r);const a=r*(1-Math.sin(Math.min(k,i||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,i,r,n){const{fullCircles:o,startAngle:s,circumference:a}=e;let l=e.endAngle;if(o){Ln(t,e,i,r,l,n);for(let e=0;e<o;++e)t.fill();isNaN(a)||(l=s+(a%A||A))}Ln(t,e,i,r,l,n),t.fill()}(t,this,a,n,o),function(t,e,i,r,n){const{fullCircles:o,startAngle:s,circumference:a,options:l}=e,{borderWidth:c,borderJoinStyle:u}=l,h="inner"===l.borderAlign;if(!c)return;h?(t.lineWidth=2*c,t.lineJoin=u||"round"):(t.lineWidth=c,t.lineJoin=u||"bevel");let p=e.endAngle;if(o){Ln(t,e,i,r,p,n);for(let e=0;e<o;++e)t.stroke();isNaN(a)||(p=s+(a%A||A))}h&&function(t,e,i){const{startAngle:r,pixelMargin:n,x:o,y:s,outerRadius:a,innerRadius:l}=e;let c=n/a;t.beginPath(),t.arc(o,s,a,r-c,i+c),l>n?(c=n/l,t.arc(o,s,l,i+c,r-c,!0)):t.arc(o,s,n,i+z,r-z),t.closePath(),t.clip()}(t,e,p),o||(Ln(t,e,i,r,p,n),t.stroke())}(t,this,a,n,o),t.restore()}},LineElement:Nn,PointElement:class extends Lr{static id="point";static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const r=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)<Math.pow(r.hitRadius+r.radius,2)}inXRange(t,e){return Vn(this,t,"x",e)}inYRange(t,e){return Vn(this,t,"y",e)}getCenterPoint(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}size(t){let e=(t=t||this.options||{}).radius||0;e=Math.max(e,e&&t.hoverRadius||0);return 2*(e+(e&&t.borderWidth||0))}draw(t,e){const i=this.options;this.skip||i.radius<.1||!ke(this,e,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,Ce(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}},BarElement:class extends Lr{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:r}}=this,{inner:n,outer:o}=Gn(this),s=(a=o.radius).topLeft||a.topRight||a.bottomLeft||a.bottomRight?Oe:Zn;var a;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),s(t,Hn(o,e,n)),t.clip(),s(t,Hn(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),s(t,Hn(n,e)),t.fillStyle=r,t.fill(),t.restore()}inRange(t,e,i){return qn(this,t,e,i)}inXRange(t,e){return qn(this,t,null,e)}inYRange(t,e){return qn(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:r,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+r)/2:e,y:n?i:(i+r)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}});function Xn(t){const e=this.getLabels();return t>=0&&t<e.length?e[t]:t}function Qn(t,e,{horizontal:i,minRotation:r}){const n=G(r),o=(i?Math.sin(n):Math.cos(n))||.001,s=.75*e*(""+t).length;return Math.min(e/o,s)}class Yn extends Ur{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return r(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:r,max:n}=this;const o=t=>r=e?r:t,s=t=>n=i?n:t;if(t){const t=F(r),e=F(n);t<0&&e<0?s(0):t>0&&e>0&&o(0)}if(r===n){let e=0===n?1:Math.abs(.05*n);s(n+e),t||o(r-e)}this.min=r,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:r}=t;return r?(e=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const n=function(t,e){const i=[],{bounds:n,step:o,min:s,max:a,precision:l,count:c,maxTicks:u,maxDigits:h,includeBounds:p}=t,d=o||1,f=u-1,{min:m,max:_}=e,g=!r(s),y=!r(a),v=!r(c),x=(_-m)/(h+1);let b,w,T,M,E=j((_-m)/f/d)*d;if(E<1e-14&&!g&&!y)return[{value:m},{value:_}];M=Math.ceil(_/E)-Math.floor(m/E),M>f&&(E=j(M*E/f/d)*d),r(l)||(b=Math.pow(10,l),E=Math.ceil(E*b)/b),"ticks"===n?(w=Math.floor(m/E)*E,T=Math.ceil(_/E)*E):(w=m,T=_),g&&y&&o&&U((a-s)/o,E/1e3)?(M=Math.round(Math.min((a-s)/E,u)),E=(a-s)/M,w=s,T=a):v?(w=g?s:w,T=y?a:T,M=c-1,E=(T-w)/M):(M=(T-w)/E,M=B(M,Math.round(M),E/1e3)?Math.round(M):Math.ceil(M));const C=Math.max(Z(E),Z(w));b=Math.pow(10,r(l)?C:l),w=Math.round(w*b)/b,T=Math.round(T*b)/b;let S=0;for(g&&(p&&w!==s?(i.push({value:s}),w<s&&S++,B(Math.round((w+S*E)*b)/b,s,Qn(s,x,t))&&S++):w<s&&S++);S<M;++S)i.push({value:Math.round((w+S*E)*b)/b});return y&&p&&T!==a?i.length&&B(i[i.length-1].value,a,Qn(a,x,t))?i[i.length-1].value=a:i.push({value:a}):y&&T!==a||i.push({value:T}),i}({maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&$(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const r=(i-e)/Math.max(t.length-1,1)/2;e-=r,i+=r}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return te(t,this.chart.options.locale,this.options.ticks.format)}}class Jn extends Yn{static id="linear";static defaults={ticks:{callback:ie.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=s(t)?t:0,this.max=s(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=G(this.options.ticks.minRotation),r=(t?Math.sin(i):Math.cos(i))||.001,n=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,n.lineHeight/r))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Kn=t=>Math.floor(O(t)),to=(t,e)=>Math.pow(10,Kn(t)+e);function eo(t){return 1==t/Math.pow(10,Kn(t))}function io(t,e,i){const r=Math.pow(10,i),n=Math.floor(t/r);return Math.ceil(e/r)-n}class ro extends Ur{static id="logarithmic";static defaults={ticks:{callback:ie.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=Yn.prototype.parse.apply(this,[t,e]);if(0!==i)return s(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=s(t)?Math.max(0,t):null,this.max=s(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!s(this._userMin)&&(this.min=t===to(this.min,0)?to(this.min,-1):to(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,r=this.max;const n=e=>i=t?i:e,o=t=>r=e?r:t;i===r&&(i<=0?(n(1),o(10)):(n(to(i,-1)),o(to(r,1)))),i<=0&&n(to(r,-1)),r<=0&&o(to(i,1)),this.min=i,this.max=r}buildTicks(){const t=this.options,e=function(t,{min:e,max:i}){e=a(t.min,e);const r=[],n=Kn(e);let o=function(t,e){let i=Kn(e-t);for(;io(t,e,i)>10;)i++;for(;io(t,e,i)<10;)i--;return Math.min(i,Kn(t))}(e,i),s=o<0?Math.pow(10,Math.abs(o)):1;const l=Math.pow(10,o),c=n>o?Math.pow(10,n):0,u=Math.round((e-c)*s)/s,h=Math.floor((e-c)/l/10)*l*10;let p=Math.floor((u-h)/Math.pow(10,o)),d=a(t.min,Math.round((c+h+p*Math.pow(10,o))*s)/s);for(;d<i;)r.push({value:d,major:eo(d),significand:p}),p>=10?p=p<15?15:20:p++,p>=20&&(o++,p=2,s=o>=0?1:s),d=Math.round((c+h+p*Math.pow(10,o))*s)/s;const f=a(t.max,d);return r.push({value:f,major:eo(f),significand:p}),r}({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&$(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":te(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=O(t),this._valueRange=O(this.max)-O(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(O(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function no(t){const e=t.ticks;if(e.display&&t.display){const t=gi(e.backdropPadding);return l(e.font&&e.font.size,ae.font.size)+t.height}return 0}function oo(t,e,i,r,n){return t===r||t===n?{start:e-i/2,end:e+i/2}:t<r||t>n?{start:e-i,end:e}:{start:e,end:e+i}}function so(t,e,i,r,n){const o=Math.abs(Math.sin(i)),s=Math.abs(Math.cos(i));let a=0,l=0;r.start<e.l?(a=(e.l-r.start)/o,t.l=Math.min(t.l,e.l-a)):r.end>e.r&&(a=(r.end-e.r)/o,t.r=Math.max(t.r,e.r+a)),n.start<e.t?(l=(e.t-n.start)/s,t.t=Math.min(t.t,e.t-l)):n.end>e.b&&(l=(n.end-e.b)/s,t.b=Math.max(t.b,e.b+l))}function ao(t){return 0===t||180===t?"center":t<180?"left":"right"}function lo(t,e,i){return"right"===i?t-=e:"center"===i&&(t-=e/2),t}function co(t,e,i){return 90===i||270===i?t-=e/2:(i>270||i<90)&&(t-=e),t}function uo(t,e,i,r){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,A);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o<r;o++)i=t.getPointPosition(o,e),n.lineTo(i.x,i.y)}}class ho extends Yn{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:ie.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=gi(no(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=s(t)&&!isNaN(t)?t:0,this.max=s(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/no(this.options))}generateTickLabels(t){Yn.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const i=h(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?function(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},i=Object.assign({},e),r=[],o=[],s=t._pointLabels.length,a=t.options.pointLabels,l=a.centerPointLabels?k/s:0;for(let p=0;p<s;p++){const s=a.setContext(t.getPointLabelContext(p));o[p]=s.padding;const d=t.getPointPosition(p,t.drawingArea+o[p],l),f=yi(s.font),m=(c=t.ctx,u=f,h=n(h=t._pointLabels[p])?h:[h],{w:Te(c,u.string,h),h:h.length*u.lineHeight});r[p]=m;const _=Q(t.getIndexAngle(p)+l),g=Math.round(q(_));so(i,e,_,oo(g,d.x,m.w,0,180),oo(g,d.y,m.h,90,270))}var c,u,h;t.setCenterPoint(e.l-i.l,i.r-e.r,e.t-i.t,i.b-e.b),t._pointLabelItems=function(t,e,i){const r=[],n=t._pointLabels.length,o=t.options,s=no(o)/2,a=t.drawingArea,l=o.pointLabels.centerPointLabels?k/n:0;for(let o=0;o<n;o++){const n=t.getPointPosition(o,a+s+i[o],l),c=Math.round(q(Q(n.angle+z))),u=e[o],h=co(n.y,u.h,c),p=ao(c),d=lo(n.x,u.w,p);r.push({x:n.x,y:h,textAlign:p,left:d,top:h,right:d+u.w,bottom:h+u.h})}return r}(t,r,o)}(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,r){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,r))}getIndexAngle(t){return Q(t*(A/(this._pointLabels.length||1))+G(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(r(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(r(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t<e.length){const i=e[t];return function(t,e,i){return bi(t,{label:i,index:e,type:"pointLabel"})}(this.getContext(),t,i)}}getPointPosition(t,e,i=0){const r=this.getIndexAngle(t)-z+i;return{x:Math.cos(r)*e+this.xCenter,y:Math.sin(r)*e+this.yCenter,angle:r}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:e,top:i,right:r,bottom:n}=this._pointLabelItems[t];return{left:e,top:i,right:r,bottom:n}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const i=this.ctx;i.save(),i.beginPath(),uo(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),i.closePath(),i.fillStyle=t,i.fill(),i.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:i,grid:n,border:o}=e,s=this._pointLabels.length;let a,l,c;if(e.pointLabels.display&&function(t,e){const{ctx:i,options:{pointLabels:n}}=t;for(let o=e-1;o>=0;o--){const e=n.setContext(t.getPointLabelContext(o)),s=yi(e.font),{x:a,y:l,textAlign:c,left:u,top:h,right:p,bottom:d}=t._pointLabelItems[o],{backdropColor:f}=e;if(!r(f)){const t=_i(e.borderRadius),r=gi(e.backdropPadding);i.fillStyle=f;const n=u-r.left,o=h-r.top,s=p-u+r.width,a=d-h+r.height;Object.values(t).some((t=>0!==t))?(i.beginPath(),Oe(i,{x:n,y:o,w:s,h:a,radius:t}),i.fill()):i.fillRect(n,o,s,a)}ze(i,t._pointLabels[o],a,l+s.lineHeight/2,s,{color:e.color,textAlign:c,textBaseline:"middle"})}}(this,s),n.display&&this.ticks.forEach(((t,e)=>{if(0!==e){l=this.getDistanceFromCenterForValue(t.value);const i=this.getContext(e),r=n.setContext(i),a=o.setContext(i);!function(t,e,i,r,n){const o=t.ctx,s=e.circular,{color:a,lineWidth:l}=e;!s&&!r||!a||!l||i<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(n.dash),o.lineDashOffset=n.dashOffset,o.beginPath(),uo(t,i,s,r),o.closePath(),o.stroke(),o.restore())}(this,r,l,s,a)}})),i.display){for(t.save(),a=s-1;a>=0;a--){const r=i.setContext(this.getPointLabelContext(a)),{color:n,lineWidth:o}=r;o&&n&&(t.lineWidth=o,t.strokeStyle=n,t.setLineDash(r.borderDash),t.lineDashOffset=r.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const r=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(r),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((r,s)=>{if(0===s&&!e.reverse)return;const a=i.setContext(this.getContext(s)),l=yi(a.font);if(n=this.getDistanceFromCenterForValue(this.ticks[s].value),a.showLabelBackdrop){t.font=l.string,o=t.measureText(r.label).width,t.fillStyle=a.backdropColor;const e=gi(a.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}ze(t,r.label,0,-n,l,{color:a.color})})),t.restore()}drawTitle(){}}const po={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},fo=Object.keys(po);function mo(t,e){return t-e}function _o(t,e){if(r(e))return null;const i=t._adapter,{parser:n,round:o,isoWeekday:a}=t._parseOpts;let l=e;return"function"==typeof n&&(l=n(l)),s(l)||(l="string"==typeof n?i.parse(l,n):i.parse(l)),null===l?null:(o&&(l="week"!==o||!V(a)&&!0!==a?i.startOf(l,o):i.startOf(l,"isoWeek",a)),+l)}function go(t,e,i,r){const n=fo.length;for(let o=fo.indexOf(t);o<n-1;++o){const t=po[fo[o]],n=t.steps?t.steps:Number.MAX_SAFE_INTEGER;if(t.common&&Math.ceil((i-e)/(n*t.size))<=r)return fo[o]}return fo[n-1]}function yo(t,e,i){if(i){if(i.length){const{lo:r,hi:n}=et(i,e);t[i[r]>=e?i[r]:i[n]]=!0}}else t[e]=!0}function vo(t,e,i){const r=[],n={},o=e.length;let s,a;for(s=0;s<o;++s)a=e[s],n[a]=s,r.push({value:a,major:!1});return 0!==o&&i?function(t,e,i,r){const n=t._adapter,o=+n.startOf(e[0].value,r),s=e[e.length-1].value;let a,l;for(a=o;a<=s;a=+n.add(a,1,r))l=i[a],l>=0&&(e[l].major=!0);return e}(t,r,n,i):r}class xo extends Ur{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){const i=t.time||(t.time={}),r=this._adapter=new vn._date(t.adapters.date);r.init(e),y(i.displayFormats,r.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:_o(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:r,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function l(t){o||isNaN(t.min)||(r=Math.min(r,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(l(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||l(this.getMinMax(!1))),r=s(r)&&!isNaN(r)?r:+e.startOf(Date.now(),i),n=s(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(r,n-1),this.max=Math.max(r+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,r="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&r.length&&(this.min=this._userMin||r[0],this.max=this._userMax||r[r.length-1]);const n=this.min,o=nt(r,n,this.max);return this._unit=e.unit||(i.autoSkip?go(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,r,n){for(let o=fo.length-1;o>=fo.indexOf(i);o--){const i=fo[o];if(po[i].common&&t._adapter.diff(n,r,i)>=e-1)return i}return fo[i?fo.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=fo.indexOf(t)+1,i=fo.length;e<i;++e)if(po[fo[e]].common)return fo[e]}(this._unit):void 0,this.initOffsets(r),t.reverse&&o.reverse(),vo(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map((t=>+t.value)))}initOffsets(t=[]){let e,i,r=0,n=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),r=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),n=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;r=J(r,0,o),n=J(n,0,o),this._offsets={start:r,end:n,factor:1/(r+1+n)}}_generate(){const t=this._adapter,e=this.min,i=this.max,r=this.options,n=r.time,o=n.unit||go(n.minUnit,e,i,this._getLabelCapacity(e)),s=l(r.ticks.stepSize,1),a="week"===o&&n.isoWeekday,c=V(a)||!0===a,u={};let h,p,d=e;if(c&&(d=+t.startOf(d,"isoWeek",a)),d=+t.startOf(d,c?"day":o),t.diff(i,e,o)>1e5*s)throw new Error(e+" and "+i+" are too far apart with stepSize of "+s+" "+o);const f="data"===r.ticks.source&&this.getDataTimestamps();for(h=d,p=0;h<i;h=+t.add(h,s,o),p++)yo(u,h,f);return h!==i&&"ticks"!==r.bounds&&1!==p||yo(u,h,f),Object.keys(u).sort(((t,e)=>t-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const i=this.options.time.displayFormats,r=this._unit,n=e||i[r];return this._adapter.format(t,n)}_tickFormatFunction(t,e,i,r){const n=this.options,o=n.ticks.callback;if(o)return h(o,[t,e,i],this);const s=n.time.displayFormats,a=this._unit,l=this._majorUnit,c=a&&s[a],u=l&&s[l],p=i[e],d=l&&u&&p&&p.major;return this._adapter.format(t,r||(d?u:c))}generateTickLabels(t){let e,i,r;for(e=0,i=t.length;e<i;++e)r=t[e],r.label=this._tickFormatFunction(r.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+i)*e.factor)}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,i=this.ctx.measureText(t).width,r=G(this.isHorizontal()?e.maxRotation:e.minRotation),n=Math.cos(r),o=Math.sin(r),s=this._resolveTickFontOptions(0).size;return{w:i*n+s*o,h:i*o+s*n}}_getLabelCapacity(t){const e=this.options.time,i=e.displayFormats,r=i[e.unit]||i.millisecond,n=this._tickFormatFunction(t,0,vo(this,[t],this._majorUnit),r),o=this._getLabelSize(n),s=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return s>0?s:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,e=r.length;t<e;++t)i=i.concat(r[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(i)}getLabelTimestamps(){const t=this._cache.labels||[];let e,i;if(t.length)return t;const r=this.getLabels();for(e=0,i=r.length;e<i;++e)t.push(_o(this,r[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return lt(t.sort(mo))}}function bo(t,e,i){let r,n,o,s,a=0,l=t.length-1;i?(e>=t[a].pos&&e<=t[l].pos&&({lo:a,hi:l}=it(t,"pos",e)),({pos:r,time:o}=t[a]),({pos:n,time:s}=t[l])):(e>=t[a].time&&e<=t[l].time&&({lo:a,hi:l}=it(t,"time",e)),({time:r,pos:o}=t[a]),({time:n,pos:s}=t[l]));const c=n-r;return c?o+(s-o)*(e-r)/c:o}var wo=Object.freeze({__proto__:null,CategoryScale:class extends Ur{static id="category";static defaults={ticks:{callback:Xn}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:r}of e)t[i]===r&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(r(t))return null;const i=this.getLabels();return((t,e)=>null===t?null:J(Math.round(t),0,e))(e=isFinite(e)&&i[e]===t?e:function(t,e,i,r){const n=t.indexOf(e);return-1===n?((t,e,i,r)=>("string"==typeof e?(i=t.push(e)-1,r.unshift({index:i,label:e})):isNaN(e)&&(i=null),i))(t,e,i,r):n!==t.lastIndexOf(e)?i:n}(i,t,l(e,t),this._addedLabels),i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:r}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(r=this.getLabels().length-1)),this.min=i,this.max=r}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,r=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)r.push({value:i});return r}getLabelForValue(t){return Xn.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:Jn,LogarithmicScale:ro,RadialLinearScale:ho,TimeScale:xo,TimeSeriesScale:class extends xo{static id="timeseries";static defaults=xo.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=bo(e,this.min),this._tableRange=bo(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,r=[],n=[];let o,s,a,l,c;for(o=0,s=t.length;o<s;++o)l=t[o],l>=e&&l<=i&&r.push(l);if(r.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,s=r.length;o<s;++o)c=r[o+1],a=r[o-1],l=r[o],Math.round((c+a)/2)!==l&&n.push({time:l,pos:o/(s-1)});return n}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return t=e.length&&i.length?this.normalize(e.concat(i)):e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(bo(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return bo(this._table,i*this._tableRange+this._minPos,!0)}}});const To=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Mo=To.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function Eo(t){return To[t%To.length]}function Co(t){return Mo[t%Mo.length]}function So(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var ko={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,i){if(!i.enabled)return;const{data:{datasets:r},options:n}=t.config,{elements:o}=n;if(!i.forceOverride&&(So(r)||(s=n)&&(s.borderColor||s.backgroundColor)||o&&So(o)))return;var s;const a=function(t){let e=0;return(i,r)=>{const n=t.getDatasetMeta(r).controller;n instanceof kn?e=function(t,e){return t.backgroundColor=t.data.map((()=>Eo(e++))),e}(i,e):n instanceof An?e=function(t,e){return t.backgroundColor=t.data.map((()=>Co(e++))),e}(i,e):n&&(e=function(t,e){return t.borderColor=Eo(e),t.backgroundColor=Co(e),++e}(i,e))}}(t);r.forEach(a)}};function Ao(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function Io(t){t.data.datasets.forEach((t=>{Ao(t)}))}var Po={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void Io(t);const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:s,indexAxis:a}=e,l=t.getDatasetMeta(o),c=s||e.data;if("y"===vi([a,t.options.indexAxis]))return;if(!l.controller.supportsDecimation)return;const u=t.scales[l.xAxisID];if("linear"!==u.type&&"time"!==u.type)return;if(t.options.parsing)return;let h,{start:p,count:d}=function(t,e){const i=e.length;let r,n=0;const{iScale:o}=t,{min:s,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=J(it(e,o.axis,s).lo,0,i-1)),r=c?J(it(e,o.axis,a).hi+1,n,i)-n:i-n,{start:n,count:r}}(l,c);if(d<=(i.threshold||4*n))Ao(e);else{switch(r(s)&&(e._data=c,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":h=function(t,e,i,r,n){const o=n.samples||r;if(o>=i)return t.slice(e,e+i);const s=[],a=(i-2)/(o-2);let l=0;const c=e+i-1;let u,h,p,d,f,m=e;for(s[l++]=t[m],u=0;u<o-2;u++){let r,n=0,o=0;const c=Math.floor((u+1)*a)+1+e,_=Math.min(Math.floor((u+2)*a)+1,i)+e,g=_-c;for(r=c;r<_;r++)n+=t[r].x,o+=t[r].y;n/=g,o/=g;const y=Math.floor(u*a)+1+e,v=Math.min(Math.floor((u+1)*a)+1,i)+e,{x:x,y:b}=t[m];for(p=d=-1,r=y;r<v;r++)d=.5*Math.abs((x-n)*(t[r].y-b)-(x-t[r].x)*(o-b)),d>p&&(p=d,h=t[r],f=r);s[l++]=h,m=f}return s[l++]=t[c],s}(c,p,d,n,i);break;case"min-max":h=function(t,e,i,n){let o,s,a,l,c,u,h,p,d,f,m=0,_=0;const g=[],y=e+i-1,v=t[e].x,x=t[y].x-v;for(o=e;o<e+i;++o){s=t[o],a=(s.x-v)/x*n,l=s.y;const e=0|a;if(e===c)l<d?(d=l,u=o):l>f&&(f=l,h=o),m=(_*m+s.x)/++_;else{const i=o-1;if(!r(u)&&!r(h)){const e=Math.min(u,h),r=Math.max(u,h);e!==p&&e!==i&&g.push({...t[e],x:m}),r!==p&&r!==i&&g.push({...t[r],x:m})}o>0&&i!==p&&g.push(t[i]),g.push(s),c=e,_=0,d=f=l,u=h=p=o}}return g}(c,p,d,n);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=h}}))},destroy(t){Io(t)}};function Lo(t,e,i,r){if(r)return;let n=e[t],o=i[t];return"angle"===t&&(n=Q(n),o=Q(o)),{property:t,start:n,end:o}}function zo(t,e,i){for(;e>t;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function Do(t,e,i,r){return t&&e?r(t[i],e[i]):t?t[i]:e?e[i]:0}function Ro(t,e){let i=[],r=!1;return n(t)?(r=!0,i=t):i=function(t,e){const{x:i=null,y:r=null}=t||{},n=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=zo(t,e,n);const s=n[t],a=n[e];null!==r?(o.push({x:s.x,y:r}),o.push({x:a.x,y:r})):null!==i&&(o.push({x:i,y:s.y}),o.push({x:i,y:a.y}))})),o}(t,e),i.length?new Nn({points:i,options:{tension:0},_loop:r,_fullLoop:r}):null}function Oo(t){return t&&!1!==t.fill}function Fo(t,e,i){let r=t[e].fill;const n=[e];let o;if(!i)return r;for(;!1!==r&&-1===n.indexOf(r);){if(!s(r))return r;if(o=t[r],!o)return!1;if(o.visible)return r;n.push(r),r=o.fill}return!1}function Bo(t,e,i){const r=function(t){const e=t.options,i=e.fill;let r=l(i&&i.target,i);void 0===r&&(r=!!e.backgroundColor);return!1!==r&&null!==r&&(!0===r?"origin":r)}(t);if(o(r))return!isNaN(r.value)&&r;let n=parseFloat(r);return s(n)&&Math.floor(n)===n?function(t,e,i,r){"-"!==t&&"+"!==t||(i=e+i);return!(i===e||i<0||i>=r)&&i}(r[0],e,n,i):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function jo(t,e,i){const r=[];for(let n=0;n<i.length;n++){const o=i[n],{first:s,last:a,point:l}=No(o,e,"x");if(!(!l||s&&a))if(s)r.unshift(l);else if(t.push(l),!a)break}t.push(...r)}function No(t,e,i){const r=t.interpolate(e,i);if(!r)return{};const n=r[i],o=t.segments,s=t.points;let a=!1,l=!1;for(let t=0;t<o.length;t++){const e=o[t],r=s[e.start][i],c=s[e.end][i];if(tt(n,r,c)){a=n===r,l=n===c;break}}return{first:a,last:l,point:r}}class Vo{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:r,y:n,radius:o}=this;return e=e||{start:0,end:A},t.arc(r,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:r}=this,n=t.angle;return{x:e+Math.cos(n)*r,y:i+Math.sin(n)*r,angle:n}}}function Uo(t){const{chart:e,fill:i,line:r}=t;if(s(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return function(t){const{scale:e,index:i,line:r}=t,n=[],o=r.segments,s=r.points,a=function(t,e){const i=[],r=t.getMatchingVisibleMetas("line");for(let t=0;t<r.length;t++){const n=r[t];if(n.index===e)break;n.hidden||i.unshift(n.dataset)}return i}(e,i);a.push(Ro({x:null,y:e.bottom},r));for(let t=0;t<o.length;t++){const e=o[t];for(let t=e.start;t<=e.end;t++)jo(n,s[t],a)}return new Nn({points:n,options:{}})}(t);if("shape"===i)return!0;const n=function(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,r=e.options,n=e.getLabels().length,s=r.reverse?e.max:e.min,a=function(t,e,i){let r;return r="start"===t?i:"end"===t?e.options.reverse?e.min:e.max:o(t)?t.value:e.getBaseValue(),r}(i,e,s),l=[];if(r.grid.circular){const t=e.getPointPositionForValue(0,s);return new Vo({x:t.x,y:t.y,radius:e.getDistanceFromCenterForValue(a)})}for(let t=0;t<n;++t)l.push(e.getPointPositionForValue(t,a));return l}(t):function(t){const{scale:e={},fill:i}=t,r=function(t,e){let i=null;return"start"===t?i=e.bottom:"end"===t?i=e.top:o(t)?i=e.getPixelForValue(t.value):e.getBasePixel&&(i=e.getBasePixel()),i}(i,e);if(s(r)){const t=e.isHorizontal();return{x:t?r:null,y:t?null:r}}return null}(t)}(t);return n instanceof Vo?n:Ro(n,r)}function $o(t,e,i){const r=Uo(e),{line:n,scale:o,axis:s}=e,a=n.options,l=a.fill,c=a.backgroundColor,{above:u=c,below:h=c}=l||{};r&&n.points.length&&(Ae(t,i),function(t,e){const{line:i,target:r,above:n,below:o,area:s,scale:a}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(Go(t,r,s.top),qo(t,{line:i,target:r,color:n,scale:a,property:l}),t.restore(),t.save(),Go(t,r,s.bottom));qo(t,{line:i,target:r,color:o,scale:a,property:l}),t.restore()}(t,{line:n,target:r,above:u,below:h,area:i,scale:o,axis:s}),Ie(t))}function Go(t,e,i){const{segments:r,points:n}=e;let o=!0,s=!1;t.beginPath();for(const a of r){const{start:r,end:l}=a,c=n[r],u=n[zo(r,l,n)];o?(t.moveTo(c.x,c.y),o=!1):(t.lineTo(c.x,i),t.lineTo(c.x,c.y)),s=!!e.pathSegment(t,a,{move:s}),s?t.closePath():t.lineTo(u.x,i)}t.lineTo(e.first().x,i),t.closePath(),t.clip()}function qo(t,e){const{line:i,target:r,property:n,color:o,scale:s}=e,a=function(t,e,i){const r=t.segments,n=t.points,o=e.points,s=[];for(const t of r){let{start:r,end:a}=t;a=zo(r,a,n);const l=Lo(i,n[r],n[a],t.loop);if(!e.segments){s.push({source:t,target:l,start:n[r],end:n[a]});continue}const c=ki(e,l);for(const e of c){const r=Lo(i,o[e.start],o[e.end],e.loop),a=Si(t,n,r);for(const t of a)s.push({source:t,target:e,start:{[i]:Do(l,r,"start",Math.max)},end:{[i]:Do(l,r,"end",Math.min)}})}}return s}(i,r,n);for(const{source:e,target:l,start:c,end:u}of a){const{style:{backgroundColor:a=o}={}}=e,h=!0!==r;t.save(),t.fillStyle=a,Zo(t,s,h&&Lo(n,c,u)),t.beginPath();const p=!!i.pathSegment(t,e);let d;if(h){p?t.closePath():Ho(t,r,u,n);const e=!!r.pathSegment(t,l,{move:p,reverse:!0});d=p&&e,d||Ho(t,r,c,n)}t.closePath(),t.fill(d?"evenodd":"nonzero"),t.restore()}}function Zo(t,e,i){const{top:r,bottom:n}=e.chart.chartArea,{property:o,start:s,end:a}=i||{};"x"===o&&(t.beginPath(),t.rect(s,r,a-s,n-r),t.clip())}function Ho(t,e,i,r){const n=e.interpolate(i,r);n&&t.lineTo(n.x,n.y)}var Wo={id:"filler",afterDatasetsUpdate(t,e,i){const r=(t.data.datasets||[]).length,n=[];let o,s,a,l;for(s=0;s<r;++s)o=t.getDatasetMeta(s),a=o.dataset,l=null,a&&a.options&&a instanceof Nn&&(l={visible:t.isDatasetVisible(s),index:s,fill:Bo(a,s,r),chart:t,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=l,n.push(l);for(s=0;s<r;++s)l=n[s],l&&!1!==l.fill&&(l.fill=Fo(n,s,i.propagate))},beforeDraw(t,e,i){const r="beforeDraw"===i.drawTime,n=t.getSortedVisibleDatasetMetas(),o=t.chartArea;for(let e=n.length-1;e>=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),r&&i.fill&&$o(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const r=t.getSortedVisibleDatasetMetas();for(let e=r.length-1;e>=0;--e){const i=r[e].$filler;Oo(i)&&$o(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const r=e.meta.$filler;Oo(r)&&"beforeDatasetDraw"===i.drawTime&&$o(t.ctx,r,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Xo=(t,e)=>{let{boxHeight:i=e,boxWidth:r=e}=t;return t.usePointStyle&&(i=Math.min(i,e),r=t.pointStyleWidth||Math.min(r,e)),{boxWidth:r,boxHeight:i,itemHeight:Math.max(e,i)}};class Qo extends Lr{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=h(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,r=yi(i.font),n=r.size,o=this._computeTitleHeight(),{boxWidth:s,itemHeight:a}=Xo(i,n);let l,c;e.font=r.string,this.isHorizontal()?(l=this.maxWidth,c=this._fitRows(o,n,s,a)+10):(c=this.maxHeight,l=this._fitCols(o,r,s,a)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,r){const{ctx:n,maxWidth:o,options:{labels:{padding:s}}}=this,a=this.legendHitBoxes=[],l=this.lineWidths=[0],c=r+s;let u=t;n.textAlign="left",n.textBaseline="middle";let h=-1,p=-c;return this.legendItems.forEach(((t,d)=>{const f=i+e/2+n.measureText(t.text).width;(0===d||l[l.length-1]+f+2*s>o)&&(u+=c,l[l.length-(d>0?0:1)]=0,p+=c,h++),a[d]={left:0,top:p,row:h,width:f,height:r},l[l.length-1]+=f+s})),u}_fitCols(t,e,i,r){const{ctx:n,maxHeight:o,options:{labels:{padding:s}}}=this,a=this.legendHitBoxes=[],l=this.columnSizes=[],c=o-t;let u=s,h=0,p=0,d=0,f=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:m,itemHeight:_}=function(t,e,i,r,n){const o=function(t,e,i,r){let n=t.text;n&&"string"!=typeof n&&(n=n.reduce(((t,e)=>t.length>e.length?t:e)));return e+i.size/2+r.measureText(n).width}(r,t,e,i),s=function(t,e,i){let r=t;"string"!=typeof e.text&&(r=Yo(e,i));return r}(n,r,e.lineHeight);return{itemWidth:o,itemHeight:s}}(i,e,n,t,r);o>0&&p+_+2*s>c&&(u+=h+s,l.push({width:h,height:p}),d+=h+s,f++,h=p=0),a[o]={left:d,top:p,col:f,width:m,height:_},h=Math.max(h,m),p+=_+s})),u+=h,l.push({width:h,height:p}),u}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:r},rtl:n}}=this,o=wi(n,this.left,this.width);if(this.isHorizontal()){let n=0,s=dt(i,this.left+r,this.right-this.lineWidths[n]);for(const a of e)n!==a.row&&(n=a.row,s=dt(i,this.left+r,this.right-this.lineWidths[n])),a.top+=this.top+t+r,a.left=o.leftForLtr(o.x(s),a.width),s+=a.width+r}else{let n=0,s=dt(i,this.top+t+r,this.bottom-this.columnSizes[n].height);for(const a of e)a.col!==n&&(n=a.col,s=dt(i,this.top+t+r,this.bottom-this.columnSizes[n].height)),a.top=s,a.left+=this.left+r,a.left=o.leftForLtr(o.x(a.left),a.width),s+=a.height+r}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Ae(t,this),this._draw(),Ie(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:r}=this,{align:n,labels:o}=t,s=ae.color,a=wi(t.rtl,this.left,this.width),c=yi(o.font),{padding:u}=o,h=c.size,p=h/2;let d;this.drawTitle(),r.textAlign=a.textAlign("left"),r.textBaseline="middle",r.lineWidth=.5,r.font=c.string;const{boxWidth:f,boxHeight:m,itemHeight:_}=Xo(o,h),g=this.isHorizontal(),y=this._computeTitleHeight();d=g?{x:dt(n,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:dt(n,this.top+y+u,this.bottom-e[0].height),line:0},Ti(this.ctx,t.textDirection);const v=_+u;this.legendItems.forEach(((x,b)=>{r.strokeStyle=x.fontColor,r.fillStyle=x.fontColor;const w=r.measureText(x.text).width,T=a.textAlign(x.textAlign||(x.textAlign=o.textAlign)),M=f+p+w;let E=d.x,C=d.y;a.setWidth(this.width),g?b>0&&E+M+u>this.right&&(C=d.y+=v,d.line++,E=d.x=dt(n,this.left+u,this.right-i[d.line])):b>0&&C+v>this.bottom&&(E=d.x=E+e[d.line].width+u,d.line++,C=d.y=dt(n,this.top+y+u,this.bottom-e[d.line].height));if(function(t,e,i){if(isNaN(f)||f<=0||isNaN(m)||m<0)return;r.save();const n=l(i.lineWidth,1);if(r.fillStyle=l(i.fillStyle,s),r.lineCap=l(i.lineCap,"butt"),r.lineDashOffset=l(i.lineDashOffset,0),r.lineJoin=l(i.lineJoin,"miter"),r.lineWidth=n,r.strokeStyle=l(i.strokeStyle,s),r.setLineDash(l(i.lineDash,[])),o.usePointStyle){const s={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},l=a.xPlus(t,f/2);Se(r,s,l,e+p,o.pointStyleWidth&&f)}else{const o=e+Math.max((h-m)/2,0),s=a.leftForLtr(t,f),l=_i(i.borderRadius);r.beginPath(),Object.values(l).some((t=>0!==t))?Oe(r,{x:s,y:o,w:f,h:m,radius:l}):r.rect(s,o,f,m),r.fill(),0!==n&&r.stroke()}r.restore()}(a.x(E),C,x),E=ft(T,E+f+p,g?E+M:this.right,t.rtl),function(t,e,i){ze(r,i.text,t,e+_/2,c,{strikethrough:i.hidden,textAlign:a.textAlign(i.textAlign)})}(a.x(E),C,x),g)d.x+=M+u;else if("string"!=typeof x.text){const t=c.lineHeight;d.y+=Yo(x,t)}else d.y+=v})),Mi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=yi(e.font),r=gi(e.padding);if(!e.display)return;const n=wi(t.rtl,this.left,this.width),o=this.ctx,s=e.position,a=i.size/2,l=r.top+a;let c,u=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+l,u=dt(t.align,u,this.right-h);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);c=l+dt(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const p=dt(s,u,u+h);o.textAlign=n.textAlign(pt(s)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=i.string,ze(o,e.text,p,c,i)}_computeTitleHeight(){const t=this.options.title,e=yi(t.font),i=gi(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,r,n;if(tt(t,this.left,this.right)&&tt(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;i<n.length;++i)if(r=n[i],tt(t,r.left,r.left+r.width)&&tt(e,r.top,r.top+r.height))return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!function(t,e){return!("mousemove"!==t&&"mouseout"!==t||!e.onHover&&!e.onLeave)||!(!e.onClick||"click"!==t&&"mouseup"!==t)}(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type||"mouseout"===t.type){const o=this._hoveredItem,s=(n=i,null!==(r=o)&&null!==n&&r.datasetIndex===n.datasetIndex&&r.index===n.index);o&&!s&&h(e.onLeave,[t,o,this],this),this._hoveredItem=i,i&&!s&&h(e.onHover,[t,i,this],this)}else i&&h(e.onClick,[t,i,this],this);var r,n}}function Yo(t,e){return e*(t.text?t.text.length+.5:0)}var Jo={id:"legend",_element:Qo,start(t,e,i){const r=t.legend=new Qo({ctx:t.ctx,options:i,chart:t});Yi.configure(t,r,i),Yi.addBox(t,r)},stop(t){Yi.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const r=t.legend;Yi.configure(t,r,i),r.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const r=e.datasetIndex,n=i.chart;n.isDatasetVisible(r)?(n.hide(r),e.hidden=!0):(n.show(r),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:r,textAlign:n,color:o,useBorderRadius:s,borderRadius:a}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(i?0:void 0),c=gi(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:l.borderColor,pointStyle:r||l.pointStyle,rotation:l.rotation,textAlign:n||l.textAlign,borderRadius:s&&(a||l.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Ko extends Lr{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const r=n(i.text)?i.text.length:1;this._padding=gi(i.padding);const o=r*yi(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:r,right:n,options:o}=this,s=o.align;let a,l,c,u=0;return this.isHorizontal()?(l=dt(s,i,n),c=e+t,a=n-i):("left"===o.position?(l=i+t,c=dt(s,r,e),u=-.5*k):(l=n-t,c=dt(s,e,r),u=.5*k),a=r-e),{titleX:l,titleY:c,maxWidth:a,rotation:u}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=yi(e.font),r=i.lineHeight/2+this._padding.top,{titleX:n,titleY:o,maxWidth:s,rotation:a}=this._drawArgs(r);ze(t,e.text,0,0,i,{color:e.color,maxWidth:s,rotation:a,textAlign:pt(e.align),textBaseline:"middle",translation:[n,o]})}}var ts={id:"title",_element:Ko,start(t,e,i){!function(t,e){const i=new Ko({ctx:t.ctx,options:e,chart:t});Yi.configure(t,i,e),Yi.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;Yi.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const r=t.titleBlock;Yi.configure(t,r,i),r.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const es=new WeakMap;var is={id:"subtitle",start(t,e,i){const r=new Ko({ctx:t.ctx,options:i,chart:t});Yi.configure(t,r,i),Yi.addBox(t,r),es.set(t,r)},stop(t){Yi.removeBox(t,es.get(t)),es.delete(t)},beforeUpdate(t,e,i){const r=es.get(t);Yi.configure(t,r,i),r.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const rs={average(t){if(!t.length)return!1;let e,i,r=0,n=0,o=0;for(e=0,i=t.length;e<i;++e){const i=t[e].element;if(i&&i.hasValue()){const t=i.tooltipPosition();r+=t.x,n+=t.y,++o}}return{x:r/o,y:n/o}},nearest(t,e){if(!t.length)return!1;let i,r,n,o=e.x,s=e.y,a=Number.POSITIVE_INFINITY;for(i=0,r=t.length;i<r;++i){const r=t[i].element;if(r&&r.hasValue()){const t=W(e,r.getCenterPoint());t<a&&(a=t,n=r)}}if(n){const t=n.tooltipPosition();o=t.x,s=t.y}return{x:o,y:s}}};function ns(t,e){return e&&(n(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function os(t){return("string"==typeof t||t instanceof String)&&t.indexOf("\n")>-1?t.split("\n"):t}function ss(t,e){const{element:i,datasetIndex:r,index:n}=e,o=t.getDatasetMeta(r).controller,{label:s,value:a}=o.getLabelAndValue(n);return{chart:t,label:s,parsed:o.getParsed(n),raw:t.data.datasets[r].data[n],formattedValue:a,dataset:o.getDataset(),dataIndex:n,datasetIndex:r,element:i}}function as(t,e){const i=t.chart.ctx,{body:r,footer:n,title:o}=t,{boxWidth:s,boxHeight:a}=e,l=yi(e.bodyFont),c=yi(e.titleFont),u=yi(e.footerFont),h=o.length,d=n.length,f=r.length,m=gi(e.padding);let _=m.height,g=0,y=r.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);(y+=t.beforeBody.length+t.afterBody.length,h&&(_+=h*c.lineHeight+(h-1)*e.titleSpacing+e.titleMarginBottom),y)&&(_+=f*(e.displayColors?Math.max(a,l.lineHeight):l.lineHeight)+(y-f)*l.lineHeight+(y-1)*e.bodySpacing);d&&(_+=e.footerMarginTop+d*u.lineHeight+(d-1)*e.footerSpacing);let v=0;const x=function(t){g=Math.max(g,i.measureText(t).width+v)};return i.save(),i.font=c.string,p(t.title,x),i.font=l.string,p(t.beforeBody.concat(t.afterBody),x),v=e.displayColors?s+2+e.boxPadding:0,p(r,(t=>{p(t.before,x),p(t.lines,x),p(t.after,x)})),v=0,i.font=u.string,p(t.footer,x),i.restore(),g+=m.width,{width:g,height:_}}function ls(t,e,i,r){const{x:n,width:o}=i,{width:s,chartArea:{left:a,right:l}}=t;let c="center";return"center"===r?c=n<=(a+l)/2?"left":"right":n<=o/2?c="left":n>=s-o/2&&(c="right"),function(t,e,i,r){const{x:n,width:o}=r,s=i.caretSize+i.caretPadding;return"left"===t&&n+o+s>e.width||"right"===t&&n-o-s<0||void 0}(c,t,e,i)&&(c="center"),c}function cs(t,e,i){const r=i.yAlign||e.yAlign||function(t,e){const{y:i,height:r}=e;return i<r/2?"top":i>t.height-r/2?"bottom":"center"}(t,i);return{xAlign:i.xAlign||e.xAlign||ls(t,e,i,r),yAlign:r}}function us(t,e,i,r){const{caretSize:n,caretPadding:o,cornerRadius:s}=t,{xAlign:a,yAlign:l}=i,c=n+o,{topLeft:u,topRight:h,bottomLeft:p,bottomRight:d}=_i(s);let f=function(t,e){let{x:i,width:r}=t;return"right"===e?i-=r:"center"===e&&(i-=r/2),i}(e,a);const m=function(t,e,i){let{y:r,height:n}=t;return"top"===e?r+=i:r-="bottom"===e?n+i:n/2,r}(e,l,c);return"center"===l?"left"===a?f+=c:"right"===a&&(f-=c):"left"===a?f-=Math.max(u,p)+n:"right"===a&&(f+=Math.max(h,d)+n),{x:J(f,0,r.width-e.width),y:J(m,0,r.height-e.height)}}function hs(t,e,i){const r=gi(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-r.right:t.x+r.left}function ps(t){return ns([],os(t))}function ds(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}const fs={beforeTitle:e,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,r=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(r>0&&e.dataIndex<r)return i[e.dataIndex]}return""},afterTitle:e,beforeBody:e,beforeLabel:e,label(t){if(this&&this.options&&"dataset"===this.options.mode)return t.label+": "+t.formattedValue||t.formattedValue;let e=t.dataset.label||"";e&&(e+=": ");const i=t.formattedValue;return r(i)||(e+=i),e},labelColor(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(t){const e=t.chart.getDatasetMeta(t.datasetIndex).controller.getStyle(t.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:e,afterBody:e,beforeFooter:e,footer:e,afterFooter:e};function ms(t,e,i,r){const n=t[e].call(i,r);return void 0===n?fs[e].call(i,r):n}class _s extends Lr{static positioners=rs;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),r=i.enabled&&e.options.animation&&i.animations,n=new vr(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(this,bi(this.chart.getContext(),{tooltip:this,tooltipItems:this._tooltipItems,type:"tooltip"})))}getTitle(t,e){const{callbacks:i}=e,r=ms(i,"beforeTitle",this,t),n=ms(i,"title",this,t),o=ms(i,"afterTitle",this,t);let s=[];return s=ns(s,os(r)),s=ns(s,os(n)),s=ns(s,os(o)),s}getBeforeBody(t,e){return ps(ms(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,r=[];return p(t,(t=>{const e={before:[],lines:[],after:[]},n=ds(i,t);ns(e.before,os(ms(n,"beforeLabel",this,t))),ns(e.lines,ms(n,"label",this,t)),ns(e.after,os(ms(n,"afterLabel",this,t))),r.push(e)})),r}getAfterBody(t,e){return ps(ms(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,r=ms(i,"beforeFooter",this,t),n=ms(i,"footer",this,t),o=ms(i,"afterFooter",this,t);let s=[];return s=ns(s,os(r)),s=ns(s,os(n)),s=ns(s,os(o)),s}_createItems(t){const e=this._active,i=this.chart.data,r=[],n=[],o=[];let s,a,l=[];for(s=0,a=e.length;s<a;++s)l.push(ss(this.chart,e[s]));return t.filter&&(l=l.filter(((e,r,n)=>t.filter(e,r,n,i)))),t.itemSort&&(l=l.sort(((e,r)=>t.itemSort(e,r,i)))),p(l,(e=>{const i=ds(t.callbacks,e);r.push(ms(i,"labelColor",this,e)),n.push(ms(i,"labelPointStyle",this,e)),o.push(ms(i,"labelTextColor",this,e))})),this.labelColors=r,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),r=this._active;let n,o=[];if(r.length){const t=rs[i.position].call(this,r,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=as(this,i),s=Object.assign({},t,e),a=cs(this.chart,i,s),l=us(i,s,a,this.chart);this.xAlign=a.xAlign,this.yAlign=a.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,r){const n=this.getCaretPosition(t,i,r);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:r,yAlign:n}=this,{caretSize:o,cornerRadius:s}=i,{topLeft:a,topRight:l,bottomLeft:c,bottomRight:u}=_i(s),{x:h,y:p}=t,{width:d,height:f}=e;let m,_,g,y,v,x;return"center"===n?(v=p+f/2,"left"===r?(m=h,_=m-o,y=v+o,x=v-o):(m=h+d,_=m+o,y=v-o,x=v+o),g=m):(_="left"===r?h+Math.max(a,c)+o:"right"===r?h+d-Math.max(l,u)-o:this.caretX,"top"===n?(y=p,v=y-o,m=_-o,g=_+o):(y=p+f,v=y+o,m=_+o,g=_-o),x=y),{x1:m,x2:_,x3:g,y1:y,y2:v,y3:x}}drawTitle(t,e,i){const r=this.title,n=r.length;let o,s,a;if(n){const l=wi(i.rtl,this.x,this.width);for(t.x=hs(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=yi(i.titleFont),s=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,a=0;a<n;++a)e.fillText(r[a],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+s,a+1===n&&(t.y+=i.titleMarginBottom-s)}}_drawColorBox(t,e,i,r,n){const s=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:l,boxWidth:c,boxPadding:u}=n,h=yi(n.bodyFont),p=hs(this,"left",n),d=r.x(p),f=l<h.lineHeight?(h.lineHeight-l)/2:0,m=e.y+f;if(n.usePointStyle){const e={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},i=r.leftForLtr(d,c)+c/2,o=m+l/2;t.strokeStyle=n.multiKeyBackground,t.fillStyle=n.multiKeyBackground,Ce(t,e,i,o),t.strokeStyle=s.borderColor,t.fillStyle=s.backgroundColor,Ce(t,e,i,o)}else{t.lineWidth=o(s.borderWidth)?Math.max(...Object.values(s.borderWidth)):s.borderWidth||1,t.strokeStyle=s.borderColor,t.setLineDash(s.borderDash||[]),t.lineDashOffset=s.borderDashOffset||0;const e=r.leftForLtr(d,c-u),i=r.leftForLtr(r.xPlus(d,1),c-u-2),a=_i(s.borderRadius);Object.values(a).some((t=>0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,Oe(t,{x:e,y:m,w:c,h:l,radius:a}),t.fill(),t.stroke(),t.fillStyle=s.backgroundColor,t.beginPath(),Oe(t,{x:i,y:m+1,w:c-2,h:l-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,m,c,l),t.strokeRect(e,m,c,l),t.fillStyle=s.backgroundColor,t.fillRect(i,m+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:r}=this,{bodySpacing:n,bodyAlign:o,displayColors:s,boxHeight:a,boxWidth:l,boxPadding:c}=i,u=yi(i.bodyFont);let h=u.lineHeight,d=0;const f=wi(i.rtl,this.x,this.width),m=function(i){e.fillText(i,f.x(t.x+d),t.y+h/2),t.y+=h+n},_=f.textAlign(o);let g,y,v,x,b,w,T;for(e.textAlign=o,e.textBaseline="middle",e.font=u.string,t.x=hs(this,_,i),e.fillStyle=i.bodyColor,p(this.beforeBody,m),d=s&&"right"!==_?"center"===o?l/2+c:l+2+c:0,x=0,w=r.length;x<w;++x){for(g=r[x],y=this.labelTextColors[x],e.fillStyle=y,p(g.before,m),v=g.lines,s&&v.length&&(this._drawColorBox(e,t,x,f,i),h=Math.max(u.lineHeight,a)),b=0,T=v.length;b<T;++b)m(v[b]),h=u.lineHeight;p(g.after,m)}d=0,h=u.lineHeight,p(this.afterBody,m),t.y-=n}drawFooter(t,e,i){const r=this.footer,n=r.length;let o,s;if(n){const a=wi(i.rtl,this.x,this.width);for(t.x=hs(this,i.footerAlign,i),t.y+=i.footerMarginTop,e.textAlign=a.textAlign(i.footerAlign),e.textBaseline="middle",o=yi(i.footerFont),e.fillStyle=i.footerColor,e.font=o.string,s=0;s<n;++s)e.fillText(r[s],a.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+i.footerSpacing}}drawBackground(t,e,i,r){const{xAlign:n,yAlign:o}=this,{x:s,y:a}=t,{width:l,height:c}=i,{topLeft:u,topRight:h,bottomLeft:p,bottomRight:d}=_i(r.cornerRadius);e.fillStyle=r.backgroundColor,e.strokeStyle=r.borderColor,e.lineWidth=r.borderWidth,e.beginPath(),e.moveTo(s+u,a),"top"===o&&this.drawCaret(t,e,i,r),e.lineTo(s+l-h,a),e.quadraticCurveTo(s+l,a,s+l,a+h),"center"===o&&"right"===n&&this.drawCaret(t,e,i,r),e.lineTo(s+l,a+c-d),e.quadraticCurveTo(s+l,a+c,s+l-d,a+c),"bottom"===o&&this.drawCaret(t,e,i,r),e.lineTo(s+p,a+c),e.quadraticCurveTo(s,a+c,s,a+c-p),"center"===o&&"left"===n&&this.drawCaret(t,e,i,r),e.lineTo(s,a+u),e.quadraticCurveTo(s,a,s+u,a),e.closePath(),e.fill(),r.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,r=i&&i.x,n=i&&i.y;if(r||n){const i=rs[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=as(this,t),s=Object.assign({},i,this._size),a=cs(e,t,s),l=us(t,s,a,e);r._to===l.x&&n._to===l.y||(this.xAlign=a.xAlign,this.yAlign=a.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const r={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=gi(e.padding),s=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&s&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,r,e),Ti(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Mi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,r=t.map((({datasetIndex:t,index:e})=>{const i=this.chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!d(i,r),o=this._positionChanged(r,e);(n||o)&&(this._active=r,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const r=this.options,n=this._active||[],o=this._getActiveElements(t,n,e,i),s=this._positionChanged(o,t),a=e||!d(o,n)||s;return a&&(this._active=o,(r.enabled||r.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),a}_getActiveElements(t,e,i,r){const n=this.options;if("mouseout"===t.type)return[];if(!r)return e;const o=this.chart.getElementsAtEventForMode(t,n.mode,n,i);return n.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:i,caretY:r,options:n}=this,o=rs[n.position].call(this,t,e);return!1!==o&&(i!==o.x||r!==o.y)}}var gs={id:"tooltip",_element:_s,positioners:rs,afterInit(t,e,i){i&&(t.tooltip=new _s({chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const i={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...i,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i)}},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:fs},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return mn.register(In,wo,Wn,t),mn.helpers={...zi},mn._adapters=vn,mn.Animation=yr,mn.Animations=vr,mn.animator=gt,mn.controllers=Gr.controllers.items,mn.DatasetController=Pr,mn.Element=Lr,mn.elements=Wn,mn.Interaction=ji,mn.layouts=Yi,mn.platforms=mr,mn.Scale=Ur,mn.Ticks=ie,Object.assign(mn,In,wo,Wn,t,mr),mn.Chart=mn,"undefined"!=typeof window&&(window.Chart=mn),mn}));!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).turf=t()}}((function(){return function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[s]={exports:{}};e[s][0].call(u.exports,(function(t){return n(e[s][1][t]||t)}),u,u.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){e.exports={along:t("@turf/along").default,bbox:t("@turf/bbox").default,center:t("@turf/center").default,distance:t("@turf/distance").default,destination:t("@turf/destination").default,length:t("@turf/length").default,nearestPointOnLine:t("@turf/nearest-point-on-line").default,booleanPointInPolygon:t("@turf/boolean-point-in-polygon").default,pointOnFeature:t("@turf/point-on-feature").default}},{"@turf/along":2,"@turf/bbox":3,"@turf/boolean-point-in-polygon":5,"@turf/center":6,"@turf/destination":8,"@turf/distance":9,"@turf/length":13,"@turf/nearest-point-on-line":17,"@turf/point-on-feature":19}],2:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=r(t("@turf/bearing")),o=r(t("@turf/destination")),s=r(t("@turf/distance")),a=t("@turf/helpers"),l=t("@turf/invariant");i.default=function(t,e,i){void 0===i&&(i={});for(var r=l.getGeom(t).coordinates,c=0,u=0;u<r.length&&!(e>=c&&u===r.length-1);u++){if(c>=e){var h=e-c;if(h){var p=n.default(r[u],r[u-1])-180;return o.default(r[u],h,p,i)}return a.point(r[u])}c+=s.default(r[u],r[u+1],i)}return a.point(r[r.length-1])}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12}],3:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/meta");function n(t){var e=[1/0,1/0,-1/0,-1/0];r.coordEach(t,(function(t){e[0]>t[0]&&(e[0]=t[0]);e[1]>t[1]&&(e[1]=t[1]);e[2]<t[0]&&(e[2]=t[0]);e[3]<t[1]&&(e[3]=t[1])}));return e}n.default=n;i.default=n},{"@turf/meta":16}],4:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/helpers"),n=t("@turf/invariant");function o(t,e,i){void 0===i&&(i={});if(!0===i.final)return function(t,e){var i=o(e,t);return(i+180)%360}(t,e);var s=n.getCoord(t),a=n.getCoord(e),l=r.degreesToRadians(s[0]),c=r.degreesToRadians(a[0]),u=r.degreesToRadians(s[1]),h=r.degreesToRadians(a[1]),p=Math.sin(c-l)*Math.cos(h),d=Math.cos(u)*Math.sin(h)-Math.sin(u)*Math.cos(h)*Math.cos(c-l);return r.radiansToDegrees(Math.atan2(p,d))}i.default=o},{"@turf/helpers":11,"@turf/invariant":12}],5:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/invariant");i.default=function(t,e,i){void 0===i&&(i={});if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var o=r.getCoord(t),s=r.getGeom(e),a=s.type,l=e.bbox,c=s.coordinates;if(l&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(o,l))return!1;"Polygon"===a&&(c=[c]);for(var u=!1,h=0;h<c.length&&!u;h++)if(n(o,c[h][0],i.ignoreBoundary)){for(var p=!1,d=1;d<c[h].length&&!p;){n(o,c[h][d],!i.ignoreBoundary)&&(p=!0);d++}p||(u=!0)}return u};function n(t,e,i){var r=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var n=0,o=e.length-1;n<e.length;o=n++){var s=e[n][0],a=e[n][1],l=e[o][0],c=e[o][1];if(t[1]*(s-l)+a*(l-t[0])+c*(t[0]-s)==0&&(s-t[0])*(l-t[0])<=0&&(a-t[1])*(c-t[1])<=0)return!i;a>t[1]!=c>t[1]&&t[0]<(l-s)*(t[1]-a)/(c-a)+s&&(r=!r)}return r}},{"@turf/invariant":12}],6:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=r(t("@turf/bbox")),o=t("@turf/helpers");i.default=function(t,e){void 0===e&&(e={});var i=n.default(t),r=(i[0]+i[2])/2,s=(i[1]+i[3])/2;return o.point([r,s],e.properties,e)}},{"@turf/bbox":3,"@turf/helpers":11}],7:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});function r(t){var e={type:"Feature"};Object.keys(t).forEach((function(i){switch(i){case"type":case"properties":case"geometry":return;default:e[i]=t[i]}}));e.properties=n(t.properties);e.geometry=o(t.geometry);return e}function n(t){var e={};if(!t)return e;Object.keys(t).forEach((function(i){var r=t[i];"object"==typeof r?null===r?e[i]=null:Array.isArray(r)?e[i]=r.map((function(t){return t})):e[i]=n(r):e[i]=r}));return e}function o(t){var e={type:t.type};t.bbox&&(e.bbox=t.bbox);if("GeometryCollection"===t.type){e.geometries=t.geometries.map((function(t){return o(t)}));return e}e.coordinates=s(t.coordinates);return e}function s(t){var e=t;return"object"!=typeof e[0]?e.slice():e.map((function(t){return s(t)}))}i.default=function(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return r(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};Object.keys(t).forEach((function(i){switch(i){case"type":case"features":return;default:e[i]=t[i]}}));e.features=t.features.map((function(t){return r(t)}));return e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return o(t);default:throw new Error("unknown GeoJSON type")}}},{}],8:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/helpers"),n=t("@turf/invariant");i.default=function(t,e,i,o){void 0===o&&(o={});var s=n.getCoord(t),a=r.degreesToRadians(s[0]),l=r.degreesToRadians(s[1]),c=r.degreesToRadians(i),u=r.lengthToRadians(e,o.units),h=Math.asin(Math.sin(l)*Math.cos(u)+Math.cos(l)*Math.sin(u)*Math.cos(c)),p=a+Math.atan2(Math.sin(c)*Math.sin(u)*Math.cos(l),Math.cos(u)-Math.sin(l)*Math.sin(h)),d=r.radiansToDegrees(p),f=r.radiansToDegrees(h);return r.point([d,f],o.properties)}},{"@turf/helpers":11,"@turf/invariant":12}],9:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/invariant"),n=t("@turf/helpers");i.default=function(t,e,i){void 0===i&&(i={});var o=r.getCoord(t),s=r.getCoord(e),a=n.degreesToRadians(s[1]-o[1]),l=n.degreesToRadians(s[0]-o[0]),c=n.degreesToRadians(o[1]),u=n.degreesToRadians(s[1]),h=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(u);return n.radiansToLength(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),i.units)}},{"@turf/helpers":11,"@turf/invariant":12}],10:[function(t,e,i){"use strict";var r=t("@turf/meta"),n=t("@turf/helpers");function o(t){var e=[];"FeatureCollection"===t.type?r.featureEach(t,(function(t){r.coordEach(t,(function(i){e.push(n.point(i,t.properties))}))})):r.coordEach(t,(function(i){e.push(n.point(i,t.properties))}));return n.featureCollection(e)}e.exports=o;e.exports.default=o},{"@turf/helpers":11,"@turf/meta":16}],11:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.earthRadius=6371008.8;i.factors={centimeters:100*i.earthRadius,centimetres:100*i.earthRadius,degrees:i.earthRadius/111325,feet:3.28084*i.earthRadius,inches:39.37*i.earthRadius,kilometers:i.earthRadius/1e3,kilometres:i.earthRadius/1e3,meters:i.earthRadius,metres:i.earthRadius,miles:i.earthRadius/1609.344,millimeters:1e3*i.earthRadius,millimetres:1e3*i.earthRadius,nauticalmiles:i.earthRadius/1852,radians:1,yards:1.0936*i.earthRadius};i.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/i.earthRadius,yards:1.0936133};i.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function r(t,e,i){void 0===i&&(i={});var r={type:"Feature"};(0===i.id||i.id)&&(r.id=i.id);i.bbox&&(r.bbox=i.bbox);r.properties=e||{};r.geometry=t;return r}i.feature=r;i.geometry=function(t,e,i){void 0===i&&(i={});switch(t){case"Point":return n(e).geometry;case"LineString":return s(e).geometry;case"Polygon":return o(e).geometry;case"MultiPoint":return c(e).geometry;case"MultiLineString":return l(e).geometry;case"MultiPolygon":return u(e).geometry;default:throw new Error(t+" is invalid")}};function n(t,e,i){void 0===i&&(i={});if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:t},e,i)}i.point=n;i.points=function(t,e,i){void 0===i&&(i={});return a(t.map((function(t){return n(t,e)})),i)};function o(t,e,i){void 0===i&&(i={});for(var n=0,o=t;n<o.length;n++){var s=o[n];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:t},e,i)}i.polygon=o;i.polygons=function(t,e,i){void 0===i&&(i={});return a(t.map((function(t){return o(t,e)})),i)};function s(t,e,i){void 0===i&&(i={});if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:t},e,i)}i.lineString=s;i.lineStrings=function(t,e,i){void 0===i&&(i={});return a(t.map((function(t){return s(t,e)})),i)};function a(t,e){void 0===e&&(e={});var i={type:"FeatureCollection"};e.id&&(i.id=e.id);e.bbox&&(i.bbox=e.bbox);i.features=t;return i}i.featureCollection=a;function l(t,e,i){void 0===i&&(i={});return r({type:"MultiLineString",coordinates:t},e,i)}i.multiLineString=l;function c(t,e,i){void 0===i&&(i={});return r({type:"MultiPoint",coordinates:t},e,i)}i.multiPoint=c;function u(t,e,i){void 0===i&&(i={});return r({type:"MultiPolygon",coordinates:t},e,i)}i.multiPolygon=u;i.geometryCollection=function(t,e,i){void 0===i&&(i={});return r({type:"GeometryCollection",geometries:t},e,i)};i.round=function(t,e){void 0===e&&(e=0);if(e&&!(e>=0))throw new Error("precision must be a positive number");var i=Math.pow(10,e||0);return Math.round(t*i)/i};function h(t,e){void 0===e&&(e="kilometers");var r=i.factors[e];if(!r)throw new Error(e+" units is invalid");return t*r}i.radiansToLength=h;function p(t,e){void 0===e&&(e="kilometers");var r=i.factors[e];if(!r)throw new Error(e+" units is invalid");return t/r}i.lengthToRadians=p;i.lengthToDegrees=function(t,e){return d(p(t,e))};i.bearingToAzimuth=function(t){var e=t%360;e<0&&(e+=360);return e};function d(t){return 180*(t%(2*Math.PI))/Math.PI}i.radiansToDegrees=d;i.degreesToRadians=function(t){return t%360*Math.PI/180};i.convertLength=function(t,e,i){void 0===e&&(e="kilometers");void 0===i&&(i="kilometers");if(!(t>=0))throw new Error("length must be a positive number");return h(p(t,e),i)};i.convertArea=function(t,e,r){void 0===e&&(e="meters");void 0===r&&(r="kilometers");if(!(t>=0))throw new Error("area must be a positive number");var n=i.areaFactors[e];if(!n)throw new Error("invalid original units");var o=i.areaFactors[r];if(!o)throw new Error("invalid final units");return t/n*o};function f(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}i.isNumber=f;i.isObject=function(t){return!!t&&t.constructor===Object};i.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!f(t))throw new Error("bbox must only contain numbers")}))};i.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}},{}],12:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/helpers");i.getCoord=function(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")};i.getCoords=function(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")};i.containsNumber=function t(e){if(e.length>1&&r.isNumber(e[0])&&r.isNumber(e[1]))return!0;if(Array.isArray(e[0])&&e[0].length)return t(e[0]);throw new Error("coordinates must only contain numbers")};i.geojsonType=function(t,e,i){if(!e||!i)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+i+": must be a "+e+", given "+t.type)};i.featureOf=function(t,e,i){if(!t)throw new Error("No feature passed");if(!i)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+i+": must be a "+e+", given "+t.geometry.type)};i.collectionOf=function(t,e,i){if(!t)throw new Error("No featureCollection passed");if(!i)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+i+", FeatureCollection required");for(var r=0,n=t.features;r<n.length;r++){var o=n[r];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!o.geometry||o.geometry.type!==e)throw new Error("Invalid input to "+i+": must be a "+e+", given "+o.geometry.type)}};i.getGeom=function(t){return"Feature"===t.type?t.geometry:t};i.getType=function(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}},{"@turf/helpers":11}],13:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=r(t("@turf/distance")),o=t("@turf/meta");i.default=function(t,e){void 0===e&&(e={});return o.segmentReduce(t,(function(t,i){var r=i.geometry.coordinates;return t+n.default(r[0],r[1],e)}),0)}},{"@turf/distance":9,"@turf/meta":16}],14:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=t("@turf/helpers"),o=t("@turf/invariant"),s=r(t("@turf/line-segment")),a=t("@turf/meta"),l=r(t("geojson-rbush"));function c(t,e){var i=o.getCoords(t),r=o.getCoords(e);if(2!==i.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==r.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var s=i[0][0],a=i[0][1],l=i[1][0],c=i[1][1],u=r[0][0],h=r[0][1],p=r[1][0],d=r[1][1],f=(d-h)*(l-s)-(p-u)*(c-a),m=(p-u)*(a-h)-(d-h)*(s-u),_=(l-s)*(a-h)-(c-a)*(s-u);if(0===f)return null;var g=m/f,y=_/f;if(g>=0&&g<=1&&y>=0&&y<=1){var v=s+g*(l-s),x=a+g*(c-a);return n.point([v,x])}return null}i.default=function(t,e){var i={},r=[];"LineString"===t.type&&(t=n.feature(t));"LineString"===e.type&&(e=n.feature(e));if("Feature"===t.type&&"Feature"===e.type&&null!==t.geometry&&null!==e.geometry&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var u=c(t,e);u&&r.push(u);return n.featureCollection(r)}var h=l.default();h.load(s.default(e));a.featureEach(s.default(t),(function(t){a.featureEach(h.search(t),(function(e){var n=c(t,e);if(n){var s=o.getCoords(n).join(",");if(!i[s]){i[s]=!0;r.push(n)}}}))}));return n.featureCollection(r)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/line-segment":15,"@turf/meta":16,"geojson-rbush":20}],15:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/helpers"),n=t("@turf/invariant"),o=t("@turf/meta");i.default=function(t){if(!t)throw new Error("geojson is required");var e=[];o.flattenEach(t,(function(t){!function(t,e){var i=[],o=t.geometry;if(null!==o){switch(o.type){case"Polygon":i=n.getCoords(o);break;case"LineString":i=[n.getCoords(o)]}i.forEach((function(i){var n=function(t,e){var i=[];t.reduce((function(t,n){var o,s,a,l,c,u,h=r.lineString([t,n],e);h.bbox=(s=n,a=(o=t)[0],l=o[1],c=s[0],u=s[1],[a<c?a:c,l<u?l:u,a>c?a:c,l>u?l:u]);i.push(h);return n}));return i}(i,t.properties);n.forEach((function(t){t.id=e.length;e.push(t)}))}))}}(t,e)}));return r.featureCollection(e)}},{"@turf/helpers":11,"@turf/invariant":12,"@turf/meta":16}],16:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=t("@turf/helpers");function n(t,e,i){if(null!==t)for(var r,o,s,a,l,c,u,h,p=0,d=0,f=t.type,m="FeatureCollection"===f,_="Feature"===f,g=m?t.features.length:1,y=0;y<g;y++){l=(h=!!(u=m?t.features[y].geometry:_?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<l;v++){var x=0,b=0;if(null!==(a=h?u.geometries[v]:u)){c=a.coordinates;var w=a.type;p=!i||"Polygon"!==w&&"MultiPolygon"!==w?0:1;switch(w){case null:break;case"Point":if(!1===e(c,d,y,x,b))return!1;d++;x++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(!1===e(c[r],d,y,x,b))return!1;d++;"MultiPoint"===w&&x++}"LineString"===w&&x++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-p;o++){if(!1===e(c[r][o],d,y,x,b))return!1;d++}"MultiLineString"===w&&x++;"Polygon"===w&&b++}"Polygon"===w&&x++;break;case"MultiPolygon":for(r=0;r<c.length;r++){b=0;for(o=0;o<c[r].length;o++){for(s=0;s<c[r][o].length-p;s++){if(!1===e(c[r][o][s],d,y,x,b))return!1;d++}b++}x++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===n(a.geometries[r],e,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function o(t,e){var i;switch(t.type){case"FeatureCollection":for(i=0;i<t.features.length&&!1!==e(t.features[i].properties,i);i++);break;case"Feature":e(t.properties,0)}}function s(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var i=0;i<t.features.length&&!1!==e(t.features[i],i);i++);}function a(t,e){var i,r,n,o,s,a,l,c,u,h,p=0,d="FeatureCollection"===t.type,f="Feature"===t.type,m=d?t.features.length:1;for(i=0;i<m;i++){a=d?t.features[i].geometry:f?t.geometry:t;c=d?t.features[i].properties:f?t.properties:{};u=d?t.features[i].bbox:f?t.bbox:void 0;h=d?t.features[i].id:f?t.id:void 0;s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1;for(n=0;n<s;n++)if(null!==(o=l?a.geometries[n]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,p,c,u,h))return!1;break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===e(o.geometries[r],p,c,u,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,c,u,h))return!1;p++}}function l(t,e){a(t,(function(t,i,n,o,s){var a,l=null===t?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==e(r.feature(t,n,{bbox:o,id:s}),i,0)&&void 0}switch(l){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var c=0;c<t.coordinates.length;c++){var u={type:a,coordinates:t.coordinates[c]};if(!1===e(r.feature(u,n),i,c))return!1}}))}function c(t,e){l(t,(function(t,i,o){var s=0;if(t.geometry){var a=t.geometry.type;if("Point"!==a&&"MultiPoint"!==a){var l,c=0,u=0,h=0;return!1!==n(t,(function(n,a,p,d,f){if(void 0===l||i>c||d>u||f>h){l=n;c=i;u=d;h=f;s=0}else{var m=r.lineString([l,n],t.properties);if(!1===e(m,i,o,f,s))return!1;s++;l=n}}))&&void 0}}}))}function u(t,e){if(!t)throw new Error("geojson is required");l(t,(function(t,i,n){if(null!==t.geometry){var o=t.geometry.type,s=t.geometry.coordinates;switch(o){case"LineString":if(!1===e(t,i,n,0,0))return!1;break;case"Polygon":for(var a=0;a<s.length;a++)if(!1===e(r.lineString(s[a],t.properties),i,n,a))return!1}}}))}i.coordAll=function(t){var e=[];n(t,(function(t){e.push(t)}));return e};i.coordEach=n;i.coordReduce=function(t,e,i,r){var o=i;n(t,(function(t,r,n,s,a){o=0===r&&void 0===i?t:e(o,t,r,n,s,a)}),r);return o};i.featureEach=s;i.featureReduce=function(t,e,i){var r=i;s(t,(function(t,n){r=0===n&&void 0===i?t:e(r,t,n)}));return r};i.findPoint=function(t,e){e=e||{};if(!r.isObject(e))throw new Error("options is invalid");var i,n=e.featureIndex||0,o=e.multiFeatureIndex||0,s=e.geometryIndex||0,a=e.coordIndex||0,l=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n);l=l||t.features[n].properties;i=t.features[n].geometry;break;case"Feature":l=l||t.properties;i=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":i=t;break;default:throw new Error("geojson is invalid")}if(null===i)return null;var c=i.coordinates;switch(i.type){case"Point":return r.point(c,l,e);case"MultiPoint":o<0&&(o=c.length+o);return r.point(c[o],l,e);case"LineString":a<0&&(a=c.length+a);return r.point(c[a],l,e);case"Polygon":s<0&&(s=c.length+s);a<0&&(a=c[s].length+a);return r.point(c[s][a],l,e);case"MultiLineString":o<0&&(o=c.length+o);a<0&&(a=c[o].length+a);return r.point(c[o][a],l,e);case"MultiPolygon":o<0&&(o=c.length+o);s<0&&(s=c[o].length+s);a<0&&(a=c[o][s].length-a);return r.point(c[o][s][a],l,e)}throw new Error("geojson is invalid")};i.findSegment=function(t,e){e=e||{};if(!r.isObject(e))throw new Error("options is invalid");var i,n=e.featureIndex||0,o=e.multiFeatureIndex||0,s=e.geometryIndex||0,a=e.segmentIndex||0,l=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n);l=l||t.features[n].properties;i=t.features[n].geometry;break;case"Feature":l=l||t.properties;i=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":i=t;break;default:throw new Error("geojson is invalid")}if(null===i)return null;var c=i.coordinates;switch(i.type){case"Point":case"MultiPoint":return null;case"LineString":a<0&&(a=c.length+a-1);return r.lineString([c[a],c[a+1]],l,e);case"Polygon":s<0&&(s=c.length+s);a<0&&(a=c[s].length+a-1);return r.lineString([c[s][a],c[s][a+1]],l,e);case"MultiLineString":o<0&&(o=c.length+o);a<0&&(a=c[o].length+a-1);return r.lineString([c[o][a],c[o][a+1]],l,e);case"MultiPolygon":o<0&&(o=c.length+o);s<0&&(s=c[o].length+s);a<0&&(a=c[o][s].length-a-1);return r.lineString([c[o][s][a],c[o][s][a+1]],l,e)}throw new Error("geojson is invalid")};i.flattenEach=l;i.flattenReduce=function(t,e,i){var r=i;l(t,(function(t,n,o){r=0===n&&0===o&&void 0===i?t:e(r,t,n,o)}));return r};i.geomEach=a;i.geomReduce=function(t,e,i){var r=i;a(t,(function(t,n,o,s,a){r=0===n&&void 0===i?t:e(r,t,n,o,s,a)}));return r};i.lineEach=u;i.lineReduce=function(t,e,i){var r=i;u(t,(function(t,n,o,s){r=0===n&&void 0===i?t:e(r,t,n,o,s)}));return r};i.propEach=o;i.propReduce=function(t,e,i){var r=i;o(t,(function(t,n){r=0===n&&void 0===i?t:e(r,t,n)}));return r};i.segmentEach=c;i.segmentReduce=function(t,e,i){var r=i,n=!1;c(t,(function(t,o,s,a,l){r=!1===n&&void 0===i?t:e(r,t,o,s,a,l);n=!0}));return r}},{"@turf/helpers":11}],17:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=r(t("@turf/bearing")),o=r(t("@turf/distance")),s=r(t("@turf/destination")),a=r(t("@turf/line-intersect")),l=t("@turf/meta"),c=t("@turf/helpers"),u=t("@turf/invariant");i.default=function(t,e,i){void 0===i&&(i={});var r=c.point([1/0,1/0],{dist:1/0}),h=0;l.flattenEach(t,(function(t){for(var l=u.getCoords(t),p=0;p<l.length-1;p++){var d=c.point(l[p]);d.properties.dist=o.default(e,d,i);var f=c.point(l[p+1]);f.properties.dist=o.default(e,f,i);var m=o.default(d,f,i),_=Math.max(d.properties.dist,f.properties.dist),g=n.default(d,f),y=s.default(e,_,g+90,i),v=s.default(e,_,g-90,i),x=a.default(c.lineString([y.geometry.coordinates,v.geometry.coordinates]),c.lineString([d.geometry.coordinates,f.geometry.coordinates])),b=null;if(x.features.length>0){(b=x.features[0]).properties.dist=o.default(e,b,i);b.properties.location=h+o.default(d,b,i)}if(d.properties.dist<r.properties.dist){(r=d).properties.index=p;r.properties.location=h}if(f.properties.dist<r.properties.dist){(r=f).properties.index=p+1;r.properties.location=h+m}b&&b.properties.dist<r.properties.dist&&((r=b).properties.index=p);h+=m}}));return r}},{"@turf/bearing":4,"@turf/destination":8,"@turf/distance":9,"@turf/helpers":11,"@turf/invariant":12,"@turf/line-intersect":14,"@turf/meta":16}],18:[function(t,e,i){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});var n=r(t("@turf/clone")),o=r(t("@turf/distance")),s=t("@turf/meta");i.default=function(t,e){if(!t)throw new Error("targetPoint is required");if(!e)throw new Error("points is required");var i,r=1/0,a=0;s.featureEach(e,(function(e,i){var n=o.default(t,e);if(n<r){a=i;r=n}}));(i=n.default(e.features[a])).properties.featureIndex=a;i.properties.distanceToPoint=r;return i}},{"@turf/clone":7,"@turf/distance":9,"@turf/meta":16}],19:[function(t,e,i){"use strict";var r=t("@turf/explode"),n=t("@turf/center"),o=t("@turf/nearest-point"),s=t("@turf/boolean-point-in-polygon"),a=t("@turf/helpers");function l(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var c=l(r),u=l(n),h=l(o),p=l(s);function d(t){for(var e=function(t){if("FeatureCollection"!==t.type)return"Feature"!==t.type?a.featureCollection([a.feature(t)]):a.featureCollection([t]);return t}(t),i=u.default(e),r=!1,n=0;!r&&n<e.features.length;){var o,s=e.features[n].geometry,l=!1;if("Point"===s.type)i.geometry.coordinates[0]===s.coordinates[0]&&i.geometry.coordinates[1]===s.coordinates[1]&&(r=!0);else if("MultiPoint"===s.type){var d=!1;o=0;for(;!d&&o<s.coordinates.length;){if(i.geometry.coordinates[0]===s.coordinates[o][0]&&i.geometry.coordinates[1]===s.coordinates[o][1]){r=!0;d=!0}o++}}else if("LineString"===s.type){o=0;for(;!l&&o<s.coordinates.length-1;){if(f(i.geometry.coordinates[0],i.geometry.coordinates[1],s.coordinates[o][0],s.coordinates[o][1],s.coordinates[o+1][0],s.coordinates[o+1][1])){l=!0;r=!0}o++}}else if("MultiLineString"===s.type)for(var m=0;m<s.coordinates.length;){l=!1;o=0;for(var _=s.coordinates[m];!l&&o<_.length-1;){if(f(i.geometry.coordinates[0],i.geometry.coordinates[1],_[o][0],_[o][1],_[o+1][0],_[o+1][1])){l=!0;r=!0}o++}m++}else"Polygon"!==s.type&&"MultiPolygon"!==s.type||p.default(i,s)&&(r=!0);n++}if(r)return i;var g=a.featureCollection([]);for(n=0;n<e.features.length;n++)g.features=g.features.concat(c.default(e.features[n]).features);return a.point(h.default(i,g).geometry.coordinates)}function f(t,e,i,r,n,o){return Math.sqrt((n-i)*(n-i)+(o-r)*(o-r))===Math.sqrt((t-i)*(t-i)+(e-r)*(e-r))+Math.sqrt((n-t)*(n-t)+(o-e)*(o-e))}e.exports=d;e.exports.default=d},{"@turf/boolean-point-in-polygon":5,"@turf/center":6,"@turf/explode":10,"@turf/helpers":11,"@turf/nearest-point":18}],20:[function(t,e,i){var r=t("rbush"),n=t("@turf/helpers"),o=t("@turf/meta"),s=t("@turf/bbox").default,a=o.featureEach,l=(o.coordEach,n.polygon,n.featureCollection);function c(t){var e=new r(t);e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");t.bbox=t.bbox?t.bbox:s(t);return r.prototype.insert.call(this,t)};e.load=function(t){var e=[];Array.isArray(t)?t.forEach((function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:s(t);e.push(t)})):a(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:s(t);e.push(t)}));return r.prototype.load.call(this,e)};e.remove=function(t,e){if("Feature"!==t.type)throw new Error("invalid feature");t.bbox=t.bbox?t.bbox:s(t);return r.prototype.remove.call(this,t,e)};e.clear=function(){return r.prototype.clear.call(this)};e.search=function(t){var e=r.prototype.search.call(this,this.toBBox(t));return l(e)};e.collides=function(t){return r.prototype.collides.call(this,this.toBBox(t))};e.all=function(){var t=r.prototype.all.call(this);return l(t)};e.toJSON=function(){return r.prototype.toJSON.call(this)};e.fromJSON=function(t){return r.prototype.fromJSON.call(this,t)};e.toBBox=function(t){var e;if(t.bbox)e=t.bbox;else if(Array.isArray(t)&&4===t.length)e=t;else if(Array.isArray(t)&&6===t.length)e=[t[0],t[1],t[3],t[4]];else if("Feature"===t.type)e=s(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=s(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}};return e}e.exports=c;e.exports.default=c},{"@turf/bbox":3,"@turf/helpers":11,"@turf/meta":16,rbush:21}],21:[function(t,e,i){r=this,n=function(){"use strict";function t(t,r,n,o,s){!function t(i,r,n,o,s){for(;o>n;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);t(i,r,Math.max(n,Math.floor(r-l*u/a+h)),Math.min(o,Math.floor(r+(a-l)*u/a+h)),s)}var p=i[r],d=n,f=o;for(e(i,n,r),s(i[o],p)>0&&e(i,n,o);d<f;){for(e(i,d,f),d++,f--;s(i[d],p)<0;)d++;for(;s(i[f],p)>0;)f--}0===s(i[n],p)?e(i,n,f):e(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1)}}(t,r,n||0,o||t.length-1,s||i)}function e(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function i(t,e){return t<e?-1:t>e?1:0}var r=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(t,e,i){if(!i)return e.indexOf(t);for(var r=0;r<e.length;r++)if(i(t,e[r]))return r;return-1}function o(t,e){s(t,0,t.children.length,e,t)}function s(t,e,i,r,n){n||(n=f(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(var o=e;o<i;o++){var s=t.children[o];a(n,t.leaf?r(s):s)}return n}function a(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function l(t,e){return t.minX-e.minX}function c(t,e){return t.minY-e.minY}function u(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function h(t){return t.maxX-t.minX+(t.maxY-t.minY)}function p(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function d(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function f(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(e,i,r,n,o){for(var s=[i,r];s.length;)if(!((r=s.pop())-(i=s.pop())<=n)){var a=i+Math.ceil((r-i)/n/2)*n;t(e,a,i,r,o),s.push(i,a,a,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(t){var e=this.data,i=[];if(!d(t,e))return i;for(var r=this.toBBox,n=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?r(s):s;d(t,a)&&(e.leaf?i.push(s):p(t,a)?this._all(s,i):n.push(s))}e=n.pop()}return i},r.prototype.collides=function(t){var e=this.data;if(!d(t,e))return!1;for(var i=[];e;){for(var r=0;r<e.children.length;r++){var n=e.children[r],o=e.leaf?this.toBBox(n):n;if(d(t,o)){if(e.leaf||p(t,o))return!0;i.push(n)}}e=i.pop()}return!1},r.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},r.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},r.prototype.clear=function(){return this.data=f([]),this},r.prototype.remove=function(t,e){if(!t)return this;for(var i,r,o,s=this.data,a=this.toBBox(t),l=[],c=[];s||l.length;){if(s||(s=l.pop(),r=l[l.length-1],i=c.pop(),o=!0),s.leaf){var u=n(t,s.children,e);if(-1!==u)return s.children.splice(u,1),l.push(s),this._condense(l),this}o||s.leaf||!p(s,a)?r?(i++,s=r.children[i],o=!1):s=null:(l.push(s),c.push(i),i=0,r=s,s=s.children[0])}return this},r.prototype.toBBox=function(t){return t},r.prototype.compareMinX=function(t,e){return t.minX-e.minX},r.prototype.compareMinY=function(t,e){return t.minY-e.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(t){return this.data=t,this},r.prototype._all=function(t,e){for(var i=[];t;)t.leaf?e.push.apply(e,t.children):i.push.apply(i,t.children),t=i.pop();return e},r.prototype._build=function(t,e,i,r){var n,s=i-e+1,a=this._maxEntries;if(s<=a)return o(n=f(t.slice(e,i+1)),this.toBBox),n;r||(r=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,r-1))),(n=f([])).leaf=!1,n.height=r;var l=Math.ceil(s/a),c=l*Math.ceil(Math.sqrt(a));m(t,e,i,c,this.compareMinX);for(var u=e;u<=i;u+=c){var h=Math.min(u+c-1,i);m(t,u,h,l,this.compareMinY);for(var p=u;p<=h;p+=l){var d=Math.min(p+l-1,h);n.children.push(this._build(t,p,d,r-1))}}return o(n,this.toBBox),n},r.prototype._chooseSubtree=function(t,e,i,r){for(;r.push(e),!e.leaf&&r.length-1!==i;){for(var n=1/0,o=1/0,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],c=u(l),h=(p=t,d=l,(Math.max(d.maxX,p.maxX)-Math.min(d.minX,p.minX))*(Math.max(d.maxY,p.maxY)-Math.min(d.minY,p.minY))-c);h<o?(o=h,n=c<n?c:n,s=l):h===o&&c<n&&(n=c,s=l)}e=s||e.children[0]}var p,d;return e},r.prototype._insert=function(t,e,i){var r=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(r,this.data,e,n);for(o.children.push(t),a(o,r);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(r,n,e)},r.prototype._split=function(t,e){var i=t[e],r=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,r);var s=this._chooseSplitIndex(i,n,r),a=f(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},r.prototype._splitRoot=function(t,e){this.data=f([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(t,e,i){for(var r,n,o,a,l,c,h,p=1/0,d=1/0,f=e;f<=i-e;f++){var m=s(t,0,f,this.toBBox),_=s(t,f,i,this.toBBox),g=(n=m,o=_,a=Math.max(n.minX,o.minX),l=Math.max(n.minY,o.minY),c=Math.min(n.maxX,o.maxX),h=Math.min(n.maxY,o.maxY),Math.max(0,c-a)*Math.max(0,h-l)),y=u(m)+u(_);g<p?(p=g,r=f,d=y<d?y:d):g===p&&y<d&&(d=y,r=f)}return r||i-e},r.prototype._chooseSplitAxis=function(t,e,i){var r=t.leaf?this.compareMinX:l,n=t.leaf?this.compareMinY:c;this._allDistMargin(t,e,i,r)<this._allDistMargin(t,e,i,n)&&t.children.sort(r)},r.prototype._allDistMargin=function(t,e,i,r){t.children.sort(r);for(var n=this.toBBox,o=s(t,0,e,n),l=s(t,i-e,i,n),c=h(o)+h(l),u=e;u<i-e;u++){var p=t.children[u];a(o,t.leaf?n(p):p),c+=h(o)}for(var d=i-e-1;d>=e;d--){var f=t.children[d];a(l,t.leaf?n(f):f),c+=h(l)}return c},r.prototype._adjustParentBBoxes=function(t,e,i){for(var r=i;r>=0;r--)a(e[r],t)},r.prototype._condense=function(t){for(var e=t.length-1,i=void 0;e>=0;e--)0===t[e].children.length?e>0?(i=t[e-1].children).splice(i.indexOf(t[e]),1):this.clear():o(t[e],this.toBBox)},r},"object"==typeof i&&void 0!==e?e.exports=n():(r=r||self).RBush=n();var r,n},{}]},{},[1])(1)}));class CustomHTMLControl{constructor(t){this.custom_html=t.custom_html}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.innerHTML=this.custom_html;return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class DownloadControl{constructor(t,e,i,r){this.interact_with_filters=t.interact_with_filters;this.notify_on_download=t.notify_on_download;this.included_fields=t.included_fields;this.features=e.concat(i.concat(r))}addListeners(){jQuery(document).on("click",".mapster-data-download",(()=>{this.downloadFeatures()}))}downloadFeatures(){let t=this.processFeatures();t.length>0?this.downloadCSV(t):alert("No features selected for download.")}processFeatures(t){let e=[];this.features.forEach((t=>{if(this.interact_with_filters&&window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(t.id)>-1)return;let i=t.data.location?t.data.location:t.data.line?t.data.line:t.data.polygon?t.data.polygon:null,r={};r.title=t.title;r.permalink=t.permalink;r.categories=t.categories.map((t=>t.name)).join(",");this.getRecursivePropertyValue(r,t.data.additional_details,"");r.geography=JSON.stringify(i);if(this.included_fields&&""!==this.included_fields){let t={};this.included_fields.split(",").forEach((e=>{let i=e.trim();r[i]&&(t[i]=r[i])}));r=t}e.push(r)}));return e}getRecursivePropertyValue(t,e,i){for(let r in e)Array.isArray(e[r])?t[i+r]=e[r].join(","):"object"==typeof e[r]?this.getRecursivePropertyValue(t,e[r],i+r+"_"):t[i+r]=JSON.stringify(e[r])}downloadCSV(t){const e=(t,e)=>null===e?"":e;let i=[];t.forEach((t=>{for(let e in t)-1===i.indexOf(e)&&i.push(e)}));t.forEach((t=>{i.forEach((e=>{t[e]||(t[e]="")}))}));let r=t.map((t=>i.map((i=>JSON.stringify(t[i],e).replace(/\\"/g,'""'))).join(",")));r.unshift(i.join(","));r=r.join("\r\n");var n=document.createElement("a"),o=new Blob(["\ufeff",r]),s=URL.createObjectURL(o);n.href=s;n.download="map-data-download.csv";document.body.appendChild(n);n.click();document.body.removeChild(n);if(this.notify_on_download){let t=[];jQuery(".mapster-category-control input").each((function(){jQuery(this).is(":checked")&&t.push(jQuery(this).closest("li").text().trim())}));fetch(`${window.mapster_params.rest_url}mapster-wp-maps/send-email`,{method:"POST",body:JSON.stringify({users:this.notify_on_download,active_filters:t})})}}onAdd(t){this.map=t;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-download-control";this._container.innerHTML='\n <div class="mapster-download-control-content">\n <button class="mapster-data-download">Download Data</button>\n </div>\n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ListControl{constructor(t,e,i,r,n,o){this.sort_by_distance=t.sort_by_distance;this.show_distance=t.show_distance;this.units=t.units;this.markers=n;this.mapLibrary=o;this.listing_type=t.listing_type;this.number_of_locations=t.number_of_locations;this.store_locator=t.store_locator_options.enable;this.sort_hours_by_day=t.store_locator_options.sort_hours_by_day;this.features=e.concat(i.concat(r));this.currentPage=1;this.storedBounds=null}storeLocatorHTML(t){return"<div>Upgrade to Mapster Pro to enable this functionality.</div>"}setHTML(t){const e=new MapsterHelpers;var i="<ul>",r=[];this.features.forEach(((t,i)=>{if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.indexOf(t.id)>-1)){var n=e.makeFeatureJSON(t.data);if(this.show_distance||this.sort_by_distance){var o=turf.distance(turf.center(n).geometry.coordinates,this.getCenter());t.distance=o*("imperial"===this.units?.621371:1)}r.push(t)}}));this.sort_by_distance&&(r=r.sort(((t,e)=>t.distance>e.distance?1:-1)));var n=[];r.forEach(((t,e)=>{"paginate"===this.listing_type?this.number_of_locations*(this.currentPage-1)<=e&&this.number_of_locations*this.currentPage>e&&n.push(t):n=r}));this.store_locator?i=this.storeLocatorHTML(i,n):n.forEach((t=>{i+=`\n <li data-id="${t.id}">\n ${t.title}\n <em>${t.distance?t.distance.toFixed(2)+("imperial"===this.units?" miles":" km"):""}</em>\n </li>\n `}));i+="</ul>";if("paginate"===this.listing_type){i+='<div class="mapster-paging">';this.currentPage>1&&(i+='<span class="mapster-back dashicons dashicons-arrow-left"></span>');this.number_of_locations*this.currentPage<this.number_of_locations.length&&(i+='<span class="mapster-next dashicons dashicons-arrow-right"></span>');i+="</div>"}if(t)return i;jQuery(".mapster-list-control-content").html(i)}getStoreHTML(t){return""}getCenter(){return[this.map.getCenter().lng,this.map.getCenter().lat]}addListeners(){var t=this;const e=new MapsterHelpers;jQuery(document).on("click",".mapster-list-control li",(function(i){if(!i.isTrigger){var r=t.features.find((t=>parseInt(t.id)==jQuery(this).data("id"))),n=e.makeFeatureJSON(r.data).features[0];if("Point"===n.geometry.type){const e=t.markers.find((t=>t.mapsterProperties.id===r.id));e&&r.data.enable_popup&&t.openPopup(e,r);!e&&r.data.enable_popup&&t.openPopupNonMarker(r);t.centerMap(n.geometry.coordinates,15)}else{var o=turf.bbox(n);t.fitBounds(o,{padding:20})}if(t.store_locator){jQuery(".mapster-list-control-content").hide();jQuery(".mapster-list-control-single-content").show();jQuery(".mapster-list-control-single-content").html(t.getStoreHTML(r))}}}));jQuery(document).on("click",".mapster-next",(()=>{this.currentPage=this.currentPage+1;this.setHTML()}));jQuery(document).on("click",".mapster-back",(()=>{this.currentPage=this.currentPage-1;this.setHTML()}));jQuery(document).on("click",".mapster-store-locator-results",(()=>{jQuery(".mapster-list-control-content").show();jQuery(".mapster-list-control-single-content").hide();jQuery(".mapster-list-control-single-content").empty();this.fitBounds(this.storedBounds)}));jQuery(document).on("change",".mapster-cat-toggle",(()=>{this.setHTML()}))}openPopup(t,e){const i=new MapsterHelpers;t.setPopup(new this.mapLibrary.Popup(i.returnPopupOptions(e.data)).setHTML(i.getPopupHTML(e.id,e.data))).togglePopup()}openPopupNonMarker(t){let e=this;const i=setInterval((()=>{if(e.map.getBounds().contains(t.data.location.coordinates)){e.map.fire("click",{lngLat:t.data.location.coordinates,originalEvent:{}});clearInterval(i)}}),100)}centerMap(t,e){this.map.flyTo({center:t,zoom:e})}fitBounds(t,e){this.map.fitBounds(t,e)}onAdd(t){this.map=t;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`<div class="mapster-list-control-content" style="max-height : ${jQuery(this.map._container).height()-100}px">`+this.setHTML(!0)+`</div><div class="mapster-list-control-single-content" style="max-height : ${jQuery(this.map._container).height()}px;"></div>`;if(window.innerWidth<768&&this.store_locator){jQuery(this.map._container).css("overflow","visible");this._container.style.marginTop=`${jQuery(this.map._container).height()}px`;jQuery(this.map._container).after(`<div style="height: ${jQuery(this.map._container).height()}px"></div>`);jQuery(".maplibregl-control-container > div, .mapboxgl-control-container > div").width("100%");jQuery(".mapboxgl-ctrl-geocoder").width("100%")}this.addListeners();this.map.on("moveend",(()=>{this.setHTML()}));setTimeout((()=>{this.store_locator&&!jQuery(".mapster-store-locator .mapboxgl-ctrl-geocoder").length&&jQuery(".mapboxgl-ctrl-geocoder").prependTo(".mapster-store-locator")}),100);return this._container}onAddGoogleMap(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-list-control mapster-list-control-google"+(this.store_locator?" mapster-store-locator":"")+(window.innerWidth<768?" mapster-mobile":"");this._container.innerHTML=`<div class="mapster-list-control-content" style="max-height : ${jQuery(this.map.__gm.div).height()-100}px">`+this.setHTML(!0)+`</div><div class="mapster-list-control-single-content" style="max-height : ${jQuery(this.map.__gm.div).height()}px;"></div>`;this.addListeners();this.map.addListener("dragend",(()=>{this.setHTML()}));google.maps.event.addListenerOnce(this.map,"idle",(()=>{this.store_locator&&setTimeout((()=>{jQuery(".mapster-google-geocoder-input").addClass("geocoder-google-store-locator");jQuery(".mapster-google-geocoder-input").prependTo(".mapster-store-locator")}),1e3);const t=this.map.getBounds();this.storedBounds=[t.getSouthWest().lng(),t.getSouthWest().lat(),t.getNorthEast().lng(),t.getNorthEast().lat()]}));return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}
;class PitchToggle{constructor(t=-20,e=70,i=null){this._bearing=-20;this._pitch=70;this._minpitchzoom=i}onAdd(t){this._map=t;let e=this;this._btn=document.createElement("button");this._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d";this._btn.type="button";this._btn["aria-label"]="Toggle Pitch";this._btn.onclick=function(){if(0===t.getPitch()){let i={pitch:e._pitch,bearing:e._bearing};e._minpitchzoom&&t.getZoom()>e._minpitchzoom&&(i.zoom=e._minpitchzoom);t.easeTo(i);e._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-2d"}else{t.easeTo({pitch:0,bearing:0});e._btn.className="mapboxgl-ctrl-icon mapboxgl-ctrl-pitchtoggle-3d"}};this._container=document.createElement("div");this._container.className="mapboxgl-ctrl-group mapboxgl-ctrl";this._container.appendChild(this._btn);return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class CategoryControl{constructor(t,e,i,r,n,o,s,a,l,c,u){this.displayMode=t.category_display;this.checkboxMode=t.checkbox_display;this.initialVisibility=t.initial_visibility;this.preSelectedCategories=t.pre_selected_categories;this.independentChildren=t.independent_children;this.excludedCategories=t.excluded_categories;this.functionality=t.functionality;this.additional_filters=t.additional_filters;this.accordion_layout=t.accordion_layout;this.show_number_of_features=t.show_number_of_features;this.did_one_accordion=!1;this.markers=i;this.map_provider=a;this.circle_clustering=l;this.label_icon_clustering=c;this.marker_clustering=u;this.cluster_options=e;this.features=n.concat(o.concat(s));this.dataLayers=r;this.locations=n;this.lines=o;this.polygons=s}setMarkers(t){this.markers=t}organizeCategories(){var t=[];this.features.forEach((e=>{e.categories.forEach((e=>{-1===t.findIndex((t=>t.id===e.id))&&t.push(e)}))}));return t=this.filterCategories(t)}returnHTML(){return`\n <div>\n ${this.returnCategoryHTML(this.organizeCategories())}\n </div>\n `}returnCategoryHTML(t){var e="<ul>";t.filter((t=>0===t.parent)).forEach(((i,r)=>{var n=t.filter((t=>t.parent===i.id));e+=this.returnInputHTML(i,n);e+=this.returnChildrenHTML(i,t)}));return e+="</ul>"}returnChildrenHTML(t,e){var i="<ul>",r=e.filter((e=>e.parent===t.id));r.forEach((t=>{i+=this.returnInputHTML(t,[]);i+=this.returnChildrenHTML(t,e)}));i+="</ul>";0===r.length&&(i="");return i}returnInputHTML(t,e){var i=!0;!this.initialVisibility&&this.preSelectedCategories&&-1===this.preSelectedCategories.indexOf(t.id)&&(i=!1);return this.returnAccordionHTML(`\n <li>\n ${"checkbox"===this.checkboxMode?`\n <input class="mapster-cat-toggle" id="${t.id}" data-term="${t.id}" data-parent="${t.parent}" ${i?'checked="checked"':""} type="checkbox" />\n `:`\n <label class="mapster-switch">\n <input class="mapster-cat-toggle" id="${t.id}" data-term="${t.id}" data-parent="${t.parent}" ${i?'checked="checked"':""} type="checkbox" />\n <span class="mapster-slider mapster-round"></span>\n </label>\n `}\n ${"colors"===this.displayMode?`<div class="mapster-color-swatch" style="background-color: ${t.color};"></div>`:""}\n ${"icons"===this.displayMode?`<div class="mapster-icon-swatch" style="background-image: url(${t.icon});background-size: cover;"></div>`:""}\n <label for="${t.id}">${t.name} ${this.returnNumberOfFeatures(t)?`<span class="mapster-number-of-features">(${this.returnNumberOfFeatures(t)})</span>`:""}</label>\n </li>\n `,t,e)}setToggles(t){var e=jQuery(t).data("term"),i=jQuery(t).data("parent"),r=jQuery(t).is(":checked");if(!this.independentChildren)if(0===i)r?jQuery(`.mapster-cat-toggle[data-parent="${e}"]`).prop("checked",!0):jQuery(`.mapster-cat-toggle[data-parent="${e}"]`).prop("checked",!1);else if(r)jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!0);else{var n=!0;jQuery(`.mapster-cat-toggle[data-parent="${i}"]`).each((function(){jQuery(this).is(":checked")&&(n=!1)}));n&&jQuery(`.mapster-cat-toggle[data-term="${i}"]`).prop("checked",!1)}}returnIDsToHideFeatures(t){let e=[];this.features.forEach((i=>{if(i.categories.length>0)if("exclusive"===this.functionality)i.categories.find((e=>t.indexOf(e.id)>-1))&&e.push(i.id);else if("inclusive"===this.functionality){var r=!0;i.categories.forEach((e=>{-1===t.indexOf(e.id)&&(r=!1)}));r&&e.push(i.id)}}));return e}returnNumberOfFeatures(){return!1}adjustMarkers(t){let e=[];this.markers.forEach((i=>{const r=this.returnMarkerProperties(i);if(r.categories.length>0)if("exclusive"===this.functionality)if(r.categories.find((e=>t.indexOf(e.id)>-1))){this.changeMarker("hide",i);e.push(i.mapsterProperties.id)}else this.changeMarker("show",i);else if("inclusive"===this.functionality){var n=!0;if(r.categories.length>0){r.categories.forEach((e=>{-1===t.indexOf(e.id)&&(n=!1)}));if(n){this.changeMarker("hide",i);e.push(i.mapsterProperties.id)}else this.changeMarker("show",i)}}}));this.adjustMarkerClusters(e)}adjustMarkerClusters(t){if(this.marker_clustering){let e=["marker"];(new MapsterHelpers).makeClusters(this.map,this.map_provider,this.cluster_options,e,this.locations,[],[],t)}}returnAccordionHTML(t,e,i){return t}filterCategories(t){return t}changeMarker(t,e){"hide"===t?e.remove():"show"===t&&e.addTo(this.map)}changeLayerVisibility(){var t=[];jQuery(".mapster-cat-toggle").each((function(){jQuery(this).is(":checked")||t.push(jQuery(this).data("term"))}));var e=this.returnIDsToHideFeatures(t);this.setHiddenFeatures(e);this.adjustMarkers(t)}setHiddenFeatures(t){if(this.map.getLayer("symbol")){this.map.getLayer("symbol-clusters")&&(new MapsterHelpers).setClustering(this.map,this.map_provider,this.cluster_options,this.circle_clustering,this.label_icon_clustering,this.marker_clustering,this.markers,this.locations,this.lines,this.polygons,t);this.map.setLayoutProperty("symbol","text-size",["case",["in",["get","post_id"],["literal",t]],0,["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16]);this.map.setLayoutProperty("symbol","icon-size",["case",["in",["get","post_id"],["literal",t]],0,["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1])}if(this.map.getLayer("circle")){this.map.setPaintProperty("circle","circle-radius",["case",["in",["get","post_id"],["literal",t]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0]);this.map.setPaintProperty("circle","circle-stroke-width",["case",["in",["get","post_id"],["literal",t]],0,["has","circle_radius"],["to-number",["get","circle_radius"]],0])}this.map.getLayer("line")&&this.map.setPaintProperty("line","line-width",["case",["in",["get","post_id"],["literal",t]],0,["has","width"],["to-number",["get","width"]],2]);if(this.map.getLayer("fill")){const e=new MapsterHelpers;let i=this.polygons.filter((e=>-1===t.indexOf(e.id))),r=e.createLayerGeoJSON(this.map,"polygon","fill",[],[],i);this.map.getSource("fill").setData(r)}}returnMarkerProperties(t){return t.mapsterProperties}addListeners(){var t=this;jQuery(document).on("change",".mapster-cat-toggle",(function(){t.setToggles(this);t.changeLayerVisibility()}));jQuery(document).on("click",".mapster-accordion-indicator",(function(){let t=!1;jQuery(this).parent().hasClass("mapster-accordion-indicator-open")&&(t=!0);jQuery(".mapster-accordion-indicator").each((function(){if(jQuery(this).parent().next("ul").is(":visible")){jQuery(this).parent().next("ul").slideToggle(400,(()=>jQuery(this).parent().addClass("mapster-accordion-indicator-closed")));jQuery(this).parent().removeClass("mapster-accordion-indicator-open")}}));if(t)jQuery(this).parent().addClass("mapster-accordion-indicator-closed");else{jQuery(this).parent().addClass("mapster-accordion-indicator-open");jQuery(this).parent().next("ul").slideToggle()}}))}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-category-control";this._container.innerHTML=this.returnHTML();this.initialVisibility||setTimeout((()=>{this.changeLayerVisibility()}),10);this.addListeners();return this._container}onAddGoogleMap(t){this.map=t;this._container=document.createElement("div");this._container.className="mapster-category-control mapster-google-category-control";this._container.innerHTML=this.returnHTML();this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this.map=void 0}}
;class LayerControl{constructor(t){this.toggleable_layers=t.toggleable_layers;this.toggleable_layer_titles=t.toggleable_layer_titles;this.checkbox_type=t.checkbox_type}returnHTML(){let t='<ul class="mapster-layer-control-content">';const e=this.toggleable_layers.replace("\r","").split("\n"),i=this.toggleable_layer_titles.replace("\r","").split("\n");e.forEach(((e,r)=>{t+="<li>";const n=e.split(",");let o=!0,s=!0;n.forEach((t=>{if(""!==t){this.map.getLayer(t.trim())||(o=!1);"hidden"!==this.map.getLayoutProperty(t.trim(),"visibility")&&void 0===this.map.getLayoutProperty(t.trim(),"visibility")||(s=!1)}}));o?"checkbox"===this.checkbox_type?t+=`<input class="mapster-layer-toggle" data-layers="${e}" ${s?'checked="checked"':""} type="checkbox" /> ${i[r]}`:"radio"===this.checkbox_type?t+=`<input name="mapster-layer-control" class="mapster-layer-toggle" data-layers="${e}" ${s?'checked="checked"':""} type="radio" /> ${i[r]}`:"switch"===this.checkbox_type&&(t+=`<label class="mapster-switch">\n <input class="mapster-layer-toggle" data-layers="${e}" ${s?'checked="checked"':""} type="checkbox" />\n <span class="mapster-slider mapster-round"></span>\n </label> ${i[r]}`):alert("Please double check the layers you've set for the layer control: some don't exist in the style!");t+="</li>"}));t+="</ul>";return t}changeLayerVisibility(){let t=this;jQuery(".mapster-layer-toggle").each((function(){jQuery(this).data("layers").split(",").forEach((e=>{jQuery(this).is(":checked")?t.map.setLayoutProperty(e.trim(),"visibility","visible"):t.map.setLayoutProperty(e.trim(),"visibility","none")}))}))}addListeners(){var t=this;jQuery(document).on("change",".mapster-layer-toggle",(function(){t.changeLayerVisibility()}))}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-layer-control";const e=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(e)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class StyleControl{constructor(t){this.toggleable_styles=t.toggleable_styles;this.toggleable_styles_titles=t.toggleable_styles_titles;this.initial_style_title=t.initial_style_title;this.default_style=!1}returnHTML(){let t='<ul class="mapster-style-control-content">';this.default_style=this.map.getStyle();t+=`<li><input name="mapster-style-control" class="mapster-style-toggle" data-index="default" checked="checked" type="radio" /> ${this.initial_style_title}`;const e=this.toggleable_styles.replace("\r","").split("\n"),i=this.toggleable_styles_titles.replace("\r","").split("\n");e.forEach(((e,r)=>{if(""!==e){t+="<li>";t+=`<input name="mapster-style-control" class="mapster-style-toggle" data-index="${r}" type="radio" /> ${i[r]}`;t+="</li>"}}));t+="</ul>";return t}addListeners(){var t=this;new MapsterHelpers;jQuery(document).on("change",".mapster-style-toggle",(function(){const e=jQuery(this).data("index");if("default"!==e){const i=t.toggleable_styles.split("\n");i[e].indexOf("{")>-1?t.map.setStyle(JSON.parse(i[e])):t.map.setStyle(i[e]);t.map.fire("mapster_custom_style_load")}else{t.map.setStyle(t.default_style);t.map.fire("mapster_custom_style_load")}}))}onAdd(t){this.map=t;this._container=document.createElement("div");this._container.className="mapboxgl-ctrl mapster-style-control";const e=setInterval((()=>{if(this.map.isStyleLoaded()){this._container.innerHTML=this.returnHTML();clearInterval(e)}}),100);this.addListeners();return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class ElevationControl{constructor(t){this.lines=t.lines;this.post_id=t.post_id;this.single_line=t.single_line;this.open_on_load=t.open_on_load;this.profile_color=t.profile_color;this.units=t.units;this.show_line_length=t.show_line_length;this.profile_displayed=!1;this.last_line_displayed=!1}addListeners(){jQuery(document).on("click",".mapster-elevation-control-content",(()=>{if(this.profile_displayed){this.removeElevation();this.profile_displayed=!1;jQuery(".mapster-elevation-control-content").removeClass("mapster-elevation-control-active")}else{jQuery(".mapster-elevation-control-content");if(this.map.getSource("mapbox-dem"))this.addElevation(this.last_line_displayed);else{this.loadElevationData();this.map.once("idle",(()=>{this.addElevation(this.last_line_displayed)}))}this.profile_displayed=!0;jQuery(".mapster-elevation-control-content").addClass("mapster-elevation-control-active")}}));this.single_line&&this.open_on_load&&setTimeout((()=>{this.last_line_displayed=this.lines[0];jQuery(".mapster-elevation-control-content").click()}),1e3);this.single_line||this.map.on("click","line",(t=>{this.last_line_displayed=this.lines.find((e=>e.id===t.features[0].properties.post_id));this.profile_displayed&&jQuery(".mapster-elevation-control-content").click();jQuery(".mapster-elevation-control-content").click()}));this.map.on("mousemove",(()=>{this.map.getLayer("elevation-point-along-layer")&&this.map.setLayoutProperty("elevation-point-along-layer","visibility","none")}))}loadElevationData(){this.map.addSource("mapbox-dem",{type:"raster-dem",url:"mapbox://mapbox.terrain-rgb",tileSize:512,maxzoom:14});this.map.setTerrain({source:"mapbox-dem",exaggeration:1.5})}removeElevation(){document.getElementById("mapster-chartjs-container").remove()}addElevation(t){let e=[],i=turf.length(t.data.line);for(let r=0;r<i;r+=i/50){let i=turf.along(t.data.line,r),n=this.map.queryTerrainElevation(i.geometry.coordinates,{exaggerated:!1});"feet"===this.units&&(n*=3.28084);e.push(n)}let r=document.createElement("div");r.setAttribute("id","mapster-chartjs-container");let n=document.createElement("canvas");n.setAttribute("id","mapster-chartjs");document.getElementById(`mapster-wp-maps-${this.post_id}`).append(r);r.append(n);const o=new MapsterConstants;let s=e.map((t=>""));if(this.show_line_length){s=[];e.forEach(((t,e)=>{let r=i/50;"feet"===this.units&&(r*=.621371);let n=parseInt(e*r*10)/10;s.push(n)}))}new Chart(document.getElementById("mapster-chartjs"),{type:"line",data:{labels:s,datasets:[{label:"Elevation",data:e,fill:!1,borderColor:this.profile_color,pointRadius:0,tension:.2}]},options:o.returnElevationChartOptions(this.units,this.show_line_length),plugins:[o.returnElevationChartPlugin(this.map,t)]})}onAdd(t){this.map=t;this.storedBounds=this.map.getBounds();this._container=document.createElement("div");if(window.mapster_params.public){this._container.className="mapboxgl-ctrl mapster-elevation-control";this._container.innerHTML='\n <div class="mapster-elevation-control-content">\n <svg class="mapster-svg-mountain" focusable="false" viewBox="0 0 24 24" aria-hidden="true">\n <path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path>\n </svg>\n </div>\n ';this.addListeners()}return this._container}onRemove(){this._container.parentNode.removeChild(this._container);this._map=void 0}}class MapsterConstants{returnElevationChartPlugin(t,e){return{id:"corsair",afterInit:t=>{t.corsair={x:0,y:0}},afterEvent:(t,e)=>{const{chartArea:{top:i,bottom:r,left:n,right:o}}=t,{event:{x:s,y:a}}=e;if(s<n||s>o||a<i||a>r){t.corsair={x:s,y:a,draw:!1};t.draw()}else{t.corsair={x:s,y:a,draw:!0};t.draw()}},afterDatasetsDraw:(i,r,n)=>{const{ctx:o,chartArea:{top:s,bottom:a,left:l,right:c}}=i,{x:u,y:h,draw:p}=i.corsair;if(!p)return;o.lineWidth=n.width||0;o.setLineDash(n.dash||[]);o.strokeStyle=n.color||"black";o.save();o.beginPath();o.moveTo(u,a);o.lineTo(u,s);o.stroke();o.restore();const d=(u-l)/(c-l);let f=turf.length(e.data.line),m=turf.along(e.data.line,f*d);if(t.getSource("elevation-point-along")&&t.getLayer("elevation-point-along-layer")){t.getSource("elevation-point-along").setData(m);t.setLayoutProperty("elevation-point-along-layer","visibility","visible")}else{t.addSource("elevation-point-along",{type:"geojson",data:m});t.addLayer({id:"elevation-point-along-layer",type:"circle",source:"elevation-point-along"})}}}}returnElevationChartOptions(t,e){return{interaction:{intersect:!1,mode:"index"},scales:{x:{title:{display:!!e,text:"meters"===t?"KM":"Miles",font:{style:"italic",size:10}},grid:{display:!0},ticks:{font:{size:10}}}},maintainAspectRatio:!1,plugins:{legend:{display:!1},title:{display:!0,text:`Elevation (${"meters"===t?"m":"ft"})`},tooltip:{displayColors:!1,callbacks:{label:function(e){return parseInt(10*e.parsed.y)/10+" "+("meters"===t?"m":"ft")}}},corsair:{color:"#333",width:1}}}}returnStyleProviders(){return[{id:"streets",style:"mapbox://styles/mapbox/streets-v12"},{id:"outdoors",style:"mapbox://styles/mapbox/outdoors-v12"},{id:"light",style:"mapbox://styles/mapbox/light-v11"},{id:"dark",style:"mapbox://styles/mapbox/dark-v11"},{id:"satellite",style:"mapbox://styles/mapbox/satellite-v9"},{id:"satellite-streets",style:"mapbox://styles/mapbox/satellite-streets-v12"},{id:"custom-image",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"empty",style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(255,255,255,1)"}}]}},{id:"open-street-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"open-topo-map",style:this.returnJsonStyle("https://a.tile.opentopomap.org/{z}/{x}/{y}.png",'Map data: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)')},{id:"cyclo-osm",style:this.returnJsonStyle("https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",'<a href="https://github.com/cyclosm/cyclosm-cartocss-style/releases" title="CyclOSM - Open Bicycle render">CyclOSM</a> | Map data: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"toner-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"watercolor-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"terrain-stamen",style:this.returnJsonStyle("https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png",'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')},{id:"esri-satellite",style:this.returnJsonStyle("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}","Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community")},{id:"blank-map",style:this.returnJsonStyle("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')}]}returnJsonStyle(t,e){return{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:[t],tileSize:256,attribution:e}},layers:[{id:"simple-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22}]}}loaderHTML(){return'\n\t\t\t<div class="mapster-map-loader">\n\t\t\t\t<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#333">\n\t\t\t\t\t<g fill="none" fill-rule="evenodd">\n\t\t\t\t\t\t\t<g transform="translate(1 1)" stroke-width="2">\n\t\t\t\t\t\t\t\t\t<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>\n\t\t\t\t\t\t\t\t\t<path d="M36 18c0-9.94-8.06-18-18-18">\n\t\t\t\t\t\t\t\t\t\t\t<animateTransform\n\t\t\t\t\t\t\t\t\t\t\t\t\tattributeName="transform"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype="rotate"\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom="0 18 18"\n\t\t\t\t\t\t\t\t\t\t\t\t\tto="360 18 18"\n\t\t\t\t\t\t\t\t\t\t\t\t\tdur="1s"\n\t\t\t\t\t\t\t\t\t\t\t\t\trepeatCount="indefinite"/>\n\t\t\t\t\t\t\t\t\t</path>\n\t\t\t\t\t\t\t</g>\n\t\t\t\t\t</g>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t'}markerAsSVG(t){return"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(`\n <svg display="block" height="41px" width="27px" viewBox="0 0 27 41" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink">\n <g fill-rule="nonzero">\n <g transform="translate(3.0, 29.0)" fill="#000000">\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="10.5" ry="5.25002273"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="10.5" ry="5.25002273"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="9.5" ry="4.77275007"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="8.5" ry="4.29549936"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="7.5" ry="3.81822308"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="6.5" ry="3.34094679"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="5.5" ry="2.86367051"></ellipse>\n <ellipse opacity="0.04" cx="10.5" cy="5.80029008" rx="4.5" ry="2.38636864"></ellipse>\n </g>\n <g fill="${t}">\n <path 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"></path>\n </g>\n <g opacity="0.25" fill="${t}">\n <path 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"></path>\n </g>\n <g transform="translate(6.0, 7.0)" fill="#FFFFFF"></g>\n <g transform="translate(8.0, 8.0)">\n <circle fill="${t}" opacity="0.25" cx="5.5" cy="5.5" r="5.4999962"></circle>\n <circle fill="#FFFFFF" cx="5.5" cy="5.5" r="5.4999962"></circle>\n </g>\n </g>\n </svg>\n `)}}class MapsterHelpers{constructor(){this.queuedImages=[]}isMobile(){let t=!1;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(t=!0);return t}changeCursor(t,e,i){e.data.enable_popup&&(t.getCanvas().style.cursor="on"===i?"pointer":"grab")}formatResponse(t){["location","line","polygon"].forEach((e=>{t[e+"s"].forEach((i=>{this.setObjectProperties(i,t[e+"_template"]);this.setPopupStyles(i,t.popup_styles)}))}));return new Promise((e=>{e(t)}))}getDefaultCenter(){let t=[0,0];"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_lat&&window.mapster_params.mapster_default_lng&&(t=[parseFloat(window.mapster_params.mapster_default_lng),parseFloat(window.mapster_params.mapster_default_lat)]);return t}getDefaultZoom(){let t=2;"1"===window.mapster_params.activated&&window.mapster_params.mapster_default_zoom&&(t=parseFloat(window.mapster_params.mapster_default_zoom));return t}doHover(t,e){let i=e.data.line?"line":e.data.symbol?"symbol":e.data.circle?"circle":e.data.polygon?"fill":[],r="line"===i||"fill"===i?e.data:"circle"===i?e.data.circle:e.data.symbol;if(r.hover_effects&&r.hover_effects.hover_enabled){t.removeFeatureState({source:i});t.setFeatureState({source:i,id:e.id},{hover:!0})}}doHoverOut(t,e){let i=e.data.line?"line":e.data.symbol?"symbol":e.data.circle?"circle":e.data.polygon?"fill":[],r="line"===i||"fill"===i?e.data:"circle"===i?e.data.circle:e.data.symbol;r.hover_effects&&r.hover_effects.hover_enabled&&t.setFeatureState({source:i,id:e.id},{hover:!1})}doMarkerHover(t,e,i){let r=i.mapsterProperties.data;if(r.marker.hover_effects.hover_enabled){const n=new e.Marker({color:r.marker.hover_effects.hover_color,scale:parseFloat(r.marker.hover_effects.hover_scale)/100,rotation:parseFloat(r.marker.hover_effects.hover_rotation),anchor:r.marker.anchor});-1===n._element.className.indexOf("mapster-remove-hover")&&(n._element.className+=" mapster-remove-hover");-1===i._element.className.indexOf("mapster-hide-original")&&(i._element.className+=" mapster-hide-original");n.setLngLat([i._lngLat.lng,i._lngLat.lat]).addTo(t);return n}return!1}doMarkerHoverOut(t,e){e._element.className.indexOf("mapster-hide-original")>-1&&(e._element.className=e._element.className.replace(" mapster-hide-original",""));t.remove()}setMapCompare(t,e,i,r){
}applyProSearchFilter(t,e){
return e}setGeolocationOnLoad(t){
}setMapBreakpointSizes(t,e){
}async getImageData(t){return wp.media.attachment(t).fetch().then((t=>t))}async setCustomImageMap(t,e,i){
}loadModalSteps(t,e,i,r,n,o){const s=new MapsterConstants;let a=!1,l=[];if("create_point"===r){if(n)if(1===n.length){a=n[0].term_id;if(o.submission_interface.include_address_search){c(t);u()}else{u();h()}}else{c(t);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n <div class="mapster-category-container">\n ${n.map((t=>`\n <div class="mapster-category-tile mapster-cat-set" data-category="${t.term_id}">\n ${t.icon?`<div class="mapster-category-image"><img src="${t.icon}" /></div>`:""}\n ${t.name?`<div class="mapster-category-name"><p>${t.name}</p></div>`:""}\n ${t.description?`<div class="mapster-category-description"><p>${t.description}</p></div>`:""}\n </div>\n `)).join("")}\n </div>\n `)}else{c(t);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n <div class="mapster-category-container" data-category="none">\n <div class="mapster-category-tile mapster-cat-set">${o.custom_texts.add_point_text}</div>\n </div>\n `)}jQuery(document).on("click",`#mapster-submission-modal-${t} .mapster-category-tile.mapster-cat-set`,(function(){"none"!==jQuery(this).data("category")&&(a=jQuery(this).data("category"));u()}))}if("edit_point"===r){const e=window.mapster_params.user_submission_permalink;c(t);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n <iframe\n onload="jQuery('.mapster-map-loader').remove();"\n class="mapster-submission-embed"\n src="${e}?pagetype=search&map_id=${t}">\n </iframe>\n `)}window.onmessage=function(t){if(t.data&&t.data.indexOf){t.data.indexOf("set_point")>-1&&u(t.data.replace("set_point-",""));if(t.data.indexOf("close_modal")>-1){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}}};function c(t){jQuery(`.mapster-submit-${t} #mapster-submission-modal-overlay-${t}`).fadeIn(100);jQuery(`.mapster-submit-${t} #mapster-submission-modal-${t}`).fadeIn(150)}function u(r){o.submission_interface.include_address_search?jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n <div class="mapster-description-text"><p>${o.custom_texts.choose_how}</p></div>\n <div class="mapster-category-container">\n ${o.submission_interface.include_address_search?`<div class="mapster-category-tile mapster-method-set" data-method="address" style="max-width:none;"><p>${o.custom_texts.address_search}</p></div>`:""}\n <div class="mapster-category-tile mapster-method-set" data-method="click" style="max-width:none;"><p>${o.custom_texts.map_click}</p></div>\n </div>\n `):h();jQuery(document).on("click",`#mapster-submission-modal-${t} .mapster-category-tile.mapster-method-set`,(function(){if("address"===jQuery(this).data("method")){const r=new MapboxGeocoder({accessToken:o.submission_interface.mapbox_geocoder_access_token,mapboxgl:i,marker:!1});jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`<p>${o.custom_texts.search_location}</p>`);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`)[0].appendChild(r.onAdd(e));r.on("result",(function(){h()}))}"click"===jQuery(this).data("method")&&h()}));jQuery(document).on("click",`#mapster-wp-maps-${t} .mapster-selection-instructions button`,(function(i){const r=e.getCenter();let n=!0;if(o.administration.allowed_area){const t=JSON.parse(o.administration.allowed_area);turf.booleanPointInPolygon([r.lng,r.lat],t.features[0])||(n=!1)}jQuery(".mapboxgl-ctrl").show();jQuery(".mapster-selection-overlay").remove();l=[r.lng,r.lat];jQuery(`#mapster-submission-modal-overlay-${t}`).fadeIn(100);jQuery(`#mapster-submission-modal-${t}`).fadeIn(150);jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n <div class="mapster-description-text"><p>${n?o.custom_texts.selection_saved:o.custom_texts.selection_error}</p></div>\n <div class="mapster-category-container">\n <div class="mapster-category-tile mapster-method-set" data-method="click" style="max-width:none;"><p>${o.custom_texts.try_again}</p></div>\n ${n?`<div class="mapster-category-tile mapster-coords-set" style="max-width:none;"><p>${o.custom_texts.confirm}</p></div>`:""}\n </div>\n `)}));jQuery(document).on("click",`#mapster-submission-modal-${t} .mapster-category-tile.mapster-coords-set`,(function(){const e=window.mapster_params.user_submission_permalink;let i=!!o.administration.template_post&&o.administration.template_post.ID;if(o.administration.multiple_templates){let t=o.submission_interface.categories.indexOf(a);i=o.administration.template_posts[t]}let n=r?"&type=edit&post_id="+r:"";jQuery(`#mapster-submission-modal-${t} .mapster-submission-modal-content`).html(`\n ${s.loaderHTML()}\n <iframe\n onload="jQuery('.mapster-map-loader').remove();"\n class="mapster-submission-embed"\n src="${e}?category=${a}&coords=${l.join(",")}&map_id=${t}${n}">\n </iframe>\n `)}))}function h(){jQuery(".mapster-submission-modal-close").trigger("click");jQuery(".mapboxgl-ctrl").hide();jQuery(e._container).append(`\n <div class="mapster-selection-overlay">\n <div class="mapster-selection-instructions">\n <p>${o.custom_texts.drag_zoom}</p>\n <button>${o.custom_texts.capture_point}</button>\n </div>\n <svg version="1.1" id="Uploaded to svgrepo.com" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n width="32px" height="32px" viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">\n <style type="text/css">\n .dashing_een{fill:#141414;}\n .st0{fill:#141414;}\n </style>\n <path class="dashing_een" d="M15.5,21.5v-2c0-0.276,0.224-0.5,0.5-0.5s0.5,0.224,0.5,0.5v2c0,0.276-0.224,0.5-0.5,0.5\n S15.5,21.776,15.5,21.5z M16,13c0.276,0,0.5-0.224,0.5-0.5v-2c0-0.276-0.224-0.5-0.5-0.5s-0.5,0.224-0.5,0.5v2\n C15.5,12.776,15.724,13,16,13z M16,3c0.276,0,0.5-0.224,0.5-0.5v-2C16.5,0.224,16.276,0,16,0c-0.276,0-0.5,0.224-0.5,0.5v2\n C15.5,2.776,15.724,3,16,3z M16,32c0.276,0,0.5-0.224,0.5-0.5v-2c0-0.276-0.224-0.5-0.5-0.5s-0.5,0.224-0.5,0.5v2\n C15.5,31.776,15.724,32,16,32z M22,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C21.776,16.5,22,16.276,22,16z M13,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C12.776,16.5,13,16.276,13,16z M3,16c0-0.276-0.224-0.5-0.5-0.5h-2C0.224,15.5,0,15.724,0,16c0,0.276,0.224,0.5,0.5,0.5h2\n C2.776,16.5,3,16.276,3,16z M32,16c0-0.276-0.224-0.5-0.5-0.5h-2c-0.276,0-0.5,0.224-0.5,0.5s0.224,0.5,0.5,0.5h2\n C31.776,16.5,32,16.276,32,16z M27,16c0,6.065-4.935,11-11,11S5,22.065,5,16S9.935,5,16,5S27,9.935,27,16z M26,16.5h-1.5\n c-0.276,0-0.5-0.224-0.5-0.5s0.224-0.5,0.5-0.5H26c-0.255-5.115-4.387-9.245-9.5-9.5v1.5C16.5,7.776,16.276,8,16,8\n s-0.5-0.224-0.5-0.5V6c-5.113,0.255-9.245,4.385-9.5,9.5h1.5C7.776,15.5,8,15.724,8,16s-0.224,0.5-0.5,0.5H6\n c0.255,5.115,4.387,9.245,9.5,9.5v-1.5c0-0.276,0.224-0.5,0.5-0.5s0.5,0.224,0.5,0.5V26C21.613,25.745,25.745,21.615,26,16.5z"/>\n </svg>\n </div>\n `)}}setProjectionGlobe(t,e){
}create3DModels(t,e){
}setPopupStyles(t,e){if(t.data.popup_style){let i=t.data.popup_style,r=e.find((t=>t.id===i));t.data.popup_style=r}}setObjectProperties(t,e){for(var i in e)if(this.isObject(e[i])){null==t[i]&&(t[i]={});this.setObjectProperties(t[i],e[i])}else null==t[i]&&(t[i]=e[i])}isObject(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}makeFeatureJSON(t){let e=t.line?t.line:t.location?t.location:!!t.polygon&&t.polygon;return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:e.type,coordinates:e.coordinates}}]}}getStyle(t){const e=new MapsterConstants;if(""!==t.custom_mapbox_style)return t.custom_mapbox_style;if("custom-image"===t.map_provider)return e.returnStyleProviders().find((t=>"custom-image"===t.id)).style;if(""!==t.access_token){var i=t.map_tile_style_access_token;return e.returnStyleProviders().find((t=>t.id===i)).style}i=t.map_tile_style_no_access_token;return e.returnStyleProviders().find((t=>t.id===i)).style}addMapControl(t,e,i,r,n,o={}){e&&t.removeControl(e);if(i){const e=new n(o);t.addControl(e,r);return e}return!1}searchLocalFeatures(t,e,i,r,n){var o={type:"FeatureCollection",features:[]};i.concat(r.concat(n)).forEach((t=>{var e=this.makeFeatureJSON(t.data);o.features.push(this.makeGeocoderResult(t,e))}));let s=this.localFeaturesTextMatch(t,e,o.features);s.sort(((t,e)=>t.place_name>e.place_name?1:-1));return s}localFeaturesTextMatch(t,e,i){let r=[];const n=e.split(" ").filter((t=>""!==t));i.forEach((i=>{var o=!1;i.properties.searchableTexts.forEach((s=>{var a={type:"Feature",id:i.properties.id,place_name:jQuery("<div>").html(i.properties.place_name).text()};if(!(window.mapster_categories_hidden_features&&window.mapster_categories_hidden_features.length>0&&-1!==window.mapster_categories_hidden_features.indexOf(i.properties.id))){if("exact-match"===t&&s&&(s.toLowerCase().indexOf(e.toLowerCase())>-1||" "===e)&&!o){a.center=turf.center(i).geometry.coordinates;"Point"!==i.geometry.type&&(a.bbox=turf.bbox(i));r.push(a);o=!0}
}}))}));return r}initializeSlider(t,e){const i=t=>{jQuery("#mapster-slider ul").animate({left:jQuery("#mapster-slider ul li").width()*("right"===t?-1:1)},200,(()=>{jQuery("#mapster-slider ul li:first-child").appendTo("#mapster-slider ul");jQuery("#mapster-slider ul").css("left","")}))};if(!window.sliderClicksInitialized){jQuery(document).on("click","#mapster-slider .mapster-slider-control_prev",(function(){i("left")}));jQuery(document).on("click","#mapster-slider .mapster-slider-control_next",(function(){i("right")}));window.sliderClicksInitialized=!0}}makeHeatmap(t,e,i,r){
}createHeatmapProperties(t,e,i,r){
}fadeHeatmapFeatures(t,e){
}setClustering(t,e,i,r,n,o,s,a,l,c,u){if(n||r)return this.doSymbolClustering(t,e,i,r,n,a,l,c,u);o&&this.doMarkerClustering(t,e,i,o,s,a,u);return[]}doMarkerClustering(t,e,i,r,n,o,s){let a=i.cluster_by_category?i.categories_to_cluster.map((t=>"marker-"+t)):["marker"];this.makeClusters(t,e,i,a,o,[],[],s);t.on("render",(()=>{let e=[];a.forEach((i=>{if(!t.isSourceLoaded(i))return;const r=t.querySourceFeatures(i);e=e.concat(r.filter((t=>t.properties.id)).map((t=>t.properties.id)))}));n.forEach((i=>{-1===e.indexOf(i.mapsterProperties.id)?i.remove():(!i._popup||i._popup&&!i._popup.isOpen())&&i.addTo(t)}))}))}doSymbolClustering(t,e,i,r,n,o,s,a,l){var c=[];n&&(i.cluster_by_category?i.categories_to_cluster.forEach((t=>{c.push("symbol-"+t)})):c.push("symbol"));r&&(i.cluster_by_category?i.categories_to_cluster.forEach((t=>{c.push("circle-"+t)})):c.push("circle"));this.makeClusters(t,e,i,c,o,s,a,l);return c}makeClusters(t,e,i,r,n,o,s,a){r.forEach((e=>{t.getLayer(`${e}-cluster-count`)&&t.removeLayer(`${e}-cluster-count`);t.getLayer(`${e}-clusters`)&&t.removeLayer(`${e}-clusters`);t.getLayer(`${e}-clusters-border`)&&t.removeLayer(`${e}-clusters-border`);t.getLayer(e)&&t.removeLayer(e);if(t.getSource(e))try{t.removeSource(e)}catch(t){}}));r.forEach(((r,l)=>{let c,u=r.split("-")[0];if(t.getLayer(u)&&t.getSource(u)){t.removeLayer(u);t.removeSource(u)}c=r.indexOf("marker")>-1?this.createMarkerGeoJSON(n,r):this.createLayerGeoJSON(t,"location",r,n,o,s);a=a||[];var h=c.features.filter((t=>-1===a.indexOf(t.properties.post_id)));let p=!1;if(i.show_category_name){let t=n.concat(o.concat(s)),e=parseInt(r.split("-")[1]);t.forEach((t=>{p||(p=t.categories.find((t=>t.id===e)))}))}t.addSource(r,{type:"geojson",data:{type:"FeatureCollection",features:h},cluster:!0,clusterMaxZoom:14,clusterRadius:50});if(r.indexOf("marker")>-1)t.addLayer({id:r,source:r,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":0}});else{var d=this.getLayerExpressions("location",r.indexOf("symbol")>-1?"symbol":"circle",e);t.addLayer({id:r,source:r,type:r.split("-")[0],filter:["!",["has","point_count"]],paint:d.paint,layout:d.layout})}this.addIcons(t,r,c);let f="#51bbd6",m=100,_=20,g="#f1f075",y=750,v=30,x="#f28cb1",b=40;
t.addLayer({id:`${r}-clusters`,type:"circle",source:r,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],f,m,g,y,x],"circle-radius":["step",["get","point_count"],_,m,v,y,b]}});t.addLayer({id:`${r}-cluster-count`,type:"symbol",source:r,filter:["has","point_count"],layout:{"text-field":p?p.name:"{point_count_abbreviated}","text-font":"mapbox"===e?["DIN Offc Pro Medium","Arial Unicode MS Bold"]:["Open Sans Regular"],"text-size":12}});setTimeout((()=>{t.on("click",`${r}-clusters`,(e=>{const i=t.queryRenderedFeatures(e.point,{layers:[`${r}-clusters`]}),n=i[0].properties.cluster_id;t.getSource(r).getClusterExpansionZoom(n,((e,r)=>{t.easeTo({center:i[0].geometry.coordinates,zoom:r+1})}))}))}),500)}))}makeGeocoderResult(t,e){var i=e.features[0];i.properties={searchableTexts:[t.data.popup?t.data.popup.header_text:"",t.data.popup?t.data.popup.body_text:"",t.title,t.content],id:t.id,place_name:t.title};return i}modifyDropdown(t){t.container.classList.add("mapster-maps-dropdown");jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-search").replaceWith('<svg viewBox="0 0 32 32" class="mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-search" viewBox="0 0 32 32" aria-hidden="true">\n <path d="M24 11.305l-7.997 11.39L8 11.305z"/>\n </svg>');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").wrap('<div class="input-wrapper"></div>');jQuery(".mapster-maps-dropdown").find(".mapboxgl-ctrl-geocoder--input").attr("disabled",!0);jQuery(document).on("click",".mapster-maps-dropdown .input-wrapper",(()=>{t.setInput("");jQuery(".suggestions-wrapper .suggestions li").removeClass("active")}));jQuery(document).on("click",".mapboxgl-ctrl-geocoder--icon.mapboxgl-ctrl-geocoder--icon-close",(()=>{t.clear();jQuery(".suggestions-wrapper .suggestions").hide()}))}openExternalLink(t){t&&t.data.open_link_on_click&&t.data.click_link&&t.data.click_link.url&&(t.data.click_link.open_link_in_new_tab?window.open(t.data.click_link.url):window.open(t.data.click_link.url,"_self"))}getMapBounds(t,e,i){var r={type:"FeatureCollection",features:[]};[["location",t],["line",e],["polygon",i]].forEach((t=>{t[1].forEach((t=>{var e=this.makeFeatureJSON(t.data);r.features.push(e.features[0])}))}));return r.features.length>0?turf.bbox(r):null}openStoreLocatorClick(t,e){t.enable&&jQuery(`.mapster-store-locator-list[data-id="${e}"]`).click()}openSidebarClick(t,e,i,r,n,o){!t.enable&&e&&this.setSidebarHTML(i.data,r,n,o)}openPopup(t,e,i,r,n,o,s){if(!o.enable&&!s){i&&i.remove();if(r.data.popup_style){r.data.location&&"Point"===r.data.location.type&&(n=r.data.location.coordinates);let i=new e.Popup(this.returnPopupOptions(r.data)).setLngLat(n).setHTML(this.getPopupHTML(r.id,r.data));this.centerPopup(t,i,r);i.addTo(t);return i}}}centerPopup(t,e,i){
}mouseIsNear(t,e,i){if(t&&t.offset()){var r=t.offset().left-e,n=t.offset().top-e,o=r+t.width()+2*e,s=n+t.height()+2*e,a=i.pageX,l=i.pageY;return a>r&&a<o&&l>n&&l<s}return!1}getDirectionsLatLng(t){let e="";t.location&&(e=t.location.coordinates[1].toString()+","+t.location.coordinates[0].toString());if(t.line){let i=turf.center(t.line);e=i.geometry.coordinates[1].toString()+","+i.geometry.coordinates[0].toString()}if(t.polygon){let i=turf.center(t.polygon);e=i.geometry.coordinates[1].toString()+","+i.geometry.coordinates[0].toString()}return e}getPopupHTML(t,e){var i=this.getPopupStyle(e),r=this.returnPopupCSS(e),n=this.returnPopupLayout(e),o=this.returnPopupContent(e),s=this.returnPopupHTML(e),a="";"to-directions"===o.button_action&&(a=this.getDirectionsLatLng(e));n.enable_image&&"gallery"===o.image_type&&setTimeout((()=>{this.initializeSlider(`mapster-popup-${e.popup_style.id}`,o.images.length+1)}),400);return`\n <style>${i}</style>\n ${n.use_custom_css?`<style>${r.css_editor.replace(/#mapster-popup/g,`#mapster-popup-${e.popup_style.id}`)}</style>`:""}\n ${n.use_custom_html?this.replaceHTMLValues(s.html_editor,o):`<div id="mapster-popup-${e.popup_style.id}" class="map-popup-background ${n.popup_class} mapster-feature-popup-${t}">\n ${n.enable_header?`<div class="map-popup-header">\n <h2>${o.header_text}</h2>\n </div>`:""}\n ${n.enable_image&&"feature-image"===o.image_type?'<div class="map-popup-image"></div>':""}\n ${n.enable_image&&"gallery"===o.image_type?`<div class="map-popup-gallery">\n <div id="mapster-slider" style="height : ${r.image_height}px;">\n <div class="mapster-slider-control_next">></div>\n <div class="mapster-slider-control_prev"><</div>\n <ul>\n ${o.images.map((t=>`<li style="height : ${r.image_height}px; background-image: url(${t});"> </li>`)).join(" ")}\n </ul>\n </div>\n </div>`:""}\n ${n.enable_body?`<div class="map-popup-body">\n <p>${o.body_text}</p>\n </div>`:""}\n ${n.enable_footer?`<div class="map-popup-footer">\n ${"do-nothing"===o.button_action?`<button class="map-popup-footer-button">${o.button_text}</button>`:""}\n ${"to-post"===o.button_action?`<button class="map-popup-footer-button" onclick="${o.open_link_in_new_tab?`window.open('${e.popup.permalink}', '_blank');`:`window.open('${e.popup.permalink}', '_self');`}">\n ${o.button_text}\n </button>`:""}\n ${"to-link"===o.button_action?`<button class="map-popup-footer-button" onclick="${o.open_link_in_new_tab?`window.open('${o.button_url}', '_blank');`:`window.open('${o.button_url}', '_self');`}">\n ${o.button_text}\n </button>`:""}\n ${"to-directions"===o.button_action?`<button class="map-popup-footer-button" onclick="window.open('https://www.google.com/maps/dir/?api=1&destination=${a}', '_blank');">\n ${o.button_text}\n </button>`:""}\n ${"to-modal"===o.button_action?`<button class="map-popup-footer-button mapster-button-modal-open">\n ${o.button_text}\n </button>\n <div class="mapster-modal-content-in-popup"><embed style='width: 100%; height: ${window.innerHeight-300}px;' src='http://localhost:8888/wp-content/plugins/mapster-wordpress-maps/admin/includes/mapster-modal-shortcode.php?feature_id=${t}'></embed></div>`:""}\n </div>`:""}\n </div>`}\n `}getPopupStyle(t){var e=this.returnPopupCSS(t),i=this.returnPopupLayout(t),r=this.returnPopupContent(t),n=t.popup_style.id;return`\n .mapboxgl-popup .mapboxgl-popup-content, .maplibregl-popup .maplibregl-popup-content {\n padding: 0px;\n background: none;\n border: none;\n border-radius: none;\n box-shadow: none;\n }\n #mapster-popup-${n}.map-popup-background {\n background : ${e.background};\n text-align : ${e.align};\n border-radius: 3px;\n box-shadow: 0 1px 2px rgb(0 0 0 / 10%);\n }\n #mapster-popup-${n} .map-popup-header {\n background : ${e.header};\n padding: 10px;\n }\n #mapster-popup-${n} .map-popup-header h2 {\n all : revert;\n color : ${e.header_text};\n font-weight: bold;\n margin: 0;\n padding: 0;\n }\n #mapster-popup-${n} .map-popup-image {\n background-image : url("${r.featured_image?r.featured_image.url:""}");\n background-position : center center;\n background-size: cover;\n height : ${e.image_height}px;\n width: 100%;\n }\n #mapster-popup-${n} .map-popup-body {\n margin-top: -1px;\n background : ${e.body};\n padding: 10px;\n color : ${e.body_text};\n }\n #mapster-popup-${n} .map-popup-body p {\n padding: 0px;\n margin: 0px;\n }\n #mapster-popup-${n} .map-popup-footer {\n margin-top: -1px;\n background : ${e.footer};\n padding: 10px;\n }\n #mapster-popup-${n} .map-popup-footer .map-popup-footer-button {\n all : revert;\n background : ${e.button};\n border-color: ${e.button};\n color : ${e.button_text};\n padding: 5px;\n text-decoration: none;\n text-shadow: none;\n }\n #mapster-popup-${n} .map-popup-footer .map-popup-footer-button:hover {\n cursor: pointer;\n filter: brightness(1.15);\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color : ${e.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {\n\t\t\t\tborder-left-color : ${e.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {\n\t\t\t\tborder-right-color : ${e.pointer};\n display : ${i.enable_pointer?"block":"none"};\n\t\t\t}\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n\t\t\t.mapboxgl-popup.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip, .maplibregl-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color : ${e.pointer};\n display : ${i.enable_pointer?"block":"none"};\n }\n `}setSidebarHTML(t,e,i,r){var n="#mapster-wp-maps-"+r;jQuery(".mapster-sidebar-popup").remove();var o=jQuery(n).height(),s=(jQuery(n).width(),this.getPopupStyle(t)),a=this.returnPopupCSS(t),l=this.returnPopupLayout(t),c=this.returnPopupContent(t);l.enable_image&&"gallery"===c.image_type&&setTimeout((()=>{this.initializeSlider(`mapster-sidebar-popup-${t.popup_style.id}`,c.images.length+1)}),400);jQuery(document).on("click",".mapster-sidebar-popup-exit",(()=>{jQuery(".mapster-sidebar-popup").remove()}));const u=parseFloat(e),h=parseFloat(i),p=`\n <style>${s.replace(/-popup/g,"-sidebar-popup")}</style>\n ${l.use_custom_css?`<style>${a.css_editor.replace(/#mapster-popup/g,`#mapster-popup-${t.popup_style.id}`)}</style>`:""}\n <div id="mapster-sidebar-popup-${t.popup_style.id}" class="mapster-sidebar-popup" style="min-width: ${u}px; min-height: ${o/2}px; max-height: ${o}px; max-width: ${h}px;">\n <div class="mapster-sidebar-popup-exit">&#10006;</div>\n ${l.enable_header?`<div class="map-sidebar-popup-header">\n <h2>${c.header_text}</h2>\n </div>`:""}\n ${l.enable_image&&"feature-image"===c.image_type?'<div class="map-sidebar-popup-image"></div>':""}\n ${l.enable_image&&"gallery"===c.image_type?`<div class="map-sidebar-popup-gallery">\n <div id="mapster-slider" style="height : ${a.image_height}px;">\n <div class="mapster-slider-control_next">></div>\n <div class="mapster-slider-control_prev"><</div>\n <ul>\n ${c.images.map((t=>`<li style="height : ${a.image_height}px; background-image: url(${t});"> </li>`)).join(" ")}\n </ul>\n </div>\n </div>`:""}\n ${l.enable_body?`<div class="map-sidebar-popup-body">\n <p>${c.body_text}</p>\n </div>`:""}\n ${l.enable_footer?`<div class="map-sidebar-popup-footer">\n ${"do-nothing"===c.button_action?`<button class="map-sidebar-popup-footer-button">${c.button_text}</button>`:""}\n ${"to-post"===c.button_action?`<button class="map-sidebar-popup-footer-button" onclick="${c.open_link_in_new_tab?`window.open('${t.popup.permalink}', '_blank');`:`window.open('${t.popup.permalink}', '_self');`}">\n ${c.button_text}\n </button>`:""}\n ${"to-link"===c.button_action?`<button class="map-sidebar-popup-footer-button" onclick="${c.open_link_in_new_tab?`window.open('${c.button_url}', '_blank');`:`window.open('${c.button_url}', '_self');`}">\n ${c.button_text}\n </button>`:""}\n ${"to-modal"===c.button_action?`<button class="map-sidebar-popup-footer-button mapster-button-modal-open">\n ${c.button_text}\n </button>\n <div class="mapster-modal-content-in-popup">${c.modal_details}</div>`:""}\n </div>`:""}\n </div>\n `;jQuery(n).append(p)}replaceHTMLValues(t,e){let i;
return i}returnPopupHTML(t){return{html_editor:t.popup_style.html_editor}}returnPopupContent(t){return{header_text:t.popup.header_text,image_type:t.popup.image_type,featured_image:t.popup.featured_image,images:t.popup.images,body_text:t.popup.body_text,button_text:t.popup.button_text,button_action:t.popup.button_action,button_url:t.popup.button_url,modal_details:t.popup.modal_details,additional_details:t.additional_details,open_link_in_new_tab:t.popup.open_link_in_new_tab}}returnPopupLayout(t){return{enable_header:t.popup_style.enable_header,enable_image:t.popup_style.enable_image,enable_body:t.popup_style.enable_body,enable_footer:t.popup_style.enable_footer,enable_pointer:t.popup_style.enable_pointer,use_custom_css:t.popup_style.use_custom_css,use_custom_html:t.popup_style.use_custom_html,popup_class:t.popup_style.popup_class}}returnPopupOptions(t){return{className:"hover"===t.interaction?"mapster-hover-popup":"",closeButton:t.popup_style.close_button,closeOnClick:t.popup_style.close_on_click,closeMapMove:t.popup_style.close_on_map_move,maxWidth:t.popup_style.max_width+"px"}}returnPopupCSS(t){return{background:t.popup_style.background,header:t.popup_style.header,image_height:t.popup_style.image_height,body:t.popup_style.body,footer:t.popup_style.footer,button:t.popup_style.button,pointer:t.popup_style.pointer,header_text:t.popup_style.header_text,body_text:t.popup_style.body_text,button_text:t.popup_style.button_text,align:t.popup_style.align,css_editor:t.popup_style.css_editor,max_width:t.popup_style.max_width}}getMarkerStyles(t){var e=t.data;return{color:e.marker.color,scale:parseFloat(e.marker.scale)/100,rotation:parseFloat(e.marker.rotation),anchor:e.marker.anchor}}getLayerExpressions(t,e,i){if("line"===t)return{layout:{},paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"line-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_hover_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"line-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","hover_effects_hover_width"]],["has","width"],["to-number",["get","width"]],2],"line-dasharray":"mapbox"===i?["case",["==",!0,["to-boolean",["get","dashed_line"]]],["get","dash_properties_line_dash_array"],["literal",[1,0]]]:[1,0]}};if("polygon"===t){if("fill"===e)return{layout:{},paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","hover_effects_opacity"]],100],["has","opacity"],["/",["to-number",["get","opacity"]],100],1],"fill-outline-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_outline-color"],["has","outline-color"],["get","outline-color"],"rgba(0,0,0,0)"]}};if("fill-extrusion"===e)return"1"===window.mapster_params.activated?{layout:{},paint:{"fill-extrusion-color":["case",["boolean",["feature-state","hover"],!1],["get","hover_effects_hover_color"],["has","color"],["get","color"],"#000"],"fill-extrusion-opacity":.75,"fill-extrusion-base":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","3d_polygon_base"]],100],["has","3d_polygon_base"],["to-number",["get","3d_polygon_base"]],0],"fill-extrusion-height":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","3d_polygon_height"]],["has","3d_polygon_height"],["to-number",["get","3d_polygon_height"]],0]}}:{layout:{},paint:{}}}if("location"===t){if("circle"===e)return{layout:{},paint:{"circle-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_color"],["has","circle_color"],["get","circle_color"],"#000"],"circle-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_opacity"]],100],["has","circle_opacity"],["/",["to-number",["get","circle_opacity"]],100],1],"circle-radius":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_radius"]],["has","circle_radius"],["to-number",["get","circle_radius"]],0],"circle-stroke-width":["case",["boolean",["feature-state","hover"],!1],["to-number",["get","circle_hover_effects_hover_stroke-width"]],["has","circle_stroke-width"],["to-number",["get","circle_stroke-width"]],0],"circle-stroke-color":["case",["boolean",["feature-state","hover"],!1],["get","circle_hover_effects_hover_stroke-color"],["has","circle_stroke-color"],["get","circle_stroke-color"],"#000"],"circle-stroke-opacity":["case",["boolean",["feature-state","hover"],!1],["/",["to-number",["get","circle_hover_effects_hover_stroke-opacity"]],100],["has","circle_stroke-opacity"],["/",["to-number",["get","circle_stroke-opacity"]],100],1]}};if("symbol"===e)return{layout:{"text-field":["case",["has","label_text_properties_text-field"],["get","label_text_properties_text-field"],"New Text"],"text-font":["case",["==","Open Sans Regular",["get","label_text_properties_text-font"]],["literal",["Open Sans Regular"]],["==","Open Sans Bold",["get","label_text_properties_text-font"]],["literal",["Open Sans Bold"]],["==","Open Sans Italic",["get","label_text_properties_text-font"]],["literal",["Open Sans Italic"]],["==","Klokantech Noto Sans Regular",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Regular"]],["==","Klokantech Noto Sans Bold",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Bold"]],["==","Klokantech Noto Sans Italic",["get","label_text_properties_text-font"]],["literal",["Klokantech Noto Sans Italic"]],["==","Metropolis",["get","label_text_properties_text-font"]],["literal",["Metropolis"]],["==","Metropolis Bold",["get","label_text_properties_text-font"]],["literal",["Metropolis Bold"]],["==","Metropolis Regular Italic",["get","label_text_properties_text-font"]],["literal",["Metropolis Regular Italic"]],["literal",["Open Sans Regular"]]],"text-rotate":["case",["has","label_text_properties_text-rotate"],["to-number",["get","label_text_properties_text-rotate"]],0],"text-size":["case",["==",!1,["get","label_label_on"]],0,["has","label_text_properties_text-size"],["to-number",["get","label_text_properties_text-size"]],16],"icon-size":["case",["==",!1,["get","icon_icon_on"]],0,["has","icon_icon_properties_icon-size"],["/",["to-number",["get","icon_icon_properties_icon-size"]],100],1],"icon-rotate":["case",["has","icon_icon_properties_icon-rotate"],["to-number",["get","icon_icon_properties_icon-rotate"]],0],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-anchor":["case",["has","icon_icon_properties_icon-anchor"],["get","icon_icon_properties_icon-anchor"],"center"],"icon-offset":["case",["has","icon_icon_properties_offset_array"],["get","icon_icon_properties_offset_array"],["literal",[0,0]]],"text-offset":["case",["has","label_text_properties_offset_array"],["get","label_text_properties_offset_array"],["literal",[0,0]]]},paint:{"text-color":["case",["has","label_text_properties_text-color"],["get","label_text_properties_text-color"],"#000000"],"text-halo-width":["case",["has","label_text_properties_text-halo-width"],["to-number",["get","label_text_properties_text-halo-width"]],1],"text-halo-color":["case",["has","label_text_properties_text-halo-color"],["get","label_text_properties_text-halo-color"],"#FFFFFF"],"text-halo-blur":["case",["has","label_text_properties_text-halo-blur"],["/",["to-number",["get","label_text_properties_text-halo-blur"]],100],1],"text-opacity":["case",["has","label_text_properties_text-opacity"],["/",["to-number",["get","label_text_properties_text-opacity"]],100],1],"icon-opacity":["case",["has","icon_icon_properties_icon-opacity"],["/",["to-number",["get","icon_icon_properties_icon-opacity"]],100],1]}}}}addIcons(t,e,i){e.indexOf("symbol")>-1&&i.features.forEach((i=>{i.properties.icon_icon_on&&i.properties["icon_icon_properties_icon-image_url"]&&this.addNewIcon(t,i.properties["icon_icon_properties_icon-image_url"],i.properties["icon_icon_properties_icon-image_id"],(()=>{t.getLayer(e)&&t.setLayoutProperty(e,"icon-image",["case",["has","icon_icon_properties_icon-image_id"],["concat","icon-image-",["get","icon_icon_properties_icon-image_id"]],"none"])}))}))}addNewIcon(t,e,i,r){if(this.queuedImages.indexOf(`icon-image-${i}`)>-1)r();else{this.queuedImages.push(`icon-image-${i}`);e||r();"https:"===window.location.protocol&&e.indexOf("http://")>-1&&(e=e.replace("http","https"));var n=new Image;n.src=e;n.crossOrigin="";n.onload=function(){if(t.loaded()){t.hasImage(`icon-image-${i}`)?t.updateImage(`icon-image-${i}`,n):t.addImage(`icon-image-${i}`,n);r()}else t.once("idle",(()=>{t.hasImage(`icon-image-${i}`)?t.updateImage(`icon-image-${i}`,n):t.addImage(`icon-image-${i}`,n);r()}))}}}createLayerGeoJSON(t,e,i,r,n,o){var s={type:"FeatureCollection",features:[]};let a="line"===e?n:"location"===e?r:"polygon"===e?o:[],l=i.indexOf("-")>-1&&i.split("-")[1],c=i.indexOf("-")>-1?i.split("-")[0]:i;if("fill-extrusion"===i){c=i;l=!1}a.forEach((r=>{if(r.data[e]&&c===this.getLayerType(e,r.data)&&(!l||r.categories.find((t=>t.id===parseFloat(l))))){var n=this.makeFeatureJSON(r.data);if(n.features[0]){var o=this.makeFeatureWithProperties(r,n.features[0]);s.features.push(o)}r.data.open_popup_on_load&&-1===i.indexOf("-")&&setTimeout((()=>{if(t){const e=turf.pointOnFeature(n);t.fire("click",{lngLat:e.geometry.coordinates})}}),500)}}));return s}createMarkerGeoJSON(t,e){let i=!!e.indexOf("-")&&e.split("-")[1];var r={type:"FeatureCollection",features:[]};r.features=t.filter((t=>!i&&"marker"===t.data.location_style||!(!i||"marker"!==t.data.location_style||!t.categories.find((t=>t.id===parseFloat(i)))))).map((t=>{t.post_id=t.id;return{type:"Feature",properties:t,geometry:t.data.location}}));return r}makeFeatureWithProperties(t,e){var i=JSON.parse(JSON.stringify(e));i.id=t.id;i.properties.post_id=t.id;for(var r in t.data)-1===["polygon","line","location","popup","popup_style"].indexOf(r)&&this.assignToProperty(i,t.data,r);i.properties.dashed_line&&i.properties.dash_properties_dash_length&&(i.properties.dash_properties_line_dash_array=[parseFloat(i.properties.dash_properties_dash_length),parseFloat(i.properties.dash_properties_gap_length)]);(i.properties["label_text_properties_text-translate-x"]||i.properties["label_text_properties_text-translate-y"])&&(i.properties.label_text_properties_offset_array=[parseFloat(i.properties["label_text_properties_text-translate-x"]),parseFloat(i.properties["label_text_properties_text-translate-y"])]);(i.properties["icon_icon_properties_icon-translate-x"]||i.properties["icon_icon_properties_icon-translate-y"])&&(i.properties.icon_icon_properties_offset_array=[parseFloat(i.properties["icon_icon_properties_icon-translate-x"]),parseFloat(i.properties["icon_icon_properties_icon-translate-y"])]);return i}assignToProperty(t,e,i,r){if("object"==typeof e[i])for(var n in e[i])this.assignToProperty(t,e[i],n,r?r+"_"+i:i);else{var o=r?r+"_"+i:i;t.properties[o]=e[i]}}getLayerType(t,e){if("line"===t)return"line";if("polygon"===t){if(!e.polygon_style||"fill"===e.polygon_style)return"fill";if("fill-extrusion"===e.polygon_style)return"fill-extrusion"}if("location"===t){if("circle"===e.location_style)return"circle";if("label"===e.location_style)return"symbol"}}}class MapsterCore{constructor(){}setDataLayers(){}getPostData({post_id:t,single_feature_id:e}){const i=new MapsterHelpers;let r=e?`&single_feature_id=${e}`:"";return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/map${window.mapster_params.qd}id=${t}${r}`).then((t=>t.json())).then((t=>i.formatResponse(t)))}getFeaturesAdmin({locations_ids:t,lines_ids:e,polygons_ids:i,cats:r}){const n=t.concat(e.concat(i));return fetch(`${window.mapster_params.rest_url}mapster-wp-maps/features${window.mapster_params.qd}ids=${JSON.stringify(n)}&categories=${JSON.stringify(r)}`).then((t=>t.json()))}sortLocations({adminFeatures:t}){return t.filter((t=>t.data.location))}sortLines({adminFeatures:t}){return t.filter((t=>t.data.line))}sortPolygons({adminFeatures:t}){return t.filter((t=>t.data.polygon))}doClustering({map:t,map_provider:e,cluster_options:i,circle_clustering:r,label_icon_clustering:n,marker_clustering:o,markers:s,locations:a,lines:l,polygons:c,idsToHide:u}){return(new MapsterHelpers).setClustering(t,e,i,r,n,o,s,a,l,c,u)}loadCustomScripts({map:t,javascript:e,locations:i,lines:r,polygons:n}){e&&window[e]&&(0,window[e])(t,i.concat(r.concat(n)))}setMapStyle({map:t,map_type:e}){const i=new MapsterHelpers;"custom-image"===e.map_provider?i.setCustomImageMap(t,e,!0):e.custom_style_json&&""!==e.custom_style_json?t.setStyle(JSON.parse(e.custom_style_json)):t.setStyle(i.getStyle(e))}loadProjection({map:t,map_provider:e,projection:i}){"mapbox"===e&&t.setProjection({name:i,center:[0,30],parallels:[30,30]})}loadTerrain({map:t,map_provider:e,terrain:i}){if("mapbox"===e)if(i){if(!t.getSource("mapbox-mapster-dem")){t.addSource("mapbox-mapster-dem",{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14});t.setTerrain({source:"mapbox-mapster-dem",exaggeration:1.5});t.addLayer({id:"sky",type:"sky",paint:{"sky-type":"atmosphere","sky-atmosphere-sun":[0,0],"sky-atmosphere-sun-intensity":15}})}}else{t.getLayer("sky")&&t.removeLayer("sky");t.setTerrain(null);t.getSource("mapbox-mapster-dem")&&t.removeSource("mapbox-mapster-dem")}}layerClick({map:t,interactivity:e,clickedEvent:i,locations:r,lines:n,polygons:o}){if(e){let e=i.point?i.point:t.project(i.lngLat);var s=t.queryRenderedFeatures(e).filter((t=>["symbol","line","fill","circle"].indexOf(t.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&r.concat(n.concat(o)).find((t=>t.id===s[0].properties.post_id))}return!1}storeLocatorClick({clickedFeature:t,store_locator_options:e}){const i=new MapsterHelpers;t&&t.data.enable_popup&&("click"===t.data.interaction||i.isMobile()&&t.data.click_on_mobile)&&i.openStoreLocatorClick(e,t.id)}sidebarClick({post_id:t,clickedFeature:e,minimum_sidebar_width:i,maximum_sidebar_width:r,store_locator_options:n,open_popups_in_sidebar:o}){const s=new MapsterHelpers;e&&e.data.enable_popup&&("click"===e.data.interaction||s.isMobile()&&e.data.click_on_mobile)&&s.openSidebarClick(n,o,e,i,r,t)}externalClickLayer({clickedFeature:t}){(new MapsterHelpers).openExternalLink(t)}externalClickMarker({clickedMarker:t}){(new MapsterHelpers).openExternalLink(t)}popupClick({map:t,mapLibrary:e,clickedPopup:i,clickedFeature:r,clickedEvent:n,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(r&&r.data.enable_popup&&("click"===r.data.interaction||a.isMobile()&&r.data.click_on_mobile))return a.openPopup(t,e,i,r,n.lngLat,o,s)}layerHover({map:t,interactivity:e,hoveredEvent:i,locations:r,lines:n,polygons:o}){if(e){var s=t.queryRenderedFeatures(i.point).filter((t=>["symbol","line","fill","circle"].indexOf(t.source.split("-")[0])>-1));return!(!s[0]||"fill"===s[0].layer.id&&("fill"!==s[0].layer.id||0===s[0].layer.paint["fill-opacity"]))&&r.concat(n.concat(o)).find((t=>t.id===s[0].properties.post_id))}return!1}layerHoverEffect({map:t,interactivity:e,hoveredFeature:i}){const r=new MapsterHelpers;r.changeCursor(t,i,"on");
}popupHover({map:t,mapLibrary:e,hoveredPopup:i,hoveredFeature:r,hoveredEvent:n,store_locator_options:o}){const s=new MapsterHelpers;if(r&&r.data.enable_popup&&"hover"===r.data.interaction&&(!s.isMobile()||s.isMobile()&&r.data.click_on_mobile))return s.openPopup(t,e,i,r,n.lngLat,o)}markerClick({interactivity:t,clickedMarker:e}){return!!t&&e.mapsterProperties}markerHover({interactivity:t,hoveredMarker:e}){return!!t&&e.mapsterProperties}markerHoverEffect({map:t,mapLibrary:e,interactivity:i,hoveredMarker:r}){
}openMarkerClickPopup({map:t,mapLibrary:e,clickedMarker:i,clickedFeature:r,clickedPopup:n,store_locator_options:o,open_popups_in_sidebar:s}){const a=new MapsterHelpers;if(!o.enable&&!s&&r&&r.data.enable_popup&&("click"===r.data.interaction||a.isMobile()&&r.data.click_on_mobile)&&r.data.popup_style){const n=new e.Popup(a.returnPopupOptions(r.data));n.setHTML(a.getPopupHTML(r.id,r.data));a.centerPopup(t,n,r);i.setPopup(n)}}openMarkerHoverPopup({map:t,mapLibrary:e,hoveredMarker:i,hoveredFeature:r}){const n=new MapsterHelpers;if(r&&r.data.enable_popup&&"hover"===r.data.interaction&&!n.isMobile()&&r.data.popup_style&&!i.getPopup()){const o=new e.Popup(n.returnPopupOptions(r.data));o.setHTML(n.getPopupHTML(r.id,r.data));n.centerPopup(t,o,r);i.setPopup(o).togglePopup()}}markerHoverEffectOff({tempHoverMarker:t,hoveredMarker:e}){
}removeMarkerHoverPopup({hoveredMarker:t,hoveredFeature:e}){const i=new MapsterHelpers;e&&e.data.enable_popup&&"hover"===e.data.interaction&&!i.isMobile()&&(t&&!e.data.keep_popup_open_on_hover?t.setPopup(null):t&&e.data.keep_popup_open_on_hover&&jQuery(document).on("mousemove.mapster",(function(t){let r=jQuery(`.mapster-feature-popup-${e.id}`).closest(".mapboxgl-popup");i.mouseIsNear(r,2,t)?r.one("mouseleave",(function(){jQuery(document).off("mousemove.mapster")})):jQuery(document).off("mousemove.mapster")})))}layerHoverEffectOff({map:t,interactivity:e,hoveredFeature:i}){const r=new MapsterHelpers;r.changeCursor(t,i,"off");
}removePopupHover({hoveredFeature:t,hoveredPopup:e}){e&&!t.data.keep_popup_open_on_hover?e.remove():e&&t.data.keep_popup_open_on_hover&&jQuery(document).one("mousemove",(function(i){let r=jQuery(`.mapster-feature-popup-${t.id}`).closest(".mapboxgl-popup:hover");r.length?r.one("mouseleave",(function(){e.remove()})):e.remove()}))}setInteractivity({map:t,zoom_on_scroll:e,interactivity:i,allow_rotation_and_pitch:r}){e||t.scrollZoom.disable();if(!i){t.scrollZoom.disable();t.boxZoom.disable();t.dragRotate.disable();t.dragPan.disable();t.keyboard.disable();t.doubleClickZoom.disable();t.touchZoomRotate.disable()}if(i&&!r){t.dragRotate.disable();t.touchZoomRotate.disable()}}setFeaturesToMap({map:t,map_provider:e,locations:i,lines:r,polygons:n}){const o=new MapsterHelpers;[["line","line"],["polygon","fill"],["polygon","fill-extrusion"],["location","circle"],["location","symbol"],["location","3d-model"]].forEach((s=>{var a=o.createLayerGeoJSON(t,s[0],s[1],i,r,n);if("3d-model"!==s[1])if(t.getSource(s[1])){t.getSource(s[1]).setData(a);o.addIcons(t,s[1],a)}else{t.addSource(s[1],{type:"geojson",data:a});var l=o.getLayerExpressions(s[0],s[1],e);t.addLayer({id:s[1],source:s[1],type:s[1],paint:l.paint,layout:l.layout});o.addIcons(t,s[1],a)}else o.create3DModels(t,i)}))}setMarkersToMap({map:t,markers:e,mapLibrary:i,locations:r,marker_clustering:n}){const o=new MapsterHelpers;let s=[];e.forEach((t=>{r.find((e=>e.id===t.id))?s.push(t):t.remove()}));let a=[];a=a.concat(s);const l=r.filter((t=>"marker"===t.data.location_style));let c=[];l.sort(((t,e)=>{if(t.data.location.coordinates&&e.data.location.coordinates)return t.data.location.coordinates[1]>e.data.location.coordinates[1]?-1:1;if(!t.data.location.coordinates&&-1===c.indexOf(t.title)){alert(`A point is missing coordinates. See ${t.title}.`);c.push(t.title)}if(!e.data.location.coordinates&&-1===c.indexOf(e.title)){alert(`A point is missing coordinates. See ${e.title}.`);c.push(e.title)}}));l.forEach((e=>{if(!s.find((t=>t.mapsterProperties.id===e.id))){var r=o.getMarkerStyles(e),l=o.makeFeatureJSON(e.data).features[0].geometry.coordinates,c=new i.Marker(r).setLngLat(l);c.mapsterProperties=e;n||c.addTo(t);a.push(c);e.data.open_popup_on_load&&setTimeout((()=>{jQuery(c.getElement()).click()}),100)}}));return a}setHeatmap({map:t,mapLibrary:e,markers:i,locations:r,heatmap:n}){
}setMapSize({post_id:t,layout:e}){var i="#mapster-wp-maps-"+t;const r=new MapsterHelpers;if(!e.full_page){jQuery(i).height(e.height+e.height_units);jQuery(i).width(e.width+e.width_units);r.setMapBreakpointSizes(t,e)}if(e.full_page){jQuery(i).height(window.innerHeight+e.height_units);jQuery(i).width("100%")}if(e.full_page&&e.ignore_container){jQuery(`<div id="margin-compensator" style="padding-bottom: ${window.innerHeight}px"></div>`).insertAfter(i);jQuery(i).css("marginLeft",-1*jQuery(i).offset().left+"px");jQuery(i).width(window.innerWidth+"px");jQuery(i).css("position","absolute")}}setMapMoveEndVariables({map:t}){jQuery('.acf-field[data-name="manual_pitch"]').find(".acf-label label").html(`Manual Pitch <i>(currently: ${t.getPitch()})</i>`);jQuery('.acf-field[data-name="manual_zoom"]').find(".acf-label label").html(`Manual Zoom <i>(currently: ${t.getZoom()})</i>`);jQuery('.acf-field[data-name="manual_rotation"]').find(".acf-label label").html(`Manual Rotation <i>(currently: ${t.getBearing()})</i>`);const{lng:e,lat:i}=t.getCenter();jQuery('.acf-field[data-name="manual_latitude"]').find(".acf-label label").html(`Manual Latitude <i>(currently: ${i})</i>`);jQuery('.acf-field[data-name="manual_longitude"]').find(".acf-label label").html(`Manual Longitude <i>(currently: ${e})</i>`)}setDefaultAccessToken(){""===jQuery('.acf-field[data-name="access_token"]').find(":input").val()&&jQuery('.acf-field[data-name="access_token"]').find(":input").val(window.mapster_params.mapbox_access_token)}setMapType({map_type:t}){if("mapbox"!==t.map_provider){""!==t.access_token&&(maplibregl.accessToken=t.access_token);return maplibregl}if(""!==t.access_token){mapboxgl.accessToken=t.access_token;return mapboxgl}window.alert(window.mapster_params.strings["Mapbox Token Warning"])}setSubmissionModal({post_id:t,map:e,mapLibrary:i,submission:r}){const n=new MapsterHelpers;jQuery(document).on("click",`#mapster-submit-${t}`,(function(){const o=jQuery(this).data("type"),s=jQuery(this).data("header");jQuery(`.mapster-submit-${t} .mapster-submission-modal-title`).text(s);jQuery(`.mapster-submit-${t} #mapster-submission-modal-overlay-${t}`).parent().detach().appendTo("body");jQuery(`.mapster-submit-${t} #mapster-submission-modal-${t}`).parent().detach().appendTo("body");r.submission_interface.categories.length>0?fetch(`${window.mapster_params.rest_url}mapster-wp-maps/submission-info${window.mapster_params.qd}categories=${r.submission_interface.categories.join(",")}`).then((t=>t.json())).then((s=>{n.loadModalSteps(t,e,i,o,s,r)})):n.loadModalSteps(t,e,i,o,!1,r)}));jQuery(document).on("click",".mapster-submission-modal-close",(function(){jQuery(".mapster-submission-modal-overlay").fadeOut(50);jQuery(".mapster-submission-modal").fadeOut(100)}))}setMap({post_id:t,mapLibrary:e,map:i,locations:r,lines:n,polygons:o}){var s="mapster-wp-maps-"+t;const a=new MapsterHelpers;let l=!0,c="manual"===i.view.initial_load?[parseFloat(i.view.manual_longitude),parseFloat(i.view.manual_latitude)]:a.getDefaultCenter();if(jQuery(`#${s}`).data("latitude")&&"null"!==jQuery(`#${s}`).data("latitude")&&jQuery(`#${s}`).data("longitude")&&"null"!==jQuery(`#${s}`).data("longitude")){c=[parseFloat(jQuery(`#${s}`).data("longitude")),parseFloat(jQuery(`#${s}`).data("latitude"))];l=!1}let u="manual"===i.view.initial_load?parseFloat(i.view.manual_zoom):a.getDefaultZoom();if(jQuery(`#${s}`).data("zoom")&&"null"!==jQuery(`#${s}`).data("zoom")){u=parseFloat(jQuery(`#${s}`).data("zoom"));l=!1}const h={renderWorldCopies:i.layout.duplicate_horizontally,style:a.getStyle(i.map_type),container:s,fitBoundsOptions:{padding:20,maxZoom:18},projection:{name:i.map_type.projection?i.map_type.projection:"mercator",center:[0,30],parallels:[30,30]},bounds:"fit-features"===i.view.initial_load&&l?a.getMapBounds(r,n,o):null,center:c,zoom:u,pitch:i.view.manual_pitch?parseFloat(i.view.manual_pitch):0,bearing:i.view.manual_rotation?parseFloat(i.view.manual_rotation):0,attributionControl:!1,logoPosition:i.logo_control?i.logo_control.position:"bottom-left"};if("1"===window.mapster_params.activated&&i.restricted_movement.restrict_movement){let t=i.restricted_movement.allowed_bounds.southwest_longitude,e=i.restricted_movement.allowed_bounds.southwest_latitude,r=i.restricted_movement.allowed_bounds.northeast_longitude,n=i.restricted_movement.allowed_bounds.northeast_latitude;if(""!==t&&""!==e&&""!==r&&""!==n){let i=[[parseFloat(t),parseFloat(e)],[parseFloat(r),parseFloat(n)]];h.maxBounds=i}let o=i.restricted_movement.allowed_zoom.min_zoom;""!==o&&(h.minZoom=parseFloat(o));let s=i.restricted_movement.allowed_zoom.max_zoom;""!==s&&(h.maxZoom=parseFloat(s))}const p=new e.Map(h);i.map_type.custom_style_json&&""!==i.map_type.custom_style_json&&p.setStyle(JSON.parse(i.map_type.custom_style_json));"custom-image"===i.map_type.map_provider&&a.setCustomImageMap(p,i.map_type);i.map_compare&&i.map_compare.enable_map_slider&&i.map_compare.compared_map&&a.setMapCompare(e,p,t,i.map_compare);window[`mapsterMap${t}`]=p;a.setProjectionGlobe(p,i.map_type);jQuery(".mapster-wp-maps-loader-container").hide();return p}setLoader({post_id:t}){const e=new MapsterConstants;jQuery("#mapster-wp-maps-"+t).append(e.loaderHTML())}setLoaderDone({post_id:t}){jQuery("#mapster-wp-maps-"+t+" .mapster-map-loader").fadeOut()}setMapResize({map:t}){t.resize()}setStreetViewControl(){}setMapTypeControl(){}setZoomControl({map:t,mapLibrary:e,controls:i,zoom_control:r}){return(new MapsterHelpers).addMapControl(t,i.zoomControl,r.enable,r.position,e.NavigationControl)}setAttributionControl({map:t,mapLibrary:e,controls:i,attribution_control:r,map_type:n}){}setElevationControl({map:t,mapLibrary:e,controls:i,elevation_line_chart:r,post_id:n,lines:o}){
}set3DControl(t){const{map:e,mapLibrary:i,controls:r}=t;return(new MapsterHelpers).addMapControl(e,r["3dControl"],t["3d_control"].enable,t["3d_control"].position,PitchToggle)}setScaleControl({map:t,mapLibrary:e,controls:i,scale_control:r}){return(new MapsterHelpers).addMapControl(t,i.scaleControl,r.enable,r.position,e.ScaleControl)}setGeolocationControl({map:t,mapLibrary:e,controls:i,geolocation_control:r}){const n=new MapsterHelpers,o={showAccuracyCircle:r.show_accuracy_circle,showUserHeading:r.show_user_heading,trackUserLocation:r.show_user_heading||r.track_user_location},s=n.addMapControl(t,i.geolocationControl,r.enable,r.position,e.GeolocateControl,o);n.setGeolocationOnLoad(r);return s}setFullscreenControl({map:t,mapLibrary:e,controls:i,fullscreen_control:r}){return(new MapsterHelpers).addMapControl(t,i.fullscreenControl,r.enable,r.position,e.FullscreenControl)}setGeocoderControl({map:t,mapLibrary:e,controls:i,geocoder_control:r}){const n=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var o={accessToken:e.accessToken,mapboxgl:e,placeholder:r.placeholder};return n.addMapControl(t,i.geocoderControl,r.enable,r.position,MapboxGeocoder,o)}}setDirectionsControl({map:t,mapLibrary:e,controls:i,directions_control:r}){if("undefined"!=typeof MapboxDirections){const o=new MapsterHelpers;var n={accessToken:e.accessToken,mapboxgl:e,unit:r.unit,profile:r.profile,placeholderOrigin:r.placeholderOrigin};return o.addMapControl(t,i.directionsControl,r.enable,r.position,MapboxDirections,n)}}setCustomSearchFilterControl({map:t,mapLibrary:e,controls:i,custom_search_filter:r,locations:n,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:e,marker:!1,placeholder:r.placeholder};r.include_geocoder?c.accessToken=e.accessToken:c.localGeocoderOnly=!0;""!==r.limit_results&&(c.countries=r.limit_results);(c=l.applyProSearchFilter(r,c)).localGeocoder=t=>l.searchLocalFeatures(r.search_type,t,n,o,s);const u=l.addMapControl(t,i.customSearchControl,r.enable,r.position,MapboxGeocoder,c);if(u){u.on("result",(({result:t})=>{var i=document.createElement("div");i.innerHTML=t.place_name;jQuery(u._inputEl).val(i.innerHTML);const r=a.find((e=>e.mapsterProperties.id===t.id));r&&r.mapsterProperties.data.enable_popup&&r.setPopup(new e.Popup(l.returnPopupOptions(r.mapsterProperties.data)).setHTML(l.getPopupHTML(r.mapsterProperties.id,r.mapsterProperties.data))).togglePopup()}));return u}}}setFilterDropdownControl({map:t,mapLibrary:e,controls:i,filter_dropdown:r,locations:n,lines:o,polygons:s,markers:a}){const l=new MapsterHelpers;if("undefined"!=typeof MapboxGeocoder){var c={mapboxgl:e,localGeocoderOnly:!0,marker:!1,placeholder:r.placeholder,minLength:0,limit:1e3,localGeocoder:t=>l.searchLocalFeatures("exact-match",t,n,o,s)};const u=l.addMapControl(t,i.filterDropdownControl,r.enable,r.position,MapboxGeocoder,c);if(u){r.enable&&l.modifyDropdown(u);u.on("result",(t=>{const i=a.find((e=>e.mapsterProperties.id===t.result.id));i&&i.mapsterProperties.data.enable_popup&&i.setPopup(new e.Popup(l.returnPopupOptions(i.mapsterProperties.data)).setHTML(l.getPopupHTML(i.mapsterProperties.id,i.mapsterProperties.data))).togglePopup()}))}return u}}setCategoryFilterControl({map:t,mapLibrary:e,controls:i,cluster_options:r,category_filter:n,markers:o,dataLayers:s,locations:a,lines:l,polygons:c,map_provider:u,label_icon_clustering:h,circle_clustering:p,marker_clustering:d}){new MapsterHelpers;const f={functionality:n.functionality,independent_children:n.independent_children,initial_visibility:n.initial_visibility,category_display:n.category_display,checkbox_display:n.checkbox_display,pre_selected_categories:n.pre_selected_categories,additional_filters:n.additional_filters,accordion_layout:n.accordion_layout,excluded_categories:n.excluded_categories,show_number_of_features:n.show_number_of_features};i.categoryFilterControl&&t.removeControl(i.categoryFilterControl);if(n.enable){const e=new CategoryControl(f,r,o,s,a,l,c,u,p,h,d);""!==n.render_in_external_div&&document.getElementById(n.render_in_external_div)?document.getElementById(n.render_in_external_div).appendChild(e.onAdd(t)):t.addControl(e,n.position);return e}return!1}setListControl({map:t,mapLibrary:e,controls:i,list:r,locations:n,lines:o,polygons:s,markers:a}){new MapsterHelpers;i.listControl&&t.removeControl(i.listControl);if(r.enable){const i=new ListControl(r,n,o,s,a,e);t.addControl(i,r.position);return i}return!1}setDownloadControl({map:t,mapLibrary:e,controls:i,download_control:r,locations:n,lines:o,polygons:s}){
}setCustomHTMLControl({map:t,mapLibrary:e,controls:i,custom_html_control:r}){
}setLayerControl({map:t,mapLibrary:e,controls:i,layer_control:r}){
}setStyleControl({map:t,mapLibrary:e,controls:i,style_control:r}){
}setListingPosts({post_id:t,map:e,listing_page:i,locations:r,lines:n,polygons:o}){
}setJqueryEvents(){
}}class MapsterContainer{constructor(t,e,i){this.core={};this.MapsterMap=i;this.post_id=t;this.single_feature_id=e;this.postResponse;this.mapLibrary;this.markers=[];this.controls=[];this.clusterLayers=[];this.clickedEvent;this.clickedFeature;this.clickedPopup;this.clickedMarker;this.hoveredEvent;this.hoveredFeature;this.hoveredPopup;this.hoveredMarker;this.tempHoverMarker;this.map;this.postResponseAdmin;this.adminFeatures;this.dataLayers;this.defineCore()}defineCore(){const t=new MapsterCore;this.core.set_accesstokendefault={args:[],hook:"access_token_set",func:t.setDefaultAccessToken};this.core.define_postResponse={args:["post_id","single_feature_id"],hook:"data_fetched",func:t.getPostData,promise:!0};this.core.set_mapSize={args:["post_id","postResponse.map.layout"],hook:"map_size_set",func:t.setMapSize};this.core.define_mapLibrary={args:["postResponse.map.map_type"],hook:"map_library_set",func:t.setMapType};this.core.set_submissionModal={args:["post_id","map","mapLibrary","postResponse.map.submission"],hook:"submission_modal_initialized",func:t.setSubmissionModal};this.core.define_map={args:["post_id","mapLibrary","postResponse.map","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set",func:t.setMap};this.core.set_moveendVariables={args:["map"],hook:"map_moveend",func:t.setMapMoveEndVariables};this.core.set_jquery_events={args:[],hook:"jquery_events_set",func:t.setJqueryEvents};this.core.set_loader={args:["post_id"],hook:"loading_icon_started",func:t.setLoader};this.core.set_loaderdone={args:["post_id"],hook:"loading_icon_done",func:t.setLoaderDone};this.core.set_mapresize={args:["map"],hook:"map_resize_set",func:t.setMapResize};this.core.set_listingposts={args:["post_id","map","postResponse.map.listing_page","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_set_listing_posts",func:t.setListingPosts};this.core.define_dataLayers={args:["map","postResponse.map.map_type.map_provider","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_datalayers_set",func:t.setDataLayers,callback:this.MapsterMap.setDataLayerEvents};this.core.set_mapfeatures={args:["map","postResponse.map.map_type.map_provider","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_features_set",func:t.setFeaturesToMap,callback:this.MapsterMap.setLayerEvents};this.core.define_markers={args:["map","markers","mapLibrary","postResponse.locations","postResponse.map.marker_clustering"],hook:"map_markers_set",func:t.setMarkersToMap,callback:this.MapsterMap.setMarkerEvents};this.core.set_heatmap={args:["map","markers","postResponse.locations","postResponse.map.heatmap"],hook:"map_heatmap_set",func:t.setHeatmap};this.core["define_controls.elevationControl"]={args:["map","mapLibrary","controls","postResponse.map.elevation_line_chart","post_id","postResponse.lines"],hook:"elevation_control_set",func:t.setElevationControl};this.core["define_controls.zoomControl"]={args:["map","mapLibrary","controls","postResponse.map.zoom_control"],hook:"zoom_control_set",func:t.setZoomControl};this.core["define_controls.attributionControl"]={args:["map","mapLibrary","controls","postResponse.map.attribution_control","postResponse.map.map_type"],hook:"attribution_control_set",func:t.setAttributionControl};this.core["define_controls.streetViewControl"]={args:["map","mapLibrary","controls","postResponse.map.street_view_control"],hook:"street_view_control_set",func:t.setStreetViewControl};this.core["define_controls.mapTypeControl"]={args:["map","mapLibrary","controls","postResponse.map.map_type_control"],hook:"map_type_control_set",func:t.setMapTypeControl};this.core["define_controls.geocoderControl"]={args:["map","mapLibrary","controls","postResponse.map.geocoder_control"],hook:"geocoder_control_set",func:t.setGeocoderControl};this.core["define_controls.directionsControl"]={args:["map","mapLibrary","controls","postResponse.map.directions_control"],hook:"directions_control_set",func:t.setDirectionsControl};this.core["define_controls.3dControl"]={args:["map","mapLibrary","controls","postResponse.map.3d_control"],hook:"3d_control_set",func:t.set3DControl};this.core["define_controls.scaleControl"]={args:["map","mapLibrary","controls","postResponse.map.scale_control"],hook:"scale_control_set",func:t.setScaleControl};this.core["define_controls.geolocationControl"]={args:["map","mapLibrary","controls","postResponse.map.geolocation_control"],hook:"geolocation_control_set",func:t.setGeolocationControl};this.core["define_controls.fullscreenControl"]={args:["map","mapLibrary","controls","postResponse.map.fullscreen_control"],hook:"fullscreen_control_set",func:t.setFullscreenControl};this.core["define_controls.downloadControl"]={args:["map","mapLibrary","controls","postResponse.map.download_control","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"download_control_set",func:t.setDownloadControl};this.core["define_controls.customHTMLControl"]={args:["map","mapLibrary","controls","postResponse.map.custom_html_control"],hook:"custom_html_control_set",func:t.setCustomHTMLControl};this.core["define_controls.layerControl"]={args:["map","mapLibrary","controls","postResponse.map.layer_control"],hook:"layer_control_set",func:t.setLayerControl};this.core["define_controls.styleControl"]={args:["map","mapLibrary","controls","postResponse.map.style_control"],hook:"style_control_set",func:t.setStyleControl};this.core["define_controls.customSearchControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.custom_search_filter","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"customSearch_control_set",func:t.setCustomSearchFilterControl};this.core["define_controls.filterDropdownControl"]={args:["map","mapLibrary","controls","postResponse.map.filter.filter_dropdown","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"filterDropdown_control_set",func:t.setFilterDropdownControl};this.core["define_controls.categoryFilterControl"]={args:["map","mapLibrary","controls","postResponse.map.cluster_options","postResponse.map.filter.category_filter","markers","dataLayers","postResponse.locations","postResponse.lines","postResponse.polygons","postResponse.map.map_type.map_provider","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering"],hook:"categoryFilter_control_set",func:t.setCategoryFilterControl};this.core["define_controls.listControl"]={args:["map","mapLibrary","controls","postResponse.map.list","postResponse.locations","postResponse.lines","postResponse.polygons","markers"],hook:"list_control_set",func:t.setListControl};this.core.define_clusterLayers={args:["map","postResponse.map.map_type.map_provider","postResponse.map.cluster_options","postResponse.map.circle_clustering","postResponse.map.label_icon_clustering","postResponse.map.marker_clustering","markers","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"map_clustering_set",func:t.doClustering,callback:this.MapsterMap.setDynamicLayerEvents};this.core.set_customscripts={args:["map","postResponse.map.javascript","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"custom_scripts_set",func:t.loadCustomScripts};this.core.set_interactivity={args:["map","postResponse.map.zoom_on_scroll","postResponse.map.interactivity","postResponse.map.allow_rotation_and_pitch"],hook:"interactivity_set",func:t.setInteractivity};this.core.set_mapstyle={args:["map","postResponse.map.map_type"],hook:"map_style_set",func:t.setMapStyle,callback:this.MapsterMap.idleReload};this.core.set_terrain={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.terrain"],hook:"map_terrain_set",func:t.loadTerrain};this.core.set_projection={args:["map","postResponse.map.map_type.map_provider","postResponse.map.map_type.projection"],hook:"map_projection_set",func:t.loadProjection};this.core.define_clickedFeature={args:["map","postResponse.map.interactivity","clickedEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_clicked",func:t.layerClick};this.core.set_storelocatorclick={args:["clickedFeature","postResponse.map.list.store_locator_options"],hook:"",func:t.storeLocatorClick};this.core.set_sidebarclick={args:["post_id","clickedFeature","postResponse.map.minimum_sidebar_width","postResponse.map.maximum_sidebar_width","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"",func:t.sidebarClick};this.core.define_clickedPopup={args:["map","mapLibrary","clickedPopup","clickedFeature","clickedEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_click",func:t.popupClick};this.core.define_hoveredFeature={args:["map","postResponse.map.interactivity","hoveredEvent","postResponse.locations","postResponse.lines","postResponse.polygons"],hook:"layer_feature_hovered",func:t.layerHover};this.core.set_hoverEffects={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:t.layerHoverEffect};this.core.define_hoveredPopup={args:["map","mapLibrary","hoveredPopup","hoveredFeature","hoveredEvent","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_layer_hover",func:t.popupHover};this.core.set_hoverEffectsOff={args:["map","postResponse.map.interactivity","hoveredFeature","dataLayers"],hook:"",func:t.layerHoverEffectOff};this.core.set_hoveredPopupOff={args:["hoveredFeature","hoveredPopup"],hook:"popup_closed_from_layer_hover",func:t.removePopupHover};this.core.set_externallink={args:["clickedFeature"],hook:"external_link_opened",func:t.externalClickLayer};this.core.define_clickedFeature_fromMarker={args:["clickedMarker","postResponse.map.interactivity"],hook:"marker_feature_clicked",func:t.markerClick};this.core.define_hoveredFeature_fromMarker={args:["hoveredMarker","postResponse.map.interactivity"],hook:"marker_feature_hovered",func:t.markerHover};this.core.define_tempHoverMarker={args:["map","mapLibrary","postResponse.map.interactivity","hoveredMarker"],hook:"",func:t.markerHoverEffect};this.core.define_clickedPopup_fromMarker={args:["map","mapLibrary","clickedMarker","clickedFeature","clickedPopup","postResponse.map.list.store_locator_options","postResponse.map.open_popups_in_sidebar"],hook:"popup_opened_from_marker_click",func:t.openMarkerClickPopup};this.core.define_hoveredPopup_fromMarker={args:["map","mapLibrary","hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_opened_from_marker_hover",func:t.openMarkerHoverPopup};this.core.set_hoverEffectsOff_fromMarker={args:["tempHoverMarker","hoveredMarker"],hook:"",func:t.markerHoverEffectOff};this.core.set_hoveredPopupOff_fromMarker={args:["hoveredMarker","hoveredFeature","hoveredPopup"],hook:"popup_closed_from_marker_hover",func:t.removeMarkerHoverPopup};this.core.define_adminFeatures={args:["postResponseAdmin.locations_ids","postResponseAdmin.lines_ids","postResponseAdmin.polygons_ids","postResponse.cats"],hook:"",func:t.getFeaturesAdmin,promise:!0};this.core["define_postResponse.locations"]={args:["adminFeatures"],hook:"locations_fetched",func:t.sortLocations};this.core["define_postResponse.lines"]={args:["adminFeatures"],hook:"lines_fetched",func:t.sortLines};this.core["define_postResponse.polygons"]={args:["adminFeatures"],hook:"polygons_fetched",func:t.sortPolygons}}doCore(t){let e=this.core[t].args,i=this.core[t].func,r={};for(var n=0;n<e.length;n++){let t=e[n].split(".");r[t[t.length-1]]=this.getObjectProperty(this,e[n])}if(this.core[t].promise)return Promise.resolve(i(r)).then((e=>{this.defineThisObject(t,e);this.core[t].callback&&this.core[t].callback(this,this.MapsterMap);this.core[t].hook&&this.MapsterMap.runHookActions(t,e)}));{const e=i(r);this.defineThisObject(t,e);this.core[t].callback&&this.core[t].callback(this,this.MapsterMap);this.core[t].hook&&this.MapsterMap.runHookActions(t,e);return e}}registerListener(t,e,i,r){this.setStarterValue(t,e,i);jQuery(document).on("change","select"!==e?t:t.replace("select",":input"),(()=>{"check"===e&&this.setObjectProperty(this,i,jQuery(t).is(":checked"));"val"===e&&this.setObjectProperty(this,i,jQuery(t).val());"select"===e&&this.setObjectProperty(this,i,jQuery(t).select2("data").map((t=>t.id)));if(r&&r.length>0)for(var n=0;n<r.length;n++){if(this.core[r[n]].promise){this.MapsterMap.doCoreAndRunActions(r[n]).then((()=>{for(var t=n+1;t<r.length;t++)this.MapsterMap.doCoreAndRunActions(r[t])}));break}this.MapsterMap.doCoreAndRunActions(r[n])}}))}setStarterValue(t,e,i){"check"===e&&this.setObjectProperty(this,i,jQuery(t).is(":checked"));"val"===e&&this.setObjectProperty(this,i,jQuery(t).val());"select"===e&&this.setObjectProperty(this,i,jQuery(t).select2("data").map((t=>t.id)))}defineThisObject(t,e){t.indexOf("define_")>-1&&this.setObjectProperty(this,t.split("_")[1],e)}getObjectProperty(t,e){return e.split(".").reduce(((t,e)=>t?.[e]),t)}setObjectProperty(t,e,i){e.split(".").reduce(((t,r)=>{r===e.split(".")[e.split(".").length-1]&&(t[r]=i);void 0===t[r]&&(r===e.split(".")[e.split(".").length-1]?t[r]="":t[r]={});return t?.[r]}),t)}}class MapsterMap{constructor(t,e,i){this.MapsterContainer=new MapsterContainer(t,i,this);this.post_id=t;this.isPublic=e;this.dynamicLayerListenersSet=!1;this.isPublic||this.registerAdminEventListeners()}preInitMap(){return this.isPublic?this.doCoreAndRunActions("define_postResponse"):this.doCoreAndRunActions("define_adminFeatures")}init(){this.preInitMap().then((()=>{if(!this.isPublic){this.doCoreAndRunActions("set_accesstokendefault");this.doCoreAndRunActions("define_postResponse.locations");this.doCoreAndRunActions("define_postResponse.lines");this.doCoreAndRunActions("define_postResponse.polygons")}this.initMap();this.MapsterContainer.map.on("load",(()=>{this.postLoad();this.setMoveEvents(this.MapsterContainer.map)}));this.MapsterContainer.map.on("mapster_custom_style_load",(()=>{this.postStyleSwitch(this.MapsterContainer,this)}))}))}initMap(){this.isPublic&&this.doCoreAndRunActions("set_mapSize");this.doCoreAndRunActions("define_mapLibrary");this.doCoreAndRunActions("define_map");this.doCoreAndRunActions("set_jquery_events");this.doCoreAndRunActions("set_loader");if(this.isPublic){this.doCoreAndRunActions("set_submissionModal");this.doCoreAndRunActions("set_interactivity");this.doCoreAndRunActions("set_listingposts")}}postLoad(){this.doCoreAndRunActions("set_mapresize");this.doCoreAndRunActions("set_terrain");this.doCoreAndRunActions("set_mapfeatures");this.doCoreAndRunActions("define_dataLayers");this.doCoreAndRunActions("define_markers");this.doCoreAndRunActions("set_heatmap");this.setControls();this.isPublic&&this.doCoreAndRunActions("define_clusterLayers");this.doCoreAndRunActions("set_loaderdone");this.doCoreAndRunActions("set_customscripts")}setControls(){this.doCoreAndRunActions("define_controls.zoomControl");this.doCoreAndRunActions("define_controls.mapTypeControl");this.doCoreAndRunActions("define_controls.streetViewControl");this.doCoreAndRunActions("define_controls.attributionControl");this.doCoreAndRunActions("define_controls.geocoderControl");this.doCoreAndRunActions("define_controls.directionsControl");this.doCoreAndRunActions("define_controls.3dControl");this.doCoreAndRunActions("define_controls.scaleControl");this.doCoreAndRunActions("define_controls.geolocationControl");this.doCoreAndRunActions("define_controls.fullscreenControl");this.doCoreAndRunActions("define_controls.downloadControl");this.doCoreAndRunActions("define_controls.customHTMLControl");this.doCoreAndRunActions("define_controls.layerControl");this.doCoreAndRunActions("define_controls.styleControl");this.doCoreAndRunActions("define_controls.customSearchControl");this.doCoreAndRunActions("define_controls.filterDropdownControl");this.doCoreAndRunActions("define_controls.categoryFilterControl");this.doCoreAndRunActions("define_controls.elevationControl");this.doCoreAndRunActions("define_controls.listControl")}idleReload(t,e){t.map.once("idle",(()=>{e.doCoreAndRunActions("set_loader");e.doCoreAndRunActions("set_terrain");e.doCoreAndRunActions("set_mapfeatures");e.doCoreAndRunActions("define_dataLayers");e.doCoreAndRunActions("define_markers");e.doCoreAndRunActions("define_clusterLayers");e.doCoreAndRunActions("set_loaderdone")}))}postStyleSwitch(t,e){t.map.once("idle",(()=>{e.doCoreAndRunActions("set_terrain");e.doCoreAndRunActions("set_mapfeatures");e.doCoreAndRunActions("define_dataLayers");e.doCoreAndRunActions("define_markers");e.doCoreAndRunActions("define_clusterLayers")}))}setLayerEvents(t,e){["symbol","circle","line","fill"].forEach((i=>{t.map.on("click",i,(i=>{t.clickedEvent=i;e.doCoreAndRunActions("define_clickedFeature");e.doCoreAndRunActions("set_storelocatorclick");e.doCoreAndRunActions("set_sidebarclick");e.doCoreAndRunActions("set_externallink");e.doCoreAndRunActions("define_clickedPopup")}));t.map.on("mousemove",i,(i=>{t.hoveredEvent=i;e.doCoreAndRunActions("define_hoveredFeature");e.doCoreAndRunActions("set_hoverEffects");e.doCoreAndRunActions("define_hoveredPopup")}));t.map.on("mouseout",i,(t=>{e.doCoreAndRunActions("set_hoverEffectsOff");e.doCoreAndRunActions("set_hoveredPopupOff")}))}))}setDynamicLayerEvents(t,e){if(t.clusterLayers.length>0&&!this.dynamicLayerListenersSet){t.clusterLayers.forEach((i=>{if(i.indexOf("-")>-1){t.map.on("click",i,(i=>{t.clickedEvent=i;e.doCoreAndRunActions("define_clickedFeature");e.doCoreAndRunActions("set_storelocatorclick");e.doCoreAndRunActions("set_sidebarclick");e.doCoreAndRunActions("set_externallink");e.doCoreAndRunActions("define_clickedPopup")}));t.map.on("mousemove",i,(i=>{t.hoveredEvent=i;e.doCoreAndRunActions("define_hoveredFeature");e.doCoreAndRunActions("set_hoverEffects");e.doCoreAndRunActions("define_hoveredPopup")}));t.map.on("mouseout",i,(t=>{e.doCoreAndRunActions("set_hoverEffectsOff");e.doCoreAndRunActions("set_hoveredPopupOff")}))}}));this.dynamicLayerListenersSet=!0}}setDataLayerEvents(t,e){}setMarkerEvents(t,e){t.markers.forEach((i=>{i.getElement().addEventListener("click",(()=>{t.clickedMarker=i;e.doCoreAndRunActions("define_clickedFeature_fromMarker");e.doCoreAndRunActions("set_storelocatorclick");e.doCoreAndRunActions("set_sidebarclick");e.doCoreAndRunActions("set_externallink");e.doCoreAndRunActions("define_clickedPopup_fromMarker")}));i.getElement().addEventListener("mouseenter",(r=>{t.hoveredMarker=i;e.doCoreAndRunActions("define_hoveredFeature_fromMarker");e.doCoreAndRunActions("define_tempHoverMarker");e.doCoreAndRunActions("define_hoveredPopup_fromMarker")}));i.getElement().addEventListener("mouseleave",(t=>{e.doCoreAndRunActions("set_hoverEffectsOff_fromMarker");e.doCoreAndRunActions("set_hoveredPopupOff_fromMarker")}))}))}setMoveEvents(t){if(!this.isPublic){t.once("idle",(t=>{this.doCoreAndRunActions("set_moveendVariables")}));t.on("moveend",(t=>{this.doCoreAndRunActions("set_moveendVariables")}))}}doCoreAndRunActions(t){return this.MapsterContainer.doCore(t)}runHookActions(t,e){if(window.mwm){let r=this.MapsterContainer.core[t].hook;const n=`${r}/mapster-${this.isPublic?this.post_id:"admin"}`;if(window.mwm.actions[n]){window.mwm.actions[n].funcs;if(window.mwm.actions[n].funcs.length>0)for(var i=0;i<window.mwm.actions[n].funcs.length;i++)window.mwm.actions[n].funcs[i].func(e)}if(window.mwm.actions[r]){window.mwm.actions[r].funcs;if(window.mwm.actions[r].funcs.length>0)for(i=0;i<window.mwm.actions[r].funcs.length;i++)window.mwm.actions[r].funcs[i].func(e)}}}registerAdminEventListeners(){this.MapsterContainer.registerListener('.acf-field[data-name="zoom_on_scroll"] :input',"check","postResponse.map.zoom_on_scroll");this.MapsterContainer.registerListener('.acf-field[data-name="interactivity"] :input',"check","postResponse.map.interactivity");this.MapsterContainer.registerListener('.acf-field[data-name="open_popups_in_sidebar"] :input',"check","postResponse.map.open_popups_in_sidebar");this.MapsterContainer.registerListener('.acf-field[data-name="restrict_movement"] :input',"check","postResponse.map.restricted_movement.restrict_movement");this.MapsterContainer.registerListener('.acf-field[data-name="southwest_longitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.southwest_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="southwest_latitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.southwest_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="northeast_longitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.northeast_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="northeast_latitude"] :input',"val","postResponse.map.restricted_movement.allowed_bounds.northeast_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="min_zoom"] :input',"val","postResponse.map.restricted_movement.allowed_zoom.min_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="max_zoom"] :input',"val","postResponse.map.restricted_movement.allowed_zoom.max_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="zoom_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.zoom_control.enable",["define_controls.zoomControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="zoom_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.zoom_control.position",["define_controls.zoomControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="3d_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.3d_control.enable",["define_controls.3dControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="3d_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.3d_control.position",["define_controls.3dControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="scale_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.scale_control.enable",["define_controls.scaleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="scale_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.scale_control.position",["define_controls.scaleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="attribution_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.attribution_control.position",["define_controls.attributionControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.geolocation_control.enable",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.geolocation_control.position",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geolocation_control"] .acf-field[data-name="set_on_load"] :input',"check","postResponse.map.geolocation_control.set_on_load",["define_controls.geolocationControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="fullscreen_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.fullscreen_control.enable",["define_controls.fullscreenControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="fullscreen_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.fullscreen_control.position",["define_controls.fullscreenControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="street_view_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.street_view_control.enable",["define_controls.streetViewControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="street_view_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.street_view_control.position",["define_controls.streetViewControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_type_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.map_type_control.enable",["define_controls.mapTypeControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_type_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.map_type_control.position",["define_controls.mapTypeControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.download_control.enable",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.download_control.position",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="interact_with_filters"] :input',"check","postResponse.map.download_control.interact_with_filters",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="download_control"] .acf-field[data-name="notify_on_download"] :input',"val","postResponse.map.download_control.notify_on_download",["define_controls.downloadControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.custom_html_control.enable",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.custom_html_control.position",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_html_control"] .acf-field[data-name="custom_html"] :input',"val","postResponse.map.custom_html_control.custom_html",["define_controls.customHTMLControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.layer_control.enable",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.layer_control.position",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="toggleable_layers"] :input',"val","postResponse.map.layer_control.toggleable_layers",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="toggleable_layer_titles"] :input',"val","postResponse.map.layer_control.toggleable_layer_titles",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="layer_control"] .acf-field[data-name="checkbox_type"] :input',"val","postResponse.map.layer_control.checkbox_type",["define_controls.layerControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.style_control.enable",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.style_control.position",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="toggleable_styles"] :input',"val","postResponse.map.style_control.toggleable_styles",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="toggleable_styles_titles"] :input',"val","postResponse.map.style_control.toggleable_styles_titles",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="style_control"] .acf-field[data-name="initial_style_title"] :input',"val","postResponse.map.style_control.initial_style_title",["define_controls.styleControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.geocoder_control.enable",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.geocoder_control.position",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="limit_results"] :input',"val","postResponse.map.geocoder_control.limit_results",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="geocoder_control"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.geocoder_control.placeholder",["define_controls.geocoderControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="enable"] :input',"check","postResponse.map.directions_control.enable",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="position"] :input',"val","postResponse.map.directions_control.position",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="unit"] :input',"val","postResponse.map.directions_control.unit",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="profile"] :input',"val","postResponse.map.directions_control.profile",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="directions_control"] .acf-field[data-name="placeholderOrigin"] :input',"val","postResponse.map.directions_control.placeholderOrigin",["define_controls.directionsControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.custom_search_filter.enable",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.custom_search_filter.position",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="include_geocoder"] :input',"check","postResponse.map.filter.custom_search_filter.include_geocoder",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="limit_results"] :input',"val","postResponse.map.filter.custom_search_filter.limit_results",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="number_of_results"] :input',"val","postResponse.map.filter.custom_search_filter.number_of_results",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_search_filter"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.filter.custom_search_filter.placeholder",["define_controls.customSearchControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.filter_dropdown.enable",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.filter_dropdown.position",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="filter_dropdown"] .acf-field[data-name="placeholder"] :input',"val","postResponse.map.filter.filter_dropdown.placeholder",["define_controls.filterDropdownControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="enable"] :input',"check","postResponse.map.filter.category_filter.enable",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="position"] :input',"val","postResponse.map.filter.category_filter.position",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="initial_visibility"] :input',"check","postResponse.map.filter.category_filter.initial_visibility",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="functionality"] :input',"val","postResponse.map.filter.category_filter.functionality",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="independent_children"] :input',"check","postResponse.map.filter.category_filter.independent_children",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="category_display"] :input',"val","postResponse.map.filter.category_filter.category_display",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="checkbox_display"] :input',"val","postResponse.map.filter.category_filter.checkbox_display",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="category_filter"] .acf-field[data-name="pre_selected_categories"] :input',"val","postResponse.map.filter.category_filter.pre_selected_categories",["define_controls.categoryFilterControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="enable"] :input',"check","postResponse.map.list.enable",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="position"] :input',"val","postResponse.map.list.position",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="units"] :input',"val","postResponse.map.list.units",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="show_distance"] :input',"check","postResponse.map.list.show_distance",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="sort_by_distance"] :input',"check","postResponse.map.list.sort_by_distance",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="listing_type"] :input',"val","postResponse.map.list.listing_type",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="number_of_locations"] :input',"val","postResponse.map.list.number_of_locations",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="store_locator_options"] .acf-field[data-name="enable"] :input',"check","postResponse.map.list.store_locator_options.enable",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="list"] .acf-field[data-name="store_locator_options"] .acf-field[data-name="sort_hours_by_day"] :input',"check","postResponse.map.list.store_locator_options.sort_hours_by_day",["define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="locations"] select',"select","postResponseAdmin.locations_ids",["define_adminFeatures","define_postResponse.locations","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="lines"] select',"select","postResponseAdmin.lines_ids",["define_adminFeatures","define_postResponse.lines","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="polygons"] select',"select","postResponseAdmin.polygons_ids",["define_adminFeatures","define_postResponse.polygons","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="add_by_category"] select',"select","postResponse.cats",["define_adminFeatures","define_postResponse.locations","define_postResponse.lines","define_postResponse.polygons","set_mapfeatures","define_dataLayers","define_markers","define_controls.customSearchControl","define_controls.filterDropdownControl","define_controls.categoryFilterControl","define_controls.listControl"]);this.MapsterContainer.registerListener('.acf-field[data-name="manual_latitude"] :input',"val","postResponse.map.view.manual_latitude");this.MapsterContainer.registerListener('.acf-field[data-name="manual_longitude"] :input',"val","postResponse.map.view.manual_longitude");this.MapsterContainer.registerListener('.acf-field[data-name="manual_zoom"] :input',"val","postResponse.map.view.manual_zoom");this.MapsterContainer.registerListener('.acf-field[data-name="manual_pitch"] :input',"val","postResponse.map.view.manual_pitch");this.MapsterContainer.registerListener('.acf-field[data-name="manual_rotation"] :input',"val","postResponse.map.view.manual_rotation");this.MapsterContainer.registerListener('.acf-field[data-name="initial_load"] :input',"val","postResponse.map.view.initial_load");this.MapsterContainer.registerListener('.acf-field[data-name="circle_clustering"] :input',"check","postResponse.map.circle_clustering");this.MapsterContainer.registerListener('.acf-field[data-name="label_icon_clustering"] :input',"check","postResponse.map.label_icon_clustering");this.MapsterContainer.registerListener('.acf-field[data-name="enable_heatmap"] :input',"check","postResponse.map.heatmap.enable_heatmap",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_layer"] :input',"val","postResponse.map.heatmap.heatmap_layer",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_layer_visibility"] :input',"val","postResponse.map.heatmap.heatmap_layer_visibility",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_weighted_property"] :input',"val","postResponse.map.heatmap.heatmap_weighted_property",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_intensity"] :input',"val","postResponse.map.heatmap.heatmap_intensity",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_color_range"] :input',"val","postResponse.map.heatmap.heatmap_color_range",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_point_radius"] :input',"val","postResponse.map.heatmap.heatmap_point_radius",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="heatmap_opacity"] :input',"val","postResponse.map.heatmap.heatmap_opacity",["set_heatmap"]);this.MapsterContainer.registerListener('.acf-field[data-name="enable_elevation_chart"] :input',"check","postResponse.map.elevation_line_chart.enable_elevation_chart");this.MapsterContainer.registerListener('.acf-field[data-name="map_provider"] :input',"val","postResponse.map.map_type.map_provider",["define_mapLibrary"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_tile_style_access_token"] :input',"val","postResponse.map.map_type.map_tile_style_access_token",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="map_tile_style_no_access_token"] :input',"val","postResponse.map.map_type.map_tile_style_no_access_token",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="access_token"] :input',"val","postResponse.map.map_type.access_token");this.MapsterContainer.registerListener('.acf-field[data-name="custom_mapbox_style"] :input',"val","postResponse.map.map_type.custom_mapbox_style",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_style_json"] :input',"val","postResponse.map.map_type.custom_style_json",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="snazzy_map_style"] :input',"val","postResponse.map.map_type.snazzy_map_style",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="custom_image"] :input',"val","postResponse.map.map_type.custom_image",["set_mapstyle"]);this.MapsterContainer.registerListener('.acf-field[data-name="duplicate_horizontally"] :input',"check","postResponse.map.layout.duplicate_horizontally");this.MapsterContainer.registerListener('.acf-field[data-name="terrain"] :input',"check","postResponse.map.map_type.terrain",["set_terrain"]);this.MapsterContainer.registerListener('.acf-field[data-name="projection"] :input',"val","postResponse.map.map_type.projection",["set_projection"]);this.MapsterContainer.registerListener('.acf-field[data-name="globe"] :input',"check","postResponse.map.map_type.globe",[]);this.MapsterContainer.registerListener('.acf-field[data-name="globe_background"] :input',"val","postResponse.map.map_type.globe_background",[])}}class MapsterPublic{constructor(){this.actions={}}add_action(t,e){this.actions[t]||(this.actions[t]={funcs:[]});this.actions[t].funcs.push({func:e})}}window.mwm=new MapsterPublic;!function(t){if(window.mapster_params.public)(o=".mapster-wp-maps",new Promise((t=>{if(document.querySelector(o))return t(document.querySelector(o));const e=new MutationObserver((i=>{if(document.querySelector(o)){t(document.querySelector(o));e.disconnect()}}));e.observe(document.body,{childList:!0,subtree:!0})}))).then((e=>{t(".mapster-wp-maps").each((function(){const e=t(this).attr("id").replace("mapster-wp-maps-",""),i=""!==t(this).data("single_feature_id")&&t(this).data("single_feature_id");new MapsterMap(e,window.mapster_params.public,i).init()}))}));else{let s="Publish this post to generate an embed code.";const a=new URLSearchParams(window.location.search);if(a.has("post")){let c=window.mapster_params.directory.replace("/admin/","/admin/includes/mapster-embed-map.php");c=c+window.mapster_params.qd+"map_id="+a.get("post");s=`<embed src="${c}" />`}let l="Publish this post to generate an listing code.";a.has("post")&&(l=`[mapster_listing_posts id="${a.get("post")}"]`);if(document.body.classList.contains("block-editor-page")){t("#mapster-wp-maps-preview").prependTo("#normal-sortables");t(".acf-field-625df5ebf4ecc .acf-input").text(s);t(".acf-field-6507ba6e3053a .acf-input").text(l)}else{t("#mapster-wp-maps-preview").prependTo("#acf_after_title-sortables");t(".acf-field-625df5ebf4ecc .acf-input").text(s);t(".acf-field-6507ba6e3053a .acf-input").text(l)}if(a.has("post")){let u=`\n [mapster_wp_map_submit map_id="${a.get("post")}" type="create_point"]<br />\n [mapster_wp_map_submit map_id="${a.get("post")}" type="edit_point" button_text="Edit Point" header_text="Edit Point"]\n `;t(".acf-field-62bf86b094491 .acf-input").append(u)}var e=acf.getFields().length,i=0,r=0;function n(t){"select"!==t&&(i+=1);i===e&&4===r&&new MapsterMap("map",window.mapster_params.public,!1).init()}acf.add_action("ready_field",n);acf.addAction("select2_init",(function(t,e,i,o){r+=1;n("select")}))}var o}(jQuery);